NFSv4.x: Fix handling of partially delegated locks
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Tue, 30 Apr 2013 16:43:42 +0000 (12:43 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Fri, 3 May 2013 16:18:47 +0000 (12:18 -0400)
If a NFS client receives a delegation for a file after it has taken
a lock on that file, we can currently end up in a situation where
we mistakenly skip unlocking that file.

The following patch swaps an erroneous check in nfs4_proc_unlck for
whether or not the file has a delegation to one which checks whether
or not we hold a lock stateid for that file.

Reported-by: Chuck Lever <Chuck.Lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: stable@vger.kernel.org [>=3.7]
Tested-by: Chuck Lever <Chuck.Lever@oracle.com>
fs/nfs/nfs4proc.c

index 9da4bd55eb3019a964f8a7a7b0f89e2bab4c8b42..dc1da2adc459947fdd5160658e930e82f8b2788b 100644 (file)
@@ -4766,9 +4766,9 @@ static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *
        if (status != 0)
                goto out;
        /* Is this a delegated lock? */
-       if (test_bit(NFS_DELEGATED_STATE, &state->flags))
-               goto out;
        lsp = request->fl_u.nfs4_fl.owner;
+       if (test_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags) == 0)
+               goto out;
        seqid = nfs_alloc_seqid(&lsp->ls_seqid, GFP_KERNEL);
        status = -ENOMEM;
        if (seqid == NULL)
This page took 0.026511 seconds and 5 git commands to generate.