projects
/
firefly-linux-kernel-4.4.55.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[PATCH] v9fs: simplify fid mapping
[firefly-linux-kernel-4.4.55.git]
/
fs
/
9p
/
v9fs.c
diff --git
a/fs/9p/v9fs.c
b/fs/9p/v9fs.c
index 418c3743fdee85c89452f9f6c0dda13dbb404007..61352491ba36c0798cf6632de1c3e9e8cdb4e00a 100644
(file)
--- a/
fs/9p/v9fs.c
+++ b/
fs/9p/v9fs.c
@@
-37,7
+37,6
@@
#include "v9fs_vfs.h"
#include "transport.h"
#include "mux.h"
#include "v9fs_vfs.h"
#include "transport.h"
#include "mux.h"
-#include "conv.h"
/* TODO: sysfs or debugfs interface */
int v9fs_debug_level = 0; /* feature-rific global debug level */
/* TODO: sysfs or debugfs interface */
int v9fs_debug_level = 0; /* feature-rific global debug level */
@@
-67,7
+66,7
@@
static match_table_t tokens = {
{Opt_afid, "afid=%u"},
{Opt_rfdno, "rfdno=%u"},
{Opt_wfdno, "wfdno=%u"},
{Opt_afid, "afid=%u"},
{Opt_rfdno, "rfdno=%u"},
{Opt_wfdno, "wfdno=%u"},
- {Opt_debug, "debug=%
u
"},
+ {Opt_debug, "debug=%
x
"},
{Opt_name, "name=%s"},
{Opt_remotename, "aname=%s"},
{Opt_unix, "proto=unix"},
{Opt_name, "name=%s"},
{Opt_remotename, "aname=%s"},
{Opt_unix, "proto=unix"},
@@
-213,7
+212,8
@@
retry:
return -1;
}
return -1;
}
- error = idr_get_new(&p->pool, NULL, &i);
+ /* no need to store exactly p, we just need something non-null */
+ error = idr_get_new(&p->pool, p, &i);
up(&p->lock);
if (error == -EAGAIN)
up(&p->lock);
if (error == -EAGAIN)
@@
-242,6
+242,16
@@
void v9fs_put_idpool(int id, struct v9fs_idpool *p)
up(&p->lock);
}
up(&p->lock);
}
+/**
+ * v9fs_check_idpool - check if the specified id is available
+ * @id - id to check
+ * @p - pool
+ */
+int v9fs_check_idpool(int id, struct v9fs_idpool *p)
+{
+ return idr_find(&p->pool, id) != NULL;
+}
+
/**
* v9fs_session_init - initialize session
* @v9ses: session information structure
/**
* v9fs_session_init - initialize session
* @v9ses: session information structure
@@
-259,6
+269,7
@@
v9fs_session_init(struct v9fs_session_info *v9ses,
int n = 0;
int newfid = -1;
int retval = -EINVAL;
int n = 0;
int newfid = -1;
int retval = -EINVAL;
+ struct v9fs_str *version;
v9ses->name = __getname();
if (!v9ses->name)
v9ses->name = __getname();
if (!v9ses->name)
@@
-281,9
+292,6
@@
v9fs_session_init(struct v9fs_session_info *v9ses,
/* id pools that are session-dependent: FIDs and TIDs */
idr_init(&v9ses->fidpool.pool);
init_MUTEX(&v9ses->fidpool.lock);
/* id pools that are session-dependent: FIDs and TIDs */
idr_init(&v9ses->fidpool.pool);
init_MUTEX(&v9ses->fidpool.lock);
- idr_init(&v9ses->tidpool.pool);
- init_MUTEX(&v9ses->tidpool.lock);
-
switch (v9ses->proto) {
case PROTO_TCP:
switch (v9ses->proto) {
case PROTO_TCP:
@@
-320,7
+328,12
@@
v9fs_session_init(struct v9fs_session_info *v9ses,
v9ses->shutdown = 0;
v9ses->session_hung = 0;
v9ses->shutdown = 0;
v9ses->session_hung = 0;
- if ((retval = v9fs_mux_init(v9ses, dev_name)) < 0) {
+ v9ses->mux = v9fs_mux_init(v9ses->transport, v9ses->maxdata + V9FS_IOHDRSZ,
+ &v9ses->extended);
+
+ if (IS_ERR(v9ses->mux)) {
+ retval = PTR_ERR(v9ses->mux);
+ v9ses->mux = NULL;
dprintk(DEBUG_ERROR, "problem initializing mux\n");
goto SessCleanUp;
}
dprintk(DEBUG_ERROR, "problem initializing mux\n");
goto SessCleanUp;
}
@@
-339,13
+352,16
@@
v9fs_session_init(struct v9fs_session_info *v9ses,
goto FreeFcall;
}
goto FreeFcall;
}
- /* Really should check for 9P1 and report error */
- if (
!strcmp(fcall->params.rversion.version, "9P2000.u"
)) {
+ version = &fcall->params.rversion.version;
+ if (
version->len==8 && !memcmp(version->str, "9P2000.u", 8
)) {
dprintk(DEBUG_9P, "9P2000 UNIX extensions enabled\n");
v9ses->extended = 1;
dprintk(DEBUG_9P, "9P2000 UNIX extensions enabled\n");
v9ses->extended = 1;
- } else {
+ } else
if (version->len==6 && !memcmp(version->str, "9P2000", 6))
{
dprintk(DEBUG_9P, "9P2000 legacy mode enabled\n");
v9ses->extended = 0;
dprintk(DEBUG_9P, "9P2000 legacy mode enabled\n");
v9ses->extended = 0;
+ } else {
+ retval = -EREMOTEIO;
+ goto FreeFcall;
}
n = fcall->params.rversion.msize;
}
n = fcall->params.rversion.msize;
@@
-381,7
+397,8
@@
v9fs_session_init(struct v9fs_session_info *v9ses,
}
if (v9ses->afid != ~0) {
}
if (v9ses->afid != ~0) {
- if (v9fs_t_clunk(v9ses, v9ses->afid, NULL))
+ dprintk(DEBUG_ERROR, "afid not equal to ~0\n");
+ if (v9fs_t_clunk(v9ses, v9ses->afid))
dprintk(DEBUG_ERROR, "clunk failed\n");
}
dprintk(DEBUG_ERROR, "clunk failed\n");
}
@@
-403,13
+420,16
@@
v9fs_session_init(struct v9fs_session_info *v9ses,
void v9fs_session_close(struct v9fs_session_info *v9ses)
{
void v9fs_session_close(struct v9fs_session_info *v9ses)
{
- if (v9ses->
recvproc
) {
-
send_sig(SIGKILL, v9ses->recvproc, 1
);
-
wait_for_completion(&v9ses->proccmpl)
;
+ if (v9ses->
mux
) {
+
v9fs_mux_destroy(v9ses->mux
);
+
v9ses->mux = NULL
;
}
}
- if (v9ses->transport)
+ if (v9ses->transport)
{
v9ses->transport->close(v9ses->transport);
v9ses->transport->close(v9ses->transport);
+ kfree(v9ses->transport);
+ v9ses->transport = NULL;
+ }
__putname(v9ses->name);
__putname(v9ses->remotename);
__putname(v9ses->name);
__putname(v9ses->remotename);
@@
-420,8
+440,9
@@
void v9fs_session_close(struct v9fs_session_info *v9ses)
* and cancel all pending requests.
*/
void v9fs_session_cancel(struct v9fs_session_info *v9ses) {
* and cancel all pending requests.
*/
void v9fs_session_cancel(struct v9fs_session_info *v9ses) {
+ dprintk(DEBUG_ERROR, "cancel session %p\n", v9ses);
v9ses->transport->status = Disconnected;
v9ses->transport->status = Disconnected;
- v9fs_mux_cancel
_requests(v9ses
, -EIO);
+ v9fs_mux_cancel
(v9ses->mux
, -EIO);
}
extern int v9fs_error_init(void);
}
extern int v9fs_error_init(void);
@@
-433,11
+454,17
@@
extern int v9fs_error_init(void);
static int __init init_v9fs(void)
{
static int __init init_v9fs(void)
{
+ int ret;
+
v9fs_error_init();
printk(KERN_INFO "Installing v9fs 9P2000 file system support\n");
v9fs_error_init();
printk(KERN_INFO "Installing v9fs 9P2000 file system support\n");
- return register_filesystem(&v9fs_fs_type);
+ ret = v9fs_mux_global_init();
+ if (!ret)
+ ret = register_filesystem(&v9fs_fs_type);
+
+ return ret;
}
/**
}
/**
@@
-447,6
+474,7
@@
static int __init init_v9fs(void)
static void __exit exit_v9fs(void)
{
static void __exit exit_v9fs(void)
{
+ v9fs_mux_global_exit();
unregister_filesystem(&v9fs_fs_type);
}
unregister_filesystem(&v9fs_fs_type);
}