aboutsummaryrefslogtreecommitdiffstats
path: root/fs/lockd
diff options
context:
space:
mode:
authorAndy Adamson <andros@citi.umich.edu>2006-03-20 13:44:25 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-03-20 13:44:25 -0500
commita85f193e2fb7d53e48ae6a9d9ea990bfb4cea555 (patch)
treef992c9b6b0ba6f1726a48af99a0251270d32e821 /fs/lockd
parent5de0e5024a4e21251fd80dbfdb83316ce97086bc (diff)
lockd: make nlmsvc_lock use only posix_lock_file
Reorganize nlmsvc_lock() to make full use of posix_lock_file(), which does eveything nlmsvc_lock() needs - no need to call posix_test_lock(), posix_locks_deadlock(), or posix_block_lock() separately. Signed-off-by: Andy Adamson <andros@citi.umich.edu> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/lockd')
-rw-r--r--fs/lockd/svclock.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index 58bbfede94ec..f5398097b84b 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -297,7 +297,6 @@ u32
297nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file, 297nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
298 struct nlm_lock *lock, int wait, struct nlm_cookie *cookie) 298 struct nlm_lock *lock, int wait, struct nlm_cookie *cookie)
299{ 299{
300 struct file_lock *conflock;
301 struct nlm_block *block; 300 struct nlm_block *block;
302 int error; 301 int error;
303 u32 ret; 302 u32 ret;
@@ -320,14 +319,15 @@ again:
320 /* Lock file against concurrent access */ 319 /* Lock file against concurrent access */
321 down(&file->f_sema); 320 down(&file->f_sema);
322 321
323 if (!(conflock = posix_test_lock(file->f_file, &lock->fl))) { 322 error = posix_lock_file(file->f_file, &lock->fl);
324 error = posix_lock_file(file->f_file, &lock->fl); 323
324 dprintk("lockd: posix_lock_file returned %d\n", error);
325 325
326 if (error != -EAGAIN) {
326 if (block) 327 if (block)
327 nlmsvc_delete_block(block, 0); 328 nlmsvc_delete_block(block, 0);
328 up(&file->f_sema); 329 up(&file->f_sema);
329 330
330 dprintk("lockd: posix_lock_file returned %d\n", -error);
331 switch(-error) { 331 switch(-error) {
332 case 0: 332 case 0:
333 ret = nlm_granted; 333 ret = nlm_granted;
@@ -335,9 +335,6 @@ again:
335 case EDEADLK: 335 case EDEADLK:
336 ret = nlm_deadlock; 336 ret = nlm_deadlock;
337 goto out; 337 goto out;
338 case EAGAIN:
339 ret = nlm_lck_denied;
340 goto out;
341 default: /* includes ENOLCK */ 338 default: /* includes ENOLCK */
342 ret = nlm_lck_denied_nolocks; 339 ret = nlm_lck_denied_nolocks;
343 goto out; 340 goto out;
@@ -349,11 +346,6 @@ again:
349 goto out_unlock; 346 goto out_unlock;
350 } 347 }
351 348
352 if (posix_locks_deadlock(&lock->fl, conflock)) {
353 ret = nlm_deadlock;
354 goto out_unlock;
355 }
356
357 /* If we don't have a block, create and initialize it. Then 349 /* If we don't have a block, create and initialize it. Then
358 * retry because we may have slept in kmalloc. */ 350 * retry because we may have slept in kmalloc. */
359 /* We have to release f_sema as nlmsvc_create_block may try to 351 /* We have to release f_sema as nlmsvc_create_block may try to
@@ -369,13 +361,6 @@ again:
369 /* Append to list of blocked */ 361 /* Append to list of blocked */
370 nlmsvc_insert_block(block, NLM_NEVER); 362 nlmsvc_insert_block(block, NLM_NEVER);
371 363
372 if (list_empty(&block->b_call.a_args.lock.fl.fl_block)) {
373 /* Now add block to block list of the conflicting lock
374 if we haven't done so. */
375 dprintk("lockd: blocking on this lock.\n");
376 posix_block_lock(conflock, &block->b_call.a_args.lock.fl);
377 }
378
379 ret = nlm_lck_blocked; 364 ret = nlm_lck_blocked;
380out_unlock: 365out_unlock:
381 up(&file->f_sema); 366 up(&file->f_sema);