Skip to content

Commit

Permalink
lockd: dont return EAGAIN for a permanent error
Browse files Browse the repository at this point in the history
Fix nlm_fopen() to return NLM_FAILED (or NLM_LCK_DENIED_NOLOCKS) instead
of NLM_LCK_DENIED.  The latter means the lock request failed because of a
conflicting lock (i.e.  a temporary error), which is wrong in this case.

Also fix the client to return ENOLCK instead of EAGAIN if a blocking lock
request returns with NLM_LOCK_DENIED.

Signed-off-by: Miklos Szeredi <[email protected]>
Cc: Trond Myklebust <[email protected]>
Cc: "J. Bruce Fields" <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Cc: David Teigland <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Miklos Szeredi authored and torvalds committed Jul 25, 2008
1 parent b81f3ea commit cc77b15
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
10 changes: 9 additions & 1 deletion fs/lockd/clntproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,15 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl)
}
if (status < 0)
goto out_unlock;
status = nlm_stat_to_errno(resp->status);
/*
* EAGAIN doesn't make sense for sleeping locks, and in some
* cases NLM_LCK_DENIED is returned for a permanent error. So
* turn it into an ENOLCK.
*/
if (resp->status == nlm_lck_denied && (fl_flags & FL_SLEEP))
status = -ENOLCK;
else
status = nlm_stat_to_errno(resp->status);
out_unblock:
nlmclnt_finish_block(block);
out:
Expand Down
13 changes: 9 additions & 4 deletions fs/nfsd/lockd.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@

#define NFSDDBG_FACILITY NFSDDBG_LOCKD

#ifdef CONFIG_LOCKD_V4
#define nlm_stale_fh nlm4_stale_fh
#define nlm_failed nlm4_failed
#else
#define nlm_stale_fh nlm_lck_denied_nolocks
#define nlm_failed nlm_lck_denied_nolocks
#endif
/*
* Note: we hold the dentry use count while the file is open.
*/
Expand Down Expand Up @@ -47,12 +54,10 @@ nlm_fopen(struct svc_rqst *rqstp, struct nfs_fh *f, struct file **filp)
return 0;
case nfserr_dropit:
return nlm_drop_reply;
#ifdef CONFIG_LOCKD_V4
case nfserr_stale:
return nlm4_stale_fh;
#endif
return nlm_stale_fh;
default:
return nlm_lck_denied;
return nlm_failed;
}
}

Expand Down

0 comments on commit cc77b15

Please sign in to comment.