mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-28 09:31:14 +00:00
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>
This commit is contained in:
parent
5de0e5024a
commit
a85f193e2f
1 changed files with 4 additions and 19 deletions
|
@ -297,7 +297,6 @@ u32
|
||||||
nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
|
nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
|
||||||
struct nlm_lock *lock, int wait, struct nlm_cookie *cookie)
|
struct nlm_lock *lock, int wait, struct nlm_cookie *cookie)
|
||||||
{
|
{
|
||||||
struct file_lock *conflock;
|
|
||||||
struct nlm_block *block;
|
struct nlm_block *block;
|
||||||
int error;
|
int error;
|
||||||
u32 ret;
|
u32 ret;
|
||||||
|
@ -320,14 +319,15 @@ again:
|
||||||
/* Lock file against concurrent access */
|
/* Lock file against concurrent access */
|
||||||
down(&file->f_sema);
|
down(&file->f_sema);
|
||||||
|
|
||||||
if (!(conflock = posix_test_lock(file->f_file, &lock->fl))) {
|
error = posix_lock_file(file->f_file, &lock->fl);
|
||||||
error = posix_lock_file(file->f_file, &lock->fl);
|
|
||||||
|
|
||||||
|
dprintk("lockd: posix_lock_file returned %d\n", error);
|
||||||
|
|
||||||
|
if (error != -EAGAIN) {
|
||||||
if (block)
|
if (block)
|
||||||
nlmsvc_delete_block(block, 0);
|
nlmsvc_delete_block(block, 0);
|
||||||
up(&file->f_sema);
|
up(&file->f_sema);
|
||||||
|
|
||||||
dprintk("lockd: posix_lock_file returned %d\n", -error);
|
|
||||||
switch(-error) {
|
switch(-error) {
|
||||||
case 0:
|
case 0:
|
||||||
ret = nlm_granted;
|
ret = nlm_granted;
|
||||||
|
@ -335,9 +335,6 @@ again:
|
||||||
case EDEADLK:
|
case EDEADLK:
|
||||||
ret = nlm_deadlock;
|
ret = nlm_deadlock;
|
||||||
goto out;
|
goto out;
|
||||||
case EAGAIN:
|
|
||||||
ret = nlm_lck_denied;
|
|
||||||
goto out;
|
|
||||||
default: /* includes ENOLCK */
|
default: /* includes ENOLCK */
|
||||||
ret = nlm_lck_denied_nolocks;
|
ret = nlm_lck_denied_nolocks;
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -349,11 +346,6 @@ again:
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (posix_locks_deadlock(&lock->fl, conflock)) {
|
|
||||||
ret = nlm_deadlock;
|
|
||||||
goto out_unlock;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we don't have a block, create and initialize it. Then
|
/* If we don't have a block, create and initialize it. Then
|
||||||
* retry because we may have slept in kmalloc. */
|
* retry because we may have slept in kmalloc. */
|
||||||
/* We have to release f_sema as nlmsvc_create_block may try to
|
/* We have to release f_sema as nlmsvc_create_block may try to
|
||||||
|
@ -369,13 +361,6 @@ again:
|
||||||
/* Append to list of blocked */
|
/* Append to list of blocked */
|
||||||
nlmsvc_insert_block(block, NLM_NEVER);
|
nlmsvc_insert_block(block, NLM_NEVER);
|
||||||
|
|
||||||
if (list_empty(&block->b_call.a_args.lock.fl.fl_block)) {
|
|
||||||
/* Now add block to block list of the conflicting lock
|
|
||||||
if we haven't done so. */
|
|
||||||
dprintk("lockd: blocking on this lock.\n");
|
|
||||||
posix_block_lock(conflock, &block->b_call.a_args.lock.fl);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = nlm_lck_blocked;
|
ret = nlm_lck_blocked;
|
||||||
out_unlock:
|
out_unlock:
|
||||||
up(&file->f_sema);
|
up(&file->f_sema);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue