aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/lockd/host.c11
-rw-r--r--fs/lockd/svclock.c22
-rw-r--r--fs/lockd/svcsubs.c2
-rw-r--r--include/linux/lockd/lockd.h2
4 files changed, 19 insertions, 18 deletions
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index a1423c66df04..0257a5594524 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -436,7 +436,7 @@ nlm_gc_hosts(void)
436 * Manage NSM handles 436 * Manage NSM handles
437 */ 437 */
438static LIST_HEAD(nsm_handles); 438static LIST_HEAD(nsm_handles);
439static DECLARE_MUTEX(nsm_sema); 439static DEFINE_MUTEX(nsm_mutex);
440 440
441static struct nsm_handle * 441static struct nsm_handle *
442__nsm_find(const struct sockaddr_in *sin, 442__nsm_find(const struct sockaddr_in *sin,
@@ -458,7 +458,7 @@ __nsm_find(const struct sockaddr_in *sin,
458 return NULL; 458 return NULL;
459 } 459 }
460 460
461 down(&nsm_sema); 461 mutex_lock(&nsm_mutex);
462 list_for_each(pos, &nsm_handles) { 462 list_for_each(pos, &nsm_handles) {
463 nsm = list_entry(pos, struct nsm_handle, sm_link); 463 nsm = list_entry(pos, struct nsm_handle, sm_link);
464 464
@@ -488,7 +488,8 @@ __nsm_find(const struct sockaddr_in *sin,
488 list_add(&nsm->sm_link, &nsm_handles); 488 list_add(&nsm->sm_link, &nsm_handles);
489 } 489 }
490 490
491out: up(&nsm_sema); 491out:
492 mutex_unlock(&nsm_mutex);
492 return nsm; 493 return nsm;
493} 494}
494 495
@@ -507,11 +508,11 @@ nsm_release(struct nsm_handle *nsm)
507 if (!nsm) 508 if (!nsm)
508 return; 509 return;
509 if (atomic_dec_and_test(&nsm->sm_count)) { 510 if (atomic_dec_and_test(&nsm->sm_count)) {
510 down(&nsm_sema); 511 mutex_lock(&nsm_mutex);
511 if (atomic_read(&nsm->sm_count) == 0) { 512 if (atomic_read(&nsm->sm_count) == 0) {
512 list_del(&nsm->sm_link); 513 list_del(&nsm->sm_link);
513 kfree(nsm); 514 kfree(nsm);
514 } 515 }
515 up(&nsm_sema); 516 mutex_unlock(&nsm_mutex);
516 } 517 }
517} 518}
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index 3d2b8a831be5..814c6064c9e0 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -254,9 +254,9 @@ static void nlmsvc_free_block(struct kref *kref)
254 dprintk("lockd: freeing block %p...\n", block); 254 dprintk("lockd: freeing block %p...\n", block);
255 255
256 /* Remove block from file's list of blocks */ 256 /* Remove block from file's list of blocks */
257 down(&file->f_sema); 257 mutex_lock(&file->f_mutex);
258 list_del_init(&block->b_flist); 258 list_del_init(&block->b_flist);
259 up(&file->f_sema); 259 mutex_unlock(&file->f_mutex);
260 260
261 nlmsvc_freegrantargs(block->b_call); 261 nlmsvc_freegrantargs(block->b_call);
262 nlm_release_call(block->b_call); 262 nlm_release_call(block->b_call);
@@ -281,7 +281,7 @@ void nlmsvc_traverse_blocks(struct nlm_host *host,
281 struct nlm_block *block, *next; 281 struct nlm_block *block, *next;
282 282
283restart: 283restart:
284 down(&file->f_sema); 284 mutex_lock(&file->f_mutex);
285 list_for_each_entry_safe(block, next, &file->f_blocks, b_flist) { 285 list_for_each_entry_safe(block, next, &file->f_blocks, b_flist) {
286 if (!match(block->b_host, host)) 286 if (!match(block->b_host, host))
287 continue; 287 continue;
@@ -290,12 +290,12 @@ restart:
290 if (list_empty(&block->b_list)) 290 if (list_empty(&block->b_list))
291 continue; 291 continue;
292 kref_get(&block->b_count); 292 kref_get(&block->b_count);
293 up(&file->f_sema); 293 mutex_unlock(&file->f_mutex);
294 nlmsvc_unlink_block(block); 294 nlmsvc_unlink_block(block);
295 nlmsvc_release_block(block); 295 nlmsvc_release_block(block);
296 goto restart; 296 goto restart;
297 } 297 }
298 up(&file->f_sema); 298 mutex_unlock(&file->f_mutex);
299} 299}
300 300
301/* 301/*
@@ -354,7 +354,7 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
354 lock->fl.fl_flags &= ~FL_SLEEP; 354 lock->fl.fl_flags &= ~FL_SLEEP;
355again: 355again:
356 /* Lock file against concurrent access */ 356 /* Lock file against concurrent access */
357 down(&file->f_sema); 357 mutex_lock(&file->f_mutex);
358 /* Get existing block (in case client is busy-waiting) */ 358 /* Get existing block (in case client is busy-waiting) */
359 block = nlmsvc_lookup_block(file, lock); 359 block = nlmsvc_lookup_block(file, lock);
360 if (block == NULL) { 360 if (block == NULL) {
@@ -392,10 +392,10 @@ again:
392 392
393 /* If we don't have a block, create and initialize it. Then 393 /* If we don't have a block, create and initialize it. Then
394 * retry because we may have slept in kmalloc. */ 394 * retry because we may have slept in kmalloc. */
395 /* We have to release f_sema as nlmsvc_create_block may try to 395 /* We have to release f_mutex as nlmsvc_create_block may try to
396 * to claim it while doing host garbage collection */ 396 * to claim it while doing host garbage collection */
397 if (newblock == NULL) { 397 if (newblock == NULL) {
398 up(&file->f_sema); 398 mutex_unlock(&file->f_mutex);
399 dprintk("lockd: blocking on this lock (allocating).\n"); 399 dprintk("lockd: blocking on this lock (allocating).\n");
400 if (!(newblock = nlmsvc_create_block(rqstp, file, lock, cookie))) 400 if (!(newblock = nlmsvc_create_block(rqstp, file, lock, cookie)))
401 return nlm_lck_denied_nolocks; 401 return nlm_lck_denied_nolocks;
@@ -405,7 +405,7 @@ again:
405 /* Append to list of blocked */ 405 /* Append to list of blocked */
406 nlmsvc_insert_block(newblock, NLM_NEVER); 406 nlmsvc_insert_block(newblock, NLM_NEVER);
407out: 407out:
408 up(&file->f_sema); 408 mutex_unlock(&file->f_mutex);
409 nlmsvc_release_block(newblock); 409 nlmsvc_release_block(newblock);
410 nlmsvc_release_block(block); 410 nlmsvc_release_block(block);
411 dprintk("lockd: nlmsvc_lock returned %u\n", ret); 411 dprintk("lockd: nlmsvc_lock returned %u\n", ret);
@@ -489,9 +489,9 @@ nlmsvc_cancel_blocked(struct nlm_file *file, struct nlm_lock *lock)
489 (long long)lock->fl.fl_start, 489 (long long)lock->fl.fl_start,
490 (long long)lock->fl.fl_end); 490 (long long)lock->fl.fl_end);
491 491
492 down(&file->f_sema); 492 mutex_lock(&file->f_mutex);
493 block = nlmsvc_lookup_block(file, lock); 493 block = nlmsvc_lookup_block(file, lock);
494 up(&file->f_sema); 494 mutex_unlock(&file->f_mutex);
495 if (block != NULL) { 495 if (block != NULL) {
496 status = nlmsvc_unlink_block(block); 496 status = nlmsvc_unlink_block(block);
497 nlmsvc_release_block(block); 497 nlmsvc_release_block(block);
diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c
index a1c7c0848415..514f5f20701e 100644
--- a/fs/lockd/svcsubs.c
+++ b/fs/lockd/svcsubs.c
@@ -106,7 +106,7 @@ nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result,
106 goto out_unlock; 106 goto out_unlock;
107 107
108 memcpy(&file->f_handle, f, sizeof(struct nfs_fh)); 108 memcpy(&file->f_handle, f, sizeof(struct nfs_fh));
109 init_MUTEX(&file->f_sema); 109 mutex_init(&file->f_mutex);
110 INIT_HLIST_NODE(&file->f_list); 110 INIT_HLIST_NODE(&file->f_list);
111 INIT_LIST_HEAD(&file->f_blocks); 111 INIT_LIST_HEAD(&file->f_blocks);
112 112
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index 5920ecaeed66..2909619c0295 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -111,7 +111,7 @@ struct nlm_file {
111 struct list_head f_blocks; /* blocked locks */ 111 struct list_head f_blocks; /* blocked locks */
112 unsigned int f_locks; /* guesstimate # of locks */ 112 unsigned int f_locks; /* guesstimate # of locks */
113 unsigned int f_count; /* reference count */ 113 unsigned int f_count; /* reference count */
114 struct semaphore f_sema; /* avoid concurrent access */ 114 struct mutex f_mutex; /* avoid concurrent access */
115}; 115};
116 116
117/* 117/*