diff mbox

nfs: Fix open state losing after delegation return

Message ID 55FA8D22.2010003@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kinglong Mee Sept. 17, 2015, 9:51 a.m. UTC
After delegation return caused by setting file mode, 
client lost the open state,  DESTROY_CLIENTID will 
get error NFS4ERR_CLIENTID_BUSY from server.

The delegation_type passed to nfs4_open_recover_helper
with NFS4_OPEN_CLAIM_DELEG_CUR_FH is never set.

Reproduce steps,
# mount -t nfs nfs-server:/ /mnt/
# ./delegation_test /mnt/
# umount /mnt    <--- costs 10 seconds

The delegation_test.c is,
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <error.h>

int main(int argc, char **argv)
{
        int fd1, fd2;
        char fname1[1024], fname2[1024];
        struct stat sb;

        if (argc < 2)
                return -1;

        sprintf(fname1, "%s/test1", argv[1]);
        sprintf(fname2, "%s/test2", argv[1]);

        fd1 = open(fname1, O_RDONLY);
        fd2 = open(fname2, O_RDONLY);

        fstat(fd1, &sb);
        fchmod(fd1, sb.st_mode + 1);

        close(fd1);
        close(fd2);

        return 0;
}

Fixes: 39f897fdbd ("NFSv4: When returning a delegation, don't reclaim an incompatible open mode.")
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
---
 fs/nfs/nfs4proc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff mbox

Patch

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 693b903..472a52f 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -1576,8 +1576,7 @@  static int nfs4_open_recover_helper(struct nfs4_opendata *opendata, fmode_t fmod
 	struct nfs4_state *newstate;
 	int ret;
 
-	if ((opendata->o_arg.claim == NFS4_OPEN_CLAIM_DELEGATE_CUR ||
-	     opendata->o_arg.claim == NFS4_OPEN_CLAIM_DELEG_CUR_FH) &&
+	if (opendata->o_arg.claim == NFS4_OPEN_CLAIM_DELEGATE_CUR &&
 	    (opendata->o_arg.u.delegation_type & fmode) != fmode)
 		/* This mode can't have been delegated, so we must have
 		 * a valid open_stateid to cover it - not need to reclaim.