summaryrefslogtreecommitdiffstats
path: root/fs/nfs/delegation.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2013-02-07 10:54:07 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2013-02-11 15:33:13 -0500
commit65b62a29f719e937b5be1df472287f4c61e53ac6 (patch)
treeea6b552a08883d92cfedb891044fa9697cbc5619 /fs/nfs/delegation.c
parent37380e4264dbda9753e470a30d4322097aab7152 (diff)
downloadlinux-65b62a29f719e937b5be1df472287f4c61e53ac6.tar.gz
linux-65b62a29f719e937b5be1df472287f4c61e53ac6.tar.bz2
linux-65b62a29f719e937b5be1df472287f4c61e53ac6.zip
NFSv4: Ensure delegation recall and byte range lock removal don't conflict
Add a mutex to the struct nfs4_state_owner to ensure that delegation recall doesn't conflict with byte range lock removal. Note that we nest the new mutex _outside_ the state manager reclaim protection (nfsi->rwsem) in order to avoid deadlocks. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/delegation.c')
-rw-r--r--fs/nfs/delegation.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index 2542cdaa1116..6390a4b5fee7 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -71,8 +71,10 @@ static int nfs_delegation_claim_locks(struct nfs_open_context *ctx, struct nfs4_
int status = 0;
if (inode->i_flock == NULL)
- goto out;
+ return 0;
+ if (inode->i_flock == NULL)
+ goto out;
/* Protect inode->i_flock using the file locks lock */
lock_flocks();
for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) {
@@ -113,12 +115,15 @@ again:
get_nfs_open_context(ctx);
spin_unlock(&inode->i_lock);
sp = state->owner;
+ /* Block nfs4_proc_unlck */
+ mutex_lock(&sp->so_delegreturn_mutex);
seq = raw_seqcount_begin(&sp->so_reclaim_seqcount);
err = nfs4_open_delegation_recall(ctx, state, stateid);
if (!err)
err = nfs_delegation_claim_locks(ctx, state);
if (!err && read_seqcount_retry(&sp->so_reclaim_seqcount, seq))
err = -EAGAIN;
+ mutex_unlock(&sp->so_delegreturn_mutex);
put_nfs_open_context(ctx);
if (err != 0)
return err;