diff options
Diffstat (limited to 'fs/lockd')
-rw-r--r-- | fs/lockd/host.c | 19 | ||||
-rw-r--r-- | fs/lockd/svc.c | 17 | ||||
-rw-r--r-- | fs/lockd/svcsubs.c | 17 |
3 files changed, 28 insertions, 25 deletions
diff --git a/fs/lockd/host.c b/fs/lockd/host.c index 112ebf8b8dfe..729ac427d359 100644 --- a/fs/lockd/host.c +++ b/fs/lockd/host.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/sunrpc/svc.h> | 16 | #include <linux/sunrpc/svc.h> |
17 | #include <linux/lockd/lockd.h> | 17 | #include <linux/lockd/lockd.h> |
18 | #include <linux/lockd/sm_inter.h> | 18 | #include <linux/lockd/sm_inter.h> |
19 | #include <linux/mutex.h> | ||
19 | 20 | ||
20 | 21 | ||
21 | #define NLMDBG_FACILITY NLMDBG_HOSTCACHE | 22 | #define NLMDBG_FACILITY NLMDBG_HOSTCACHE |
@@ -30,7 +31,7 @@ | |||
30 | static struct nlm_host * nlm_hosts[NLM_HOST_NRHASH]; | 31 | static struct nlm_host * nlm_hosts[NLM_HOST_NRHASH]; |
31 | static unsigned long next_gc; | 32 | static unsigned long next_gc; |
32 | static int nrhosts; | 33 | static int nrhosts; |
33 | static DECLARE_MUTEX(nlm_host_sema); | 34 | static DEFINE_MUTEX(nlm_host_mutex); |
34 | 35 | ||
35 | 36 | ||
36 | static void nlm_gc_hosts(void); | 37 | static void nlm_gc_hosts(void); |
@@ -71,7 +72,7 @@ nlm_lookup_host(int server, struct sockaddr_in *sin, | |||
71 | hash = NLM_ADDRHASH(sin->sin_addr.s_addr); | 72 | hash = NLM_ADDRHASH(sin->sin_addr.s_addr); |
72 | 73 | ||
73 | /* Lock hash table */ | 74 | /* Lock hash table */ |
74 | down(&nlm_host_sema); | 75 | mutex_lock(&nlm_host_mutex); |
75 | 76 | ||
76 | if (time_after_eq(jiffies, next_gc)) | 77 | if (time_after_eq(jiffies, next_gc)) |
77 | nlm_gc_hosts(); | 78 | nlm_gc_hosts(); |
@@ -91,7 +92,7 @@ nlm_lookup_host(int server, struct sockaddr_in *sin, | |||
91 | nlm_hosts[hash] = host; | 92 | nlm_hosts[hash] = host; |
92 | } | 93 | } |
93 | nlm_get_host(host); | 94 | nlm_get_host(host); |
94 | up(&nlm_host_sema); | 95 | mutex_unlock(&nlm_host_mutex); |
95 | return host; | 96 | return host; |
96 | } | 97 | } |
97 | } | 98 | } |
@@ -130,7 +131,7 @@ nlm_lookup_host(int server, struct sockaddr_in *sin, | |||
130 | next_gc = 0; | 131 | next_gc = 0; |
131 | 132 | ||
132 | nohost: | 133 | nohost: |
133 | up(&nlm_host_sema); | 134 | mutex_unlock(&nlm_host_mutex); |
134 | return host; | 135 | return host; |
135 | } | 136 | } |
136 | 137 | ||
@@ -141,19 +142,19 @@ nlm_find_client(void) | |||
141 | * and return it | 142 | * and return it |
142 | */ | 143 | */ |
143 | int hash; | 144 | int hash; |
144 | down(&nlm_host_sema); | 145 | mutex_lock(&nlm_host_mutex); |
145 | for (hash = 0 ; hash < NLM_HOST_NRHASH; hash++) { | 146 | for (hash = 0 ; hash < NLM_HOST_NRHASH; hash++) { |
146 | struct nlm_host *host, **hp; | 147 | struct nlm_host *host, **hp; |
147 | for (hp = &nlm_hosts[hash]; (host = *hp) != 0; hp = &host->h_next) { | 148 | for (hp = &nlm_hosts[hash]; (host = *hp) != 0; hp = &host->h_next) { |
148 | if (host->h_server && | 149 | if (host->h_server && |
149 | host->h_killed == 0) { | 150 | host->h_killed == 0) { |
150 | nlm_get_host(host); | 151 | nlm_get_host(host); |
151 | up(&nlm_host_sema); | 152 | mutex_unlock(&nlm_host_mutex); |
152 | return host; | 153 | return host; |
153 | } | 154 | } |
154 | } | 155 | } |
155 | } | 156 | } |
156 | up(&nlm_host_sema); | 157 | mutex_unlock(&nlm_host_mutex); |
157 | return NULL; | 158 | return NULL; |
158 | } | 159 | } |
159 | 160 | ||
@@ -265,7 +266,7 @@ nlm_shutdown_hosts(void) | |||
265 | int i; | 266 | int i; |
266 | 267 | ||
267 | dprintk("lockd: shutting down host module\n"); | 268 | dprintk("lockd: shutting down host module\n"); |
268 | down(&nlm_host_sema); | 269 | mutex_lock(&nlm_host_mutex); |
269 | 270 | ||
270 | /* First, make all hosts eligible for gc */ | 271 | /* First, make all hosts eligible for gc */ |
271 | dprintk("lockd: nuking all hosts...\n"); | 272 | dprintk("lockd: nuking all hosts...\n"); |
@@ -276,7 +277,7 @@ nlm_shutdown_hosts(void) | |||
276 | 277 | ||
277 | /* Then, perform a garbage collection pass */ | 278 | /* Then, perform a garbage collection pass */ |
278 | nlm_gc_hosts(); | 279 | nlm_gc_hosts(); |
279 | up(&nlm_host_sema); | 280 | mutex_unlock(&nlm_host_mutex); |
280 | 281 | ||
281 | /* complain if any hosts are left */ | 282 | /* complain if any hosts are left */ |
282 | if (nrhosts) { | 283 | if (nrhosts) { |
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index 5e85bde6c123..fd56c8872f34 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/smp.h> | 26 | #include <linux/smp.h> |
27 | #include <linux/smp_lock.h> | 27 | #include <linux/smp_lock.h> |
28 | #include <linux/mutex.h> | ||
28 | 29 | ||
29 | #include <linux/sunrpc/types.h> | 30 | #include <linux/sunrpc/types.h> |
30 | #include <linux/sunrpc/stats.h> | 31 | #include <linux/sunrpc/stats.h> |
@@ -43,13 +44,13 @@ static struct svc_program nlmsvc_program; | |||
43 | struct nlmsvc_binding * nlmsvc_ops; | 44 | struct nlmsvc_binding * nlmsvc_ops; |
44 | EXPORT_SYMBOL(nlmsvc_ops); | 45 | EXPORT_SYMBOL(nlmsvc_ops); |
45 | 46 | ||
46 | static DECLARE_MUTEX(nlmsvc_sema); | 47 | static DEFINE_MUTEX(nlmsvc_mutex); |
47 | static unsigned int nlmsvc_users; | 48 | static unsigned int nlmsvc_users; |
48 | static pid_t nlmsvc_pid; | 49 | static pid_t nlmsvc_pid; |
49 | int nlmsvc_grace_period; | 50 | int nlmsvc_grace_period; |
50 | unsigned long nlmsvc_timeout; | 51 | unsigned long nlmsvc_timeout; |
51 | 52 | ||
52 | static DECLARE_MUTEX_LOCKED(lockd_start); | 53 | static DECLARE_COMPLETION(lockd_start_done); |
53 | static DECLARE_WAIT_QUEUE_HEAD(lockd_exit); | 54 | static DECLARE_WAIT_QUEUE_HEAD(lockd_exit); |
54 | 55 | ||
55 | /* | 56 | /* |
@@ -112,7 +113,7 @@ lockd(struct svc_rqst *rqstp) | |||
112 | * Let our maker know we're running. | 113 | * Let our maker know we're running. |
113 | */ | 114 | */ |
114 | nlmsvc_pid = current->pid; | 115 | nlmsvc_pid = current->pid; |
115 | up(&lockd_start); | 116 | complete(&lockd_start_done); |
116 | 117 | ||
117 | daemonize("lockd"); | 118 | daemonize("lockd"); |
118 | 119 | ||
@@ -215,7 +216,7 @@ lockd_up(void) | |||
215 | struct svc_serv * serv; | 216 | struct svc_serv * serv; |
216 | int error = 0; | 217 | int error = 0; |
217 | 218 | ||
218 | down(&nlmsvc_sema); | 219 | mutex_lock(&nlmsvc_mutex); |
219 | /* | 220 | /* |
220 | * Unconditionally increment the user count ... this is | 221 | * Unconditionally increment the user count ... this is |
221 | * the number of clients who _want_ a lockd process. | 222 | * the number of clients who _want_ a lockd process. |
@@ -263,7 +264,7 @@ lockd_up(void) | |||
263 | "lockd_up: create thread failed, error=%d\n", error); | 264 | "lockd_up: create thread failed, error=%d\n", error); |
264 | goto destroy_and_out; | 265 | goto destroy_and_out; |
265 | } | 266 | } |
266 | down(&lockd_start); | 267 | wait_for_completion(&lockd_start_done); |
267 | 268 | ||
268 | /* | 269 | /* |
269 | * Note: svc_serv structures have an initial use count of 1, | 270 | * Note: svc_serv structures have an initial use count of 1, |
@@ -272,7 +273,7 @@ lockd_up(void) | |||
272 | destroy_and_out: | 273 | destroy_and_out: |
273 | svc_destroy(serv); | 274 | svc_destroy(serv); |
274 | out: | 275 | out: |
275 | up(&nlmsvc_sema); | 276 | mutex_unlock(&nlmsvc_mutex); |
276 | return error; | 277 | return error; |
277 | } | 278 | } |
278 | EXPORT_SYMBOL(lockd_up); | 279 | EXPORT_SYMBOL(lockd_up); |
@@ -285,7 +286,7 @@ lockd_down(void) | |||
285 | { | 286 | { |
286 | static int warned; | 287 | static int warned; |
287 | 288 | ||
288 | down(&nlmsvc_sema); | 289 | mutex_lock(&nlmsvc_mutex); |
289 | if (nlmsvc_users) { | 290 | if (nlmsvc_users) { |
290 | if (--nlmsvc_users) | 291 | if (--nlmsvc_users) |
291 | goto out; | 292 | goto out; |
@@ -315,7 +316,7 @@ lockd_down(void) | |||
315 | recalc_sigpending(); | 316 | recalc_sigpending(); |
316 | spin_unlock_irq(¤t->sighand->siglock); | 317 | spin_unlock_irq(¤t->sighand->siglock); |
317 | out: | 318 | out: |
318 | up(&nlmsvc_sema); | 319 | mutex_unlock(&nlmsvc_mutex); |
319 | } | 320 | } |
320 | EXPORT_SYMBOL(lockd_down); | 321 | EXPORT_SYMBOL(lockd_down); |
321 | 322 | ||
diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c index c7a6e3ae44d6..a570e5c8a930 100644 --- a/fs/lockd/svcsubs.c +++ b/fs/lockd/svcsubs.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/string.h> | 11 | #include <linux/string.h> |
12 | #include <linux/time.h> | 12 | #include <linux/time.h> |
13 | #include <linux/in.h> | 13 | #include <linux/in.h> |
14 | #include <linux/mutex.h> | ||
14 | #include <linux/sunrpc/svc.h> | 15 | #include <linux/sunrpc/svc.h> |
15 | #include <linux/sunrpc/clnt.h> | 16 | #include <linux/sunrpc/clnt.h> |
16 | #include <linux/nfsd/nfsfh.h> | 17 | #include <linux/nfsd/nfsfh.h> |
@@ -28,7 +29,7 @@ | |||
28 | #define FILE_HASH_BITS 5 | 29 | #define FILE_HASH_BITS 5 |
29 | #define FILE_NRHASH (1<<FILE_HASH_BITS) | 30 | #define FILE_NRHASH (1<<FILE_HASH_BITS) |
30 | static struct nlm_file * nlm_files[FILE_NRHASH]; | 31 | static struct nlm_file * nlm_files[FILE_NRHASH]; |
31 | static DECLARE_MUTEX(nlm_file_sema); | 32 | static DEFINE_MUTEX(nlm_file_mutex); |
32 | 33 | ||
33 | #ifdef NFSD_DEBUG | 34 | #ifdef NFSD_DEBUG |
34 | static inline void nlm_debug_print_fh(char *msg, struct nfs_fh *f) | 35 | static inline void nlm_debug_print_fh(char *msg, struct nfs_fh *f) |
@@ -91,7 +92,7 @@ nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result, | |||
91 | hash = file_hash(f); | 92 | hash = file_hash(f); |
92 | 93 | ||
93 | /* Lock file table */ | 94 | /* Lock file table */ |
94 | down(&nlm_file_sema); | 95 | mutex_lock(&nlm_file_mutex); |
95 | 96 | ||
96 | for (file = nlm_files[hash]; file; file = file->f_next) | 97 | for (file = nlm_files[hash]; file; file = file->f_next) |
97 | if (!nfs_compare_fh(&file->f_handle, f)) | 98 | if (!nfs_compare_fh(&file->f_handle, f)) |
@@ -130,7 +131,7 @@ found: | |||
130 | nfserr = 0; | 131 | nfserr = 0; |
131 | 132 | ||
132 | out_unlock: | 133 | out_unlock: |
133 | up(&nlm_file_sema); | 134 | mutex_unlock(&nlm_file_mutex); |
134 | return nfserr; | 135 | return nfserr; |
135 | 136 | ||
136 | out_free: | 137 | out_free: |
@@ -239,14 +240,14 @@ nlm_traverse_files(struct nlm_host *host, int action) | |||
239 | struct nlm_file *file, **fp; | 240 | struct nlm_file *file, **fp; |
240 | int i; | 241 | int i; |
241 | 242 | ||
242 | down(&nlm_file_sema); | 243 | mutex_lock(&nlm_file_mutex); |
243 | for (i = 0; i < FILE_NRHASH; i++) { | 244 | for (i = 0; i < FILE_NRHASH; i++) { |
244 | fp = nlm_files + i; | 245 | fp = nlm_files + i; |
245 | while ((file = *fp) != NULL) { | 246 | while ((file = *fp) != NULL) { |
246 | /* Traverse locks, blocks and shares of this file | 247 | /* Traverse locks, blocks and shares of this file |
247 | * and update file->f_locks count */ | 248 | * and update file->f_locks count */ |
248 | if (nlm_inspect_file(host, file, action)) { | 249 | if (nlm_inspect_file(host, file, action)) { |
249 | up(&nlm_file_sema); | 250 | mutex_unlock(&nlm_file_mutex); |
250 | return 1; | 251 | return 1; |
251 | } | 252 | } |
252 | 253 | ||
@@ -261,7 +262,7 @@ nlm_traverse_files(struct nlm_host *host, int action) | |||
261 | } | 262 | } |
262 | } | 263 | } |
263 | } | 264 | } |
264 | up(&nlm_file_sema); | 265 | mutex_unlock(&nlm_file_mutex); |
265 | return 0; | 266 | return 0; |
266 | } | 267 | } |
267 | 268 | ||
@@ -281,7 +282,7 @@ nlm_release_file(struct nlm_file *file) | |||
281 | file, file->f_count); | 282 | file, file->f_count); |
282 | 283 | ||
283 | /* Lock file table */ | 284 | /* Lock file table */ |
284 | down(&nlm_file_sema); | 285 | mutex_lock(&nlm_file_mutex); |
285 | 286 | ||
286 | /* If there are no more locks etc, delete the file */ | 287 | /* If there are no more locks etc, delete the file */ |
287 | if(--file->f_count == 0) { | 288 | if(--file->f_count == 0) { |
@@ -289,7 +290,7 @@ nlm_release_file(struct nlm_file *file) | |||
289 | nlm_delete_file(file); | 290 | nlm_delete_file(file); |
290 | } | 291 | } |
291 | 292 | ||
292 | up(&nlm_file_sema); | 293 | mutex_unlock(&nlm_file_mutex); |
293 | } | 294 | } |
294 | 295 | ||
295 | /* | 296 | /* |