|
@@ -365,7 +365,7 @@ __be32
|
|
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 nlm_block *block, *newblock = NULL;
|
|
|
|
|
|
+ struct nlm_block *block = NULL;
|
|
int error;
|
|
int error;
|
|
__be32 ret;
|
|
__be32 ret;
|
|
|
|
|
|
@@ -378,17 +378,20 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
|
|
wait);
|
|
wait);
|
|
|
|
|
|
|
|
|
|
- lock->fl.fl_flags &= ~FL_SLEEP;
|
|
|
|
-again:
|
|
|
|
/* Lock file against concurrent access */
|
|
/* Lock file against concurrent access */
|
|
mutex_lock(&file->f_mutex);
|
|
mutex_lock(&file->f_mutex);
|
|
- /* Get existing block (in case client is busy-waiting) */
|
|
|
|
|
|
+ /* Get existing block (in case client is busy-waiting)
|
|
|
|
+ * or create new block
|
|
|
|
+ */
|
|
block = nlmsvc_lookup_block(file, lock);
|
|
block = nlmsvc_lookup_block(file, lock);
|
|
if (block == NULL) {
|
|
if (block == NULL) {
|
|
- if (newblock != NULL)
|
|
|
|
- lock = &newblock->b_call->a_args.lock;
|
|
|
|
- } else
|
|
|
|
|
|
+ block = nlmsvc_create_block(rqstp, file, lock, cookie);
|
|
|
|
+ ret = nlm_lck_denied_nolocks;
|
|
|
|
+ if (block == NULL)
|
|
|
|
+ goto out;
|
|
lock = &block->b_call->a_args.lock;
|
|
lock = &block->b_call->a_args.lock;
|
|
|
|
+ } else
|
|
|
|
+ lock->fl.fl_flags &= ~FL_SLEEP;
|
|
|
|
|
|
error = posix_lock_file(file->f_file, &lock->fl, NULL);
|
|
error = posix_lock_file(file->f_file, &lock->fl, NULL);
|
|
lock->fl.fl_flags &= ~FL_SLEEP;
|
|
lock->fl.fl_flags &= ~FL_SLEEP;
|
|
@@ -414,26 +417,11 @@ again:
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
ret = nlm_lck_blocked;
|
|
ret = nlm_lck_blocked;
|
|
- if (block != NULL)
|
|
|
|
- goto out;
|
|
|
|
-
|
|
|
|
- /* If we don't have a block, create and initialize it. Then
|
|
|
|
- * retry because we may have slept in kmalloc. */
|
|
|
|
- /* We have to release f_mutex as nlmsvc_create_block may try to
|
|
|
|
- * to claim it while doing host garbage collection */
|
|
|
|
- if (newblock == NULL) {
|
|
|
|
- mutex_unlock(&file->f_mutex);
|
|
|
|
- dprintk("lockd: blocking on this lock (allocating).\n");
|
|
|
|
- if (!(newblock = nlmsvc_create_block(rqstp, file, lock, cookie)))
|
|
|
|
- return nlm_lck_denied_nolocks;
|
|
|
|
- goto again;
|
|
|
|
- }
|
|
|
|
|
|
|
|
/* Append to list of blocked */
|
|
/* Append to list of blocked */
|
|
- nlmsvc_insert_block(newblock, NLM_NEVER);
|
|
|
|
|
|
+ nlmsvc_insert_block(block, NLM_NEVER);
|
|
out:
|
|
out:
|
|
mutex_unlock(&file->f_mutex);
|
|
mutex_unlock(&file->f_mutex);
|
|
- nlmsvc_release_block(newblock);
|
|
|
|
nlmsvc_release_block(block);
|
|
nlmsvc_release_block(block);
|
|
dprintk("lockd: nlmsvc_lock returned %u\n", ret);
|
|
dprintk("lockd: nlmsvc_lock returned %u\n", ret);
|
|
return ret;
|
|
return ret;
|