NFSD: Fix 5 seconds delay when doing inter server copy
authorDai Ngo <dai.ngo@oracle.com>
Mon, 30 Nov 2020 21:24:49 +0000 (16:24 -0500)
committerChuck Lever <chuck.lever@oracle.com>
Wed, 9 Dec 2020 14:38:34 +0000 (09:38 -0500)
commitca9364dde50daba93eff711b4b945fd08beafcc2
tree725a2185b8a8c16de8e8bc39c2b0ffb13ff3e58e
parenteb162e1772f85231dabc789fb4bfea63d2d9df79
NFSD: Fix 5 seconds delay when doing inter server copy

Since commit b4868b44c5628 ("NFSv4: Wait for stateid updates after
CLOSE/OPEN_DOWNGRADE"), every inter server copy operation suffers 5
seconds delay regardless of the size of the copy. The delay is from
nfs_set_open_stateid_locked when the check by nfs_stateid_is_sequential
fails because the seqid in both nfs4_state and nfs4_stateid are 0.

Fix by modifying nfs4_init_cp_state to return the stateid with seqid 1
instead of 0. This is also to conform with section 4.8 of RFC 7862.

Here is the relevant paragraph from section 4.8 of RFC 7862:

   A copy offload stateid's seqid MUST NOT be zero.  In the context of a
   copy offload operation, it is inappropriate to indicate "the most
   recent copy offload operation" using a stateid with a seqid of zero
   (see Section 8.2.2 of [RFC5661]).  It is inappropriate because the
   stateid refers to internal state in the server and there may be
   several asynchronous COPY operations being performed in parallel on
   the same file by the server.  Therefore, a copy offload stateid with
   a seqid of zero MUST be considered invalid.

Fixes: ce0887ac96d3 ("NFSD add nfs4 inter ssc to nfsd4_copy")
Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfs4state.c