diff options
author | Tejun Heo <tj@kernel.org> | 2008-09-24 17:22:23 -0400 |
---|---|---|
committer | Eric Van Hensbergen <ericvh@ericvh-desktop.austin.ibm.com> | 2008-09-24 17:22:23 -0400 |
commit | 72029fe85d8d060b3f966f2dbc36b3c75b5a6532 (patch) | |
tree | ef8948240b0aff2a366136a8303afc70e6c84da8 /net/9p/client.c | |
parent | 72d31053f62c4bc464c2783974926969614a8649 (diff) |
9p: implement proper trans module refcounting and unregistration
9p trans modules aren't refcounted nor were they unregistered
properly. Fix it.
* Add 9p_trans_module->owner and reference the module on each trans
instance creation and put it on destruction.
* Protect v9fs_trans_list with a spinlock. This isn't strictly
necessary as the list is manipulated only during module loading /
unloading but it's a good idea to make the API safe.
* Unregister trans modules when the corresponding module is being
unloaded.
* While at it, kill unnecessary EXPORT_SYMBOL on p9_trans_fd_init().
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'net/9p/client.c')
-rw-r--r-- | net/9p/client.c | 10 |
1 files changed, 8 insertions, 2 deletions
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 | ||