Skip to content

Commit 48aab16

Browse files
committed
NFSD: Remove the cap on number of operations per NFSv4 COMPOUND
This limit has always been a sanity check; in nearly all cases a large COMPOUND is a sign of a malfunctioning client. The only real limit on COMPOUND size and complexity is the size of NFSD's send and receive buffers. However, there are a few cases where a large COMPOUND is sane. For example, when a client implementation wants to walk down a long file pathname in a single round trip. A small risk is that now a client can construct a COMPOUND request that can keep a single nfsd thread busy for quite some time. Suggested-by: Jeff Layton <jlayton@kernel.org> Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent a2d6142 commit 48aab16

5 files changed

Lines changed: 3 additions & 20 deletions

File tree

fs/nfsd/nfs4proc.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2842,20 +2842,10 @@ nfsd4_proc_compound(struct svc_rqst *rqstp)
28422842

28432843
rqstp->rq_lease_breaker = (void **)&cstate->clp;
28442844

2845-
trace_nfsd_compound(rqstp, args->tag, args->taglen, args->client_opcnt);
2845+
trace_nfsd_compound(rqstp, args->tag, args->taglen, args->opcnt);
28462846
while (!status && resp->opcnt < args->opcnt) {
28472847
op = &args->ops[resp->opcnt++];
28482848

2849-
if (unlikely(resp->opcnt == NFSD_MAX_OPS_PER_COMPOUND)) {
2850-
/* If there are still more operations to process,
2851-
* stop here and report NFS4ERR_RESOURCE. */
2852-
if (cstate->minorversion == 0 &&
2853-
args->client_opcnt > resp->opcnt) {
2854-
op->status = nfserr_resource;
2855-
goto encode_op;
2856-
}
2857-
}
2858-
28592849
/*
28602850
* The XDR decode routines may have pre-set op->status;
28612851
* for example, if there is a miscellaneous XDR error
@@ -2932,7 +2922,7 @@ nfsd4_proc_compound(struct svc_rqst *rqstp)
29322922
status = op->status;
29332923
}
29342924

2935-
trace_nfsd_compound_status(args->client_opcnt, resp->opcnt,
2925+
trace_nfsd_compound_status(args->opcnt, resp->opcnt,
29362926
status, nfsd4_op_name(op->opnum));
29372927

29382928
nfsd4_cstate_clear_replay(cstate);

fs/nfsd/nfs4state.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3865,7 +3865,6 @@ static __be32 check_forechannel_attrs(struct nfsd4_channel_attrs *ca, struct nfs
38653865
ca->headerpadsz = 0;
38663866
ca->maxreq_sz = min_t(u32, ca->maxreq_sz, maxrpc);
38673867
ca->maxresp_sz = min_t(u32, ca->maxresp_sz, maxrpc);
3868-
ca->maxops = min_t(u32, ca->maxops, NFSD_MAX_OPS_PER_COMPOUND);
38693868
ca->maxresp_cached = min_t(u32, ca->maxresp_cached,
38703869
NFSD_SLOT_CACHE_SIZE + NFSD_MIN_HDR_SEQ_SZ);
38713870
ca->maxreqs = min_t(u32, ca->maxreqs, NFSD_MAX_SLOTS_PER_SESSION);

fs/nfsd/nfs4xdr.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2500,10 +2500,8 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp)
25002500

25012501
if (xdr_stream_decode_u32(argp->xdr, &argp->minorversion) < 0)
25022502
return false;
2503-
if (xdr_stream_decode_u32(argp->xdr, &argp->client_opcnt) < 0)
2503+
if (xdr_stream_decode_u32(argp->xdr, &argp->opcnt) < 0)
25042504
return false;
2505-
argp->opcnt = min_t(u32, argp->client_opcnt,
2506-
NFSD_MAX_OPS_PER_COMPOUND);
25072505

25082506
if (argp->opcnt > ARRAY_SIZE(argp->iops)) {
25092507
argp->ops = vcalloc(argp->opcnt, sizeof(*argp->ops));

fs/nfsd/nfsd.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ struct readdir_cd {
5757
__be32 err; /* 0, nfserr, or nfserr_eof */
5858
};
5959

60-
/* Maximum number of operations per session compound */
61-
#define NFSD_MAX_OPS_PER_COMPOUND 50
62-
6360
struct nfsd_genl_rqstp {
6461
struct sockaddr rq_daddr;
6562
struct sockaddr rq_saddr;

fs/nfsd/xdr4.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,6 @@ struct nfsd4_compoundargs {
870870
char * tag;
871871
u32 taglen;
872872
u32 minorversion;
873-
u32 client_opcnt;
874873
u32 opcnt;
875874
bool splice_ok;
876875
struct nfsd4_op *ops;

0 commit comments

Comments
 (0)