NFSv4: Don't request close-to-open attribute when holding a delegation
authorTrond Myklebust <trond.myklebust@primarydata.com>
Thu, 27 Oct 2016 22:25:04 +0000 (18:25 -0400)
committerTrond Myklebust <trond.myklebust@primarydata.com>
Thu, 1 Dec 2016 22:21:37 +0000 (17:21 -0500)
If holding a delegation, we do not need to ask the server to return
close-to-open cache consistency attributes as part of the CLOSE
compound.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
fs/nfs/nfs4proc.c
fs/nfs/nfs4xdr.c

index c0628f78ed98f438afbada00269bffddfd4e599c..917a6db5c84f4784011f747216f118e2c6357c6e 100644 (file)
@@ -3156,8 +3156,15 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
                goto out_wait;
        }
 
-       if (calldata->arg.fmode == 0)
+       if (calldata->arg.fmode == 0) {
                task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CLOSE];
+
+               /* Close-to-open cache consistency revalidation */
+               if (!nfs4_have_delegation(inode, FMODE_READ))
+                       calldata->arg.bitmask = NFS_SERVER(inode)->cache_consistency_bitmask;
+               else
+                       calldata->arg.bitmask = NULL;
+       }
        if (calldata->roc)
                pnfs_roc_get_barrier(inode, &calldata->roc_barrier);
 
@@ -3240,7 +3247,6 @@ int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait)
        if (IS_ERR(calldata->arg.seqid))
                goto out_free_calldata;
        calldata->arg.fmode = 0;
-       calldata->arg.bitmask = server->cache_consistency_bitmask;
        calldata->res.fattr = &calldata->fattr;
        calldata->res.seqid = calldata->arg.seqid;
        calldata->res.server = server;
index c37473721230df28f405bec137725da654cf94fe..b549315038725646dd73f18a67e3d45831c01e1d 100644 (file)
@@ -2248,7 +2248,8 @@ static void nfs4_xdr_enc_close(struct rpc_rqst *req, struct xdr_stream *xdr,
        encode_sequence(xdr, &args->seq_args, &hdr);
        encode_putfh(xdr, args->fh, &hdr);
        encode_close(xdr, args, &hdr);
-       encode_getfattr(xdr, args->bitmask, &hdr);
+       if (args->bitmask != NULL)
+               encode_getfattr(xdr, args->bitmask, &hdr);
        encode_nops(&hdr);
 }