diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-09-24 18:33:50 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-09-24 18:33:50 -0400 |
commit | 7a528159b93bc52c14aedff55d53e741227fc846 (patch) | |
tree | 742e5b26440ef2c253d543a2b0a4bed8d3496f1e | |
parent | fb478da5ba69ecf40729ae8ab37ca406b1e5be48 (diff) | |
parent | 16ec4700127d479143c77fd9128dfa17ab572963 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ericvh/v9fs
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ericvh/v9fs:
9p: fix put_data error handling
9p: use an IS_ERR test rather than a NULL test
9p: introduce missing kfree
9p-trans_fd: fix and clean up module init/exit paths
9p-trans_fd: don't do fs segment mangling in p9_fd_poll()
9p-trans_fd: clean up p9_conn_create()
9p-trans_fd: fix trans_fd::p9_conn_destroy()
9p: implement proper trans module refcounting and unregistration
-rw-r--r-- | fs/9p/vfs_inode.c | 3 | ||||
-rw-r--r-- | include/net/9p/9p.h | 1 | ||||
-rw-r--r-- | include/net/9p/transport.h | 9 | ||||
-rw-r--r-- | net/9p/client.c | 10 | ||||
-rw-r--r-- | net/9p/conv.c | 6 | ||||
-rw-r--r-- | net/9p/mod.c | 92 | ||||
-rw-r--r-- | net/9p/trans_fd.c | 104 | ||||
-rw-r--r-- | net/9p/trans_virtio.c | 2 |
8 files changed, 127 insertions, 100 deletions
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index c95295c65045..e83aa5ebe861 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c | |||
@@ -626,8 +626,7 @@ static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, | |||
626 | return NULL; | 626 | return NULL; |
627 | 627 | ||
628 | error: | 628 | error: |
629 | if (fid) | 629 | p9_client_clunk(fid); |
630 | p9_client_clunk(fid); | ||
631 | 630 | ||
632 | return ERR_PTR(result); | 631 | return ERR_PTR(result); |
633 | } | 632 | } |
diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h index b3d3e27c6299..c3626c0ba9d3 100644 --- a/include/net/9p/9p.h +++ b/include/net/9p/9p.h | |||
@@ -596,4 +596,5 @@ int p9_idpool_check(int id, struct p9_idpool *p); | |||
596 | int p9_error_init(void); | 596 | int p9_error_init(void); |
597 | int p9_errstr2errno(char *, int); | 597 | int p9_errstr2errno(char *, int); |
598 | int p9_trans_fd_init(void); | 598 | int p9_trans_fd_init(void); |
599 | void p9_trans_fd_exit(void); | ||
599 | #endif /* NET_9P_H */ | 600 | #endif /* NET_9P_H */ |
diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h index 0db3a4038dc0..3ca737120a90 100644 --- a/include/net/9p/transport.h +++ b/include/net/9p/transport.h | |||
@@ -26,6 +26,8 @@ | |||
26 | #ifndef NET_9P_TRANSPORT_H | 26 | #ifndef NET_9P_TRANSPORT_H |
27 | #define NET_9P_TRANSPORT_H | 27 | #define NET_9P_TRANSPORT_H |
28 | 28 | ||
29 | #include <linux/module.h> | ||
30 | |||
29 | /** | 31 | /** |
30 | * enum p9_trans_status - different states of underlying transports | 32 | * enum p9_trans_status - different states of underlying transports |
31 | * @Connected: transport is connected and healthy | 33 | * @Connected: transport is connected and healthy |
@@ -91,9 +93,12 @@ struct p9_trans_module { | |||
91 | int maxsize; /* max message size of transport */ | 93 | int maxsize; /* max message size of transport */ |
92 | int def; /* this transport should be default */ | 94 | int def; /* this transport should be default */ |
93 | struct p9_trans * (*create)(const char *, char *, int, unsigned char); | 95 | struct p9_trans * (*create)(const char *, char *, int, unsigned char); |
96 | struct module *owner; | ||
94 | }; | 97 | }; |
95 | 98 | ||
96 | void v9fs_register_trans(struct p9_trans_module *m); | 99 | void v9fs_register_trans(struct p9_trans_module *m); |
97 | struct p9_trans_module *v9fs_match_trans(const substring_t *name); | 100 | void v9fs_unregister_trans(struct p9_trans_module *m); |
98 | struct p9_trans_module *v9fs_default_trans(void); | 101 | struct p9_trans_module *v9fs_get_trans_by_name(const substring_t *name); |
102 | struct p9_trans_module *v9fs_get_default_trans(void); | ||
103 | void v9fs_put_trans(struct p9_trans_module *m); | ||
99 | #endif /* NET_9P_TRANSPORT_H */ | 104 | #endif /* NET_9P_TRANSPORT_H */ |
diff --git a/net/9p/client.c b/net/9p/client.c index 2ffe40cf2f01..10e320307ec0 100644 --- a/net/9p/client.c +++ b/net/9p/client.c | |||
@@ -75,7 +75,6 @@ static int parse_opts(char *opts, struct p9_client *clnt) | |||
75 | int option; | 75 | int option; |
76 | int ret = 0; | 76 | int ret = 0; |
77 | 77 | ||
78 | clnt->trans_mod = v9fs_default_trans(); | ||
79 | clnt->dotu = 1; | 78 | clnt->dotu = 1; |
80 | clnt->msize = 8192; | 79 | clnt->msize = 8192; |
81 | 80 | ||
@@ -108,7 +107,7 @@ static int parse_opts(char *opts, struct p9_client *clnt) | |||
108 | clnt->msize = option; | 107 | clnt->msize = option; |
109 | break; | 108 | break; |
110 | case Opt_trans: | 109 | case Opt_trans: |
111 | clnt->trans_mod = v9fs_match_trans(&args[0]); | 110 | clnt->trans_mod = v9fs_get_trans_by_name(&args[0]); |
112 | break; | 111 | break; |
113 | case Opt_legacy: | 112 | case Opt_legacy: |
114 | clnt->dotu = 0; | 113 | clnt->dotu = 0; |
@@ -117,6 +116,10 @@ static int parse_opts(char *opts, struct p9_client *clnt) | |||
117 | continue; | 116 | continue; |
118 | } | 117 | } |
119 | } | 118 | } |
119 | |||
120 | if (!clnt->trans_mod) | ||
121 | clnt->trans_mod = v9fs_get_default_trans(); | ||
122 | |||
120 | kfree(options); | 123 | kfree(options); |
121 | return ret; | 124 | return ret; |
122 | } | 125 | } |
@@ -150,6 +153,7 @@ struct p9_client *p9_client_create(const char *dev_name, char *options) | |||
150 | if (!clnt) | 153 | if (!clnt) |
151 | return ERR_PTR(-ENOMEM); | 154 | return ERR_PTR(-ENOMEM); |
152 | 155 | ||
156 | clnt->trans_mod = NULL; | ||
153 | clnt->trans = NULL; | 157 | clnt->trans = NULL; |
154 | spin_lock_init(&clnt->lock); | 158 | spin_lock_init(&clnt->lock); |
155 | INIT_LIST_HEAD(&clnt->fidlist); | 159 | INIT_LIST_HEAD(&clnt->fidlist); |
@@ -235,6 +239,8 @@ void p9_client_destroy(struct p9_client *clnt) | |||
235 | clnt->trans = NULL; | 239 | clnt->trans = NULL; |
236 | } | 240 | } |
237 | 241 | ||
242 | v9fs_put_trans(clnt->trans_mod); | ||
243 | |||
238 | list_for_each_entry_safe(fid, fidptr, &clnt->fidlist, flist) | 244 | list_for_each_entry_safe(fid, fidptr, &clnt->fidlist, flist) |
239 | p9_fid_destroy(fid); | 245 | p9_fid_destroy(fid); |
240 | 246 | ||
diff --git a/net/9p/conv.c b/net/9p/conv.c index 44547201f5bc..5ad3a3bd73b2 100644 --- a/net/9p/conv.c +++ b/net/9p/conv.c | |||
@@ -451,8 +451,10 @@ p9_put_data(struct cbuf *bufp, const char *data, int count, | |||
451 | unsigned char **pdata) | 451 | unsigned char **pdata) |
452 | { | 452 | { |
453 | *pdata = buf_alloc(bufp, count); | 453 | *pdata = buf_alloc(bufp, count); |
454 | if (*pdata == NULL) | ||
455 | return -ENOMEM; | ||
454 | memmove(*pdata, data, count); | 456 | memmove(*pdata, data, count); |
455 | return count; | 457 | return 0; |
456 | } | 458 | } |
457 | 459 | ||
458 | static int | 460 | static int |
@@ -460,6 +462,8 @@ p9_put_user_data(struct cbuf *bufp, const char __user *data, int count, | |||
460 | unsigned char **pdata) | 462 | unsigned char **pdata) |
461 | { | 463 | { |
462 | *pdata = buf_alloc(bufp, count); | 464 | *pdata = buf_alloc(bufp, count); |
465 | if (*pdata == NULL) | ||
466 | return -ENOMEM; | ||
463 | return copy_from_user(*pdata, data, count); | 467 | return copy_from_user(*pdata, data, count); |
464 | } | 468 | } |
465 | 469 | ||
diff --git a/net/9p/mod.c b/net/9p/mod.c index bdee1fb7cc62..1084feb24cb0 100644 --- a/net/9p/mod.c +++ b/net/9p/mod.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/parser.h> | 31 | #include <linux/parser.h> |
32 | #include <net/9p/transport.h> | 32 | #include <net/9p/transport.h> |
33 | #include <linux/list.h> | 33 | #include <linux/list.h> |
34 | #include <linux/spinlock.h> | ||
34 | 35 | ||
35 | #ifdef CONFIG_NET_9P_DEBUG | 36 | #ifdef CONFIG_NET_9P_DEBUG |
36 | unsigned int p9_debug_level = 0; /* feature-rific global debug level */ | 37 | unsigned int p9_debug_level = 0; /* feature-rific global debug level */ |
@@ -44,8 +45,8 @@ MODULE_PARM_DESC(debug, "9P debugging level"); | |||
44 | * | 45 | * |
45 | */ | 46 | */ |
46 | 47 | ||
48 | static DEFINE_SPINLOCK(v9fs_trans_lock); | ||
47 | static LIST_HEAD(v9fs_trans_list); | 49 | static LIST_HEAD(v9fs_trans_list); |
48 | static struct p9_trans_module *v9fs_default_transport; | ||
49 | 50 | ||
50 | /** | 51 | /** |
51 | * v9fs_register_trans - register a new transport with 9p | 52 | * v9fs_register_trans - register a new transport with 9p |
@@ -54,48 +55,87 @@ static struct p9_trans_module *v9fs_default_transport; | |||
54 | */ | 55 | */ |
55 | void v9fs_register_trans(struct p9_trans_module *m) | 56 | void v9fs_register_trans(struct p9_trans_module *m) |
56 | { | 57 | { |
58 | spin_lock(&v9fs_trans_lock); | ||
57 | list_add_tail(&m->list, &v9fs_trans_list); | 59 | list_add_tail(&m->list, &v9fs_trans_list); |
58 | if (m->def) | 60 | spin_unlock(&v9fs_trans_lock); |
59 | v9fs_default_transport = m; | ||
60 | } | 61 | } |
61 | EXPORT_SYMBOL(v9fs_register_trans); | 62 | EXPORT_SYMBOL(v9fs_register_trans); |
62 | 63 | ||
63 | /** | 64 | /** |
64 | * v9fs_match_trans - match transport versus registered transports | 65 | * v9fs_unregister_trans - unregister a 9p transport |
66 | * @m: the transport to remove | ||
67 | * | ||
68 | */ | ||
69 | void v9fs_unregister_trans(struct p9_trans_module *m) | ||
70 | { | ||
71 | spin_lock(&v9fs_trans_lock); | ||
72 | list_del_init(&m->list); | ||
73 | spin_unlock(&v9fs_trans_lock); | ||
74 | } | ||
75 | EXPORT_SYMBOL(v9fs_unregister_trans); | ||
76 | |||
77 | /** | ||
78 | * v9fs_get_trans_by_name - get transport with the matching name | ||
65 | * @name: string identifying transport | 79 | * @name: string identifying transport |
66 | * | 80 | * |
67 | */ | 81 | */ |
68 | struct p9_trans_module *v9fs_match_trans(const substring_t *name) | 82 | struct p9_trans_module *v9fs_get_trans_by_name(const substring_t *name) |
69 | { | 83 | { |
70 | struct list_head *p; | 84 | struct p9_trans_module *t, *found = NULL; |
71 | struct p9_trans_module *t = NULL; | 85 | |
72 | 86 | spin_lock(&v9fs_trans_lock); | |
73 | list_for_each(p, &v9fs_trans_list) { | 87 | |
74 | t = list_entry(p, struct p9_trans_module, list); | 88 | list_for_each_entry(t, &v9fs_trans_list, list) |
75 | if (strncmp(t->name, name->from, name->to-name->from) == 0) | 89 | if (strncmp(t->name, name->from, name->to-name->from) == 0 && |
76 | return t; | 90 | try_module_get(t->owner)) { |
77 | } | 91 | found = t; |
78 | return NULL; | 92 | break; |
93 | } | ||
94 | |||
95 | spin_unlock(&v9fs_trans_lock); | ||
96 | return found; | ||
79 | } | 97 | } |
80 | EXPORT_SYMBOL(v9fs_match_trans); | 98 | EXPORT_SYMBOL(v9fs_get_trans_by_name); |
81 | 99 | ||
82 | /** | 100 | /** |
83 | * v9fs_default_trans - returns pointer to default transport | 101 | * v9fs_get_default_trans - get the default transport |
84 | * | 102 | * |
85 | */ | 103 | */ |
86 | 104 | ||
87 | struct p9_trans_module *v9fs_default_trans(void) | 105 | struct p9_trans_module *v9fs_get_default_trans(void) |
88 | { | 106 | { |
89 | if (v9fs_default_transport) | 107 | struct p9_trans_module *t, *found = NULL; |
90 | return v9fs_default_transport; | 108 | |
91 | else if (!list_empty(&v9fs_trans_list)) | 109 | spin_lock(&v9fs_trans_lock); |
92 | return list_first_entry(&v9fs_trans_list, | 110 | |
93 | struct p9_trans_module, list); | 111 | list_for_each_entry(t, &v9fs_trans_list, list) |
94 | else | 112 | if (t->def && try_module_get(t->owner)) { |
95 | return NULL; | 113 | found = t; |
114 | break; | ||
115 | } | ||
116 | |||
117 | if (!found) | ||
118 | list_for_each_entry(t, &v9fs_trans_list, list) | ||
119 | if (try_module_get(t->owner)) { | ||
120 | found = t; | ||
121 | break; | ||
122 | } | ||
123 | |||
124 | spin_unlock(&v9fs_trans_lock); | ||
125 | return found; | ||
96 | } | 126 | } |
97 | EXPORT_SYMBOL(v9fs_default_trans); | 127 | EXPORT_SYMBOL(v9fs_get_default_trans); |
98 | 128 | ||
129 | /** | ||
130 | * v9fs_put_trans - put trans | ||
131 | * @m: transport to put | ||
132 | * | ||
133 | */ | ||
134 | void v9fs_put_trans(struct p9_trans_module *m) | ||
135 | { | ||
136 | if (m) | ||
137 | module_put(m->owner); | ||
138 | } | ||
99 | 139 | ||
100 | /** | 140 | /** |
101 | * v9fs_init - Initialize module | 141 | * v9fs_init - Initialize module |
@@ -120,6 +160,8 @@ static int __init init_p9(void) | |||
120 | static void __exit exit_p9(void) | 160 | static void __exit exit_p9(void) |
121 | { | 161 | { |
122 | printk(KERN_INFO "Unloading 9P2000 support\n"); | 162 | printk(KERN_INFO "Unloading 9P2000 support\n"); |
163 | |||
164 | p9_trans_fd_exit(); | ||
123 | } | 165 | } |
124 | 166 | ||
125 | module_init(init_p9) | 167 | module_init(init_p9) |
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c index cdf137af7adc..d652baf5ff91 100644 --- a/net/9p/trans_fd.c +++ b/net/9p/trans_fd.c | |||
@@ -151,7 +151,6 @@ struct p9_mux_poll_task { | |||
151 | * @trans: reference to transport instance for this connection | 151 | * @trans: reference to transport instance for this connection |
152 | * @tagpool: id accounting for transactions | 152 | * @tagpool: id accounting for transactions |
153 | * @err: error state | 153 | * @err: error state |
154 | * @equeue: event wait_q (?) | ||
155 | * @req_list: accounting for requests which have been sent | 154 | * @req_list: accounting for requests which have been sent |
156 | * @unsent_req_list: accounting for requests that haven't been sent | 155 | * @unsent_req_list: accounting for requests that haven't been sent |
157 | * @rcall: current response &p9_fcall structure | 156 | * @rcall: current response &p9_fcall structure |
@@ -178,7 +177,6 @@ struct p9_conn { | |||
178 | struct p9_trans *trans; | 177 | struct p9_trans *trans; |
179 | struct p9_idpool *tagpool; | 178 | struct p9_idpool *tagpool; |
180 | int err; | 179 | int err; |
181 | wait_queue_head_t equeue; | ||
182 | struct list_head req_list; | 180 | struct list_head req_list; |
183 | struct list_head unsent_req_list; | 181 | struct list_head unsent_req_list; |
184 | struct p9_fcall *rcall; | 182 | struct p9_fcall *rcall; |
@@ -240,22 +238,6 @@ static int p9_conn_rpcnb(struct p9_conn *m, struct p9_fcall *tc, | |||
240 | 238 | ||
241 | static void p9_conn_cancel(struct p9_conn *m, int err); | 239 | static void p9_conn_cancel(struct p9_conn *m, int err); |
242 | 240 | ||
243 | static int p9_mux_global_init(void) | ||
244 | { | ||
245 | int i; | ||
246 | |||
247 | for (i = 0; i < ARRAY_SIZE(p9_mux_poll_tasks); i++) | ||
248 | p9_mux_poll_tasks[i].task = NULL; | ||
249 | |||
250 | p9_mux_wq = create_workqueue("v9fs"); | ||
251 | if (!p9_mux_wq) { | ||
252 | printk(KERN_WARNING "v9fs: mux: creating workqueue failed\n"); | ||
253 | return -ENOMEM; | ||
254 | } | ||
255 | |||
256 | return 0; | ||
257 | } | ||
258 | |||
259 | static u16 p9_mux_get_tag(struct p9_conn *m) | 241 | static u16 p9_mux_get_tag(struct p9_conn *m) |
260 | { | 242 | { |
261 | int tag; | 243 | int tag; |
@@ -409,11 +391,11 @@ static void p9_mux_poll_stop(struct p9_conn *m) | |||
409 | static struct p9_conn *p9_conn_create(struct p9_trans *trans) | 391 | static struct p9_conn *p9_conn_create(struct p9_trans *trans) |
410 | { | 392 | { |
411 | int i, n; | 393 | int i, n; |
412 | struct p9_conn *m, *mtmp; | 394 | struct p9_conn *m; |
413 | 395 | ||
414 | P9_DPRINTK(P9_DEBUG_MUX, "transport %p msize %d\n", trans, | 396 | P9_DPRINTK(P9_DEBUG_MUX, "transport %p msize %d\n", trans, |
415 | trans->msize); | 397 | trans->msize); |
416 | m = kmalloc(sizeof(struct p9_conn), GFP_KERNEL); | 398 | m = kzalloc(sizeof(struct p9_conn), GFP_KERNEL); |
417 | if (!m) | 399 | if (!m) |
418 | return ERR_PTR(-ENOMEM); | 400 | return ERR_PTR(-ENOMEM); |
419 | 401 | ||
@@ -424,25 +406,14 @@ static struct p9_conn *p9_conn_create(struct p9_trans *trans) | |||
424 | m->trans = trans; | 406 | m->trans = trans; |
425 | m->tagpool = p9_idpool_create(); | 407 | m->tagpool = p9_idpool_create(); |
426 | if (IS_ERR(m->tagpool)) { | 408 | if (IS_ERR(m->tagpool)) { |
427 | mtmp = ERR_PTR(-ENOMEM); | ||
428 | kfree(m); | 409 | kfree(m); |
429 | return mtmp; | 410 | return ERR_PTR(-ENOMEM); |
430 | } | 411 | } |
431 | 412 | ||
432 | m->err = 0; | ||
433 | init_waitqueue_head(&m->equeue); | ||
434 | INIT_LIST_HEAD(&m->req_list); | 413 | INIT_LIST_HEAD(&m->req_list); |
435 | INIT_LIST_HEAD(&m->unsent_req_list); | 414 | INIT_LIST_HEAD(&m->unsent_req_list); |
436 | m->rcall = NULL; | ||
437 | m->rpos = 0; | ||
438 | m->rbuf = NULL; | ||
439 | m->wpos = m->wsize = 0; | ||
440 | m->wbuf = NULL; | ||
441 | INIT_WORK(&m->rq, p9_read_work); | 415 | INIT_WORK(&m->rq, p9_read_work); |
442 | INIT_WORK(&m->wq, p9_write_work); | 416 | INIT_WORK(&m->wq, p9_write_work); |
443 | m->wsched = 0; | ||
444 | memset(&m->poll_waddr, 0, sizeof(m->poll_waddr)); | ||
445 | m->poll_task = NULL; | ||
446 | n = p9_mux_poll_start(m); | 417 | n = p9_mux_poll_start(m); |
447 | if (n) { | 418 | if (n) { |
448 | kfree(m); | 419 | kfree(m); |
@@ -463,10 +434,8 @@ static struct p9_conn *p9_conn_create(struct p9_trans *trans) | |||
463 | for (i = 0; i < ARRAY_SIZE(m->poll_waddr); i++) { | 434 | for (i = 0; i < ARRAY_SIZE(m->poll_waddr); i++) { |
464 | if (IS_ERR(m->poll_waddr[i])) { | 435 | if (IS_ERR(m->poll_waddr[i])) { |
465 | p9_mux_poll_stop(m); | 436 | p9_mux_poll_stop(m); |
466 | mtmp = (void *)m->poll_waddr; /* the error code */ | ||
467 | kfree(m); | 437 | kfree(m); |
468 | m = mtmp; | 438 | return (void *)m->poll_waddr; /* the error code */ |
469 | break; | ||
470 | } | 439 | } |
471 | } | 440 | } |
472 | 441 | ||
@@ -483,18 +452,13 @@ static void p9_conn_destroy(struct p9_conn *m) | |||
483 | { | 452 | { |
484 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p prev %p next %p\n", m, | 453 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p prev %p next %p\n", m, |
485 | m->mux_list.prev, m->mux_list.next); | 454 | m->mux_list.prev, m->mux_list.next); |
486 | p9_conn_cancel(m, -ECONNRESET); | ||
487 | |||
488 | if (!list_empty(&m->req_list)) { | ||
489 | /* wait until all processes waiting on this session exit */ | ||
490 | P9_DPRINTK(P9_DEBUG_MUX, | ||
491 | "mux %p waiting for empty request queue\n", m); | ||
492 | wait_event_timeout(m->equeue, (list_empty(&m->req_list)), 5000); | ||
493 | P9_DPRINTK(P9_DEBUG_MUX, "mux %p request queue empty: %d\n", m, | ||
494 | list_empty(&m->req_list)); | ||
495 | } | ||
496 | 455 | ||
497 | p9_mux_poll_stop(m); | 456 | p9_mux_poll_stop(m); |
457 | cancel_work_sync(&m->rq); | ||
458 | cancel_work_sync(&m->wq); | ||
459 | |||
460 | p9_conn_cancel(m, -ECONNRESET); | ||
461 | |||
498 | m->trans = NULL; | 462 | m->trans = NULL; |
499 | p9_idpool_destroy(m->tagpool); | 463 | p9_idpool_destroy(m->tagpool); |
500 | kfree(m); | 464 | kfree(m); |
@@ -840,8 +804,6 @@ static void p9_read_work(struct work_struct *work) | |||
840 | (*req->cb) (req, req->cba); | 804 | (*req->cb) (req, req->cba); |
841 | else | 805 | else |
842 | kfree(req->rcall); | 806 | kfree(req->rcall); |
843 | |||
844 | wake_up(&m->equeue); | ||
845 | } | 807 | } |
846 | } else { | 808 | } else { |
847 | if (err >= 0 && rcall->id != P9_RFLUSH) | 809 | if (err >= 0 && rcall->id != P9_RFLUSH) |
@@ -908,8 +870,10 @@ static struct p9_req *p9_send_request(struct p9_conn *m, | |||
908 | else | 870 | else |
909 | n = p9_mux_get_tag(m); | 871 | n = p9_mux_get_tag(m); |
910 | 872 | ||
911 | if (n < 0) | 873 | if (n < 0) { |
874 | kfree(req); | ||
912 | return ERR_PTR(-ENOMEM); | 875 | return ERR_PTR(-ENOMEM); |
876 | } | ||
913 | 877 | ||
914 | p9_set_tag(tc, n); | 878 | p9_set_tag(tc, n); |
915 | 879 | ||
@@ -984,8 +948,6 @@ static void p9_mux_flush_cb(struct p9_req *freq, void *a) | |||
984 | (*req->cb) (req, req->cba); | 948 | (*req->cb) (req, req->cba); |
985 | else | 949 | else |
986 | kfree(req->rcall); | 950 | kfree(req->rcall); |
987 | |||
988 | wake_up(&m->equeue); | ||
989 | } | 951 | } |
990 | 952 | ||
991 | kfree(freq->tcall); | 953 | kfree(freq->tcall); |
@@ -1191,8 +1153,6 @@ void p9_conn_cancel(struct p9_conn *m, int err) | |||
1191 | else | 1153 | else |
1192 | kfree(req->rcall); | 1154 | kfree(req->rcall); |
1193 | } | 1155 | } |
1194 | |||
1195 | wake_up(&m->equeue); | ||
1196 | } | 1156 | } |
1197 | 1157 | ||
1198 | /** | 1158 | /** |
@@ -1370,7 +1330,6 @@ p9_fd_poll(struct p9_trans *trans, struct poll_table_struct *pt) | |||
1370 | { | 1330 | { |
1371 | int ret, n; | 1331 | int ret, n; |
1372 | struct p9_trans_fd *ts = NULL; | 1332 | struct p9_trans_fd *ts = NULL; |
1373 | mm_segment_t oldfs; | ||
1374 | 1333 | ||
1375 | if (trans && trans->status == Connected) | 1334 | if (trans && trans->status == Connected) |
1376 | ts = trans->priv; | 1335 | ts = trans->priv; |
@@ -1384,24 +1343,17 @@ p9_fd_poll(struct p9_trans *trans, struct poll_table_struct *pt) | |||
1384 | if (!ts->wr->f_op || !ts->wr->f_op->poll) | 1343 | if (!ts->wr->f_op || !ts->wr->f_op->poll) |
1385 | return -EIO; | 1344 | return -EIO; |
1386 | 1345 | ||
1387 | oldfs = get_fs(); | ||
1388 | set_fs(get_ds()); | ||
1389 | |||
1390 | ret = ts->rd->f_op->poll(ts->rd, pt); | 1346 | ret = ts->rd->f_op->poll(ts->rd, pt); |
1391 | if (ret < 0) | 1347 | if (ret < 0) |
1392 | goto end; | 1348 | return ret; |
1393 | 1349 | ||
1394 | if (ts->rd != ts->wr) { | 1350 | if (ts->rd != ts->wr) { |
1395 | n = ts->wr->f_op->poll(ts->wr, pt); | 1351 | n = ts->wr->f_op->poll(ts->wr, pt); |
1396 | if (n < 0) { | 1352 | if (n < 0) |
1397 | ret = n; | 1353 | return n; |
1398 | goto end; | ||
1399 | } | ||
1400 | ret = (ret & ~POLLOUT) | (n & ~POLLIN); | 1354 | ret = (ret & ~POLLOUT) | (n & ~POLLIN); |
1401 | } | 1355 | } |
1402 | 1356 | ||
1403 | end: | ||
1404 | set_fs(oldfs); | ||
1405 | return ret; | 1357 | return ret; |
1406 | } | 1358 | } |
1407 | 1359 | ||
@@ -1629,6 +1581,7 @@ static struct p9_trans_module p9_tcp_trans = { | |||
1629 | .maxsize = MAX_SOCK_BUF, | 1581 | .maxsize = MAX_SOCK_BUF, |
1630 | .def = 1, | 1582 | .def = 1, |
1631 | .create = p9_trans_create_tcp, | 1583 | .create = p9_trans_create_tcp, |
1584 | .owner = THIS_MODULE, | ||
1632 | }; | 1585 | }; |
1633 | 1586 | ||
1634 | static struct p9_trans_module p9_unix_trans = { | 1587 | static struct p9_trans_module p9_unix_trans = { |
@@ -1636,6 +1589,7 @@ static struct p9_trans_module p9_unix_trans = { | |||
1636 | .maxsize = MAX_SOCK_BUF, | 1589 | .maxsize = MAX_SOCK_BUF, |
1637 | .def = 0, | 1590 | .def = 0, |
1638 | .create = p9_trans_create_unix, | 1591 | .create = p9_trans_create_unix, |
1592 | .owner = THIS_MODULE, | ||
1639 | }; | 1593 | }; |
1640 | 1594 | ||
1641 | static struct p9_trans_module p9_fd_trans = { | 1595 | static struct p9_trans_module p9_fd_trans = { |
@@ -1643,14 +1597,20 @@ static struct p9_trans_module p9_fd_trans = { | |||
1643 | .maxsize = MAX_SOCK_BUF, | 1597 | .maxsize = MAX_SOCK_BUF, |
1644 | .def = 0, | 1598 | .def = 0, |
1645 | .create = p9_trans_create_fd, | 1599 | .create = p9_trans_create_fd, |
1600 | .owner = THIS_MODULE, | ||
1646 | }; | 1601 | }; |
1647 | 1602 | ||
1648 | int p9_trans_fd_init(void) | 1603 | int p9_trans_fd_init(void) |
1649 | { | 1604 | { |
1650 | int ret = p9_mux_global_init(); | 1605 | int i; |
1651 | if (ret) { | 1606 | |
1652 | printk(KERN_WARNING "9p: starting mux failed\n"); | 1607 | for (i = 0; i < ARRAY_SIZE(p9_mux_poll_tasks); i++) |
1653 | return ret; | 1608 | p9_mux_poll_tasks[i].task = NULL; |
1609 | |||
1610 | p9_mux_wq = create_workqueue("v9fs"); | ||
1611 | if (!p9_mux_wq) { | ||
1612 | printk(KERN_WARNING "v9fs: mux: creating workqueue failed\n"); | ||
1613 | return -ENOMEM; | ||
1654 | } | 1614 | } |
1655 | 1615 | ||
1656 | v9fs_register_trans(&p9_tcp_trans); | 1616 | v9fs_register_trans(&p9_tcp_trans); |
@@ -1659,4 +1619,12 @@ int p9_trans_fd_init(void) | |||
1659 | 1619 | ||
1660 | return 0; | 1620 | return 0; |
1661 | } | 1621 | } |
1662 | EXPORT_SYMBOL(p9_trans_fd_init); | 1622 | |
1623 | void p9_trans_fd_exit(void) | ||
1624 | { | ||
1625 | v9fs_unregister_trans(&p9_tcp_trans); | ||
1626 | v9fs_unregister_trans(&p9_unix_trans); | ||
1627 | v9fs_unregister_trans(&p9_fd_trans); | ||
1628 | |||
1629 | destroy_workqueue(p9_mux_wq); | ||
1630 | } | ||
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c index 42adc052b149..94912e077a55 100644 --- a/net/9p/trans_virtio.c +++ b/net/9p/trans_virtio.c | |||
@@ -528,6 +528,7 @@ static struct p9_trans_module p9_virtio_trans = { | |||
528 | .create = p9_virtio_create, | 528 | .create = p9_virtio_create, |
529 | .maxsize = PAGE_SIZE*16, | 529 | .maxsize = PAGE_SIZE*16, |
530 | .def = 0, | 530 | .def = 0, |
531 | .owner = THIS_MODULE, | ||
531 | }; | 532 | }; |
532 | 533 | ||
533 | /* The standard init function */ | 534 | /* The standard init function */ |
@@ -545,6 +546,7 @@ static int __init p9_virtio_init(void) | |||
545 | static void __exit p9_virtio_cleanup(void) | 546 | static void __exit p9_virtio_cleanup(void) |
546 | { | 547 | { |
547 | unregister_virtio_driver(&p9_virtio_drv); | 548 | unregister_virtio_driver(&p9_virtio_drv); |
549 | v9fs_unregister_trans(&p9_virtio_trans); | ||
548 | } | 550 | } |
549 | 551 | ||
550 | module_init(p9_virtio_init); | 552 | module_init(p9_virtio_init); |