nfsd: Use the COPY_FILE_RANGE_TIMEO1SEC flag

Although it is not specified in the RFCs, the concept that
the NFSv4 server should reply to an RPC request within a
reasonable time is accepted practice within the NFSv4 community.

Without this patch, the NFSv4.2 server attempts to reply to
a Copy operation within 1 second by limiting the copy to
vfs.nfs.maxcopyrange bytes (default 10Mbytes). This is crude at
best, given the large variation in I/O subsystem performance.

This patch uses the COPY_FILE_RANGE_TIMEO1SEC flag added by
commit c5128c48df to limit the reply time for a Copy
operation to approximately 1 second.

MFC after:	2 weeks
This commit is contained in:
Rick Macklem 2021-09-08 14:29:20 -07:00
parent c4c6615324
commit 103b207536

View File

@ -65,7 +65,6 @@ extern int nfsd_debuglevel;
extern u_long sb_max_adj; extern u_long sb_max_adj;
extern int nfsrv_pnfsatime; extern int nfsrv_pnfsatime;
extern int nfsrv_maxpnfsmirror; extern int nfsrv_maxpnfsmirror;
extern int nfs_maxcopyrange;
extern uint32_t nfs_srvmaxio; extern uint32_t nfs_srvmaxio;
static int nfs_async = 0; static int nfs_async = 0;
@ -5506,7 +5505,6 @@ nfsrvd_copy_file_range(struct nfsrv_descript *nd, __unused int isdgram,
int cnt, error = 0, ret; int cnt, error = 0, ret;
off_t inoff, outoff; off_t inoff, outoff;
uint64_t len; uint64_t len;
size_t xfer;
struct nfsstate inst, outst, *instp = &inst, *outstp = &outst; struct nfsstate inst, outst, *instp = &inst, *outstp = &outst;
struct nfslock inlo, outlo, *inlop = &inlo, *outlop = &outlo; struct nfslock inlo, outlo, *inlop = &inlo, *outlop = &outlo;
nfsquad_t clientid; nfsquad_t clientid;
@ -5681,21 +5679,10 @@ nfsrvd_copy_file_range(struct nfsrv_descript *nd, __unused int isdgram,
nd->nd_repstat = error; nd->nd_repstat = error;
} }
/* if (nd->nd_repstat == 0)
* Do the actual copy to an upper limit of vfs.nfs.maxcopyrange.
* This limit is applied to ensure that the RPC replies in a
* reasonable time.
*/
if (len > nfs_maxcopyrange)
xfer = nfs_maxcopyrange;
else
xfer = len;
if (nd->nd_repstat == 0) {
nd->nd_repstat = vn_copy_file_range(vp, &inoff, tovp, &outoff, nd->nd_repstat = vn_copy_file_range(vp, &inoff, tovp, &outoff,
&xfer, 0, nd->nd_cred, nd->nd_cred, NULL); &len, COPY_FILE_RANGE_TIMEO1SEC, nd->nd_cred, nd->nd_cred,
if (nd->nd_repstat == 0) NULL);
len = xfer;
}
/* Unlock the ranges. */ /* Unlock the ranges. */
if (rl_rcookie != NULL) if (rl_rcookie != NULL)