Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp176726rwb; Fri, 2 Sep 2022 12:10:15 -0700 (PDT) X-Google-Smtp-Source: AA6agR6wWetWfJQcSUQhZVgeloVaXAi0gx6AdOEOatNVkUqVGyVsVj7mdxppn9QP7jnuKoDjO5qr X-Received: by 2002:a17:906:cc57:b0:73d:cdfd:28b4 with SMTP id mm23-20020a170906cc5700b0073dcdfd28b4mr27144146ejb.211.1662145815395; Fri, 02 Sep 2022 12:10:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662145815; cv=none; d=google.com; s=arc-20160816; b=AmwUfCgkb55gTHV3A6wZQKl2e8rkU0cS23IQW+jW3n/7cHrCElSDR3+yZAl2Ax49l1 3iC1cR3l1Zn9D4mEnav486lAqIscZELeOfJR2j+MOfTU/B+93UOEKEf3orpYZvg+dhPx TO7X9iFdeA9KST0WFa3cAhBMC6KmQgXhICb8DUFVjXTbKa6rBE6ZtruLDRb8omeWay0L 4QgRhFqRvGoC+IGgjLaDcIPkPI9hMc5/4w687N5xtJpFMdbh/GI/D9OLSV15X6apObqM ol6InbQStLISExoiHlBCvZFSthLqKQcZa6zEIo6u50w2/3ajvqn7PoFCUP16o1vYjKst doZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:message-id:date:to:from:subject; bh=snMBQy9kPMMFk7At1+8+4lTfA7Z/b96r98sG1bBVLn8=; b=fNOMDUOkY7BUOCJPVS05IuN5ckXSMaeuMxfoDY7dafDvkuBkxOX7TOlF96yR/9EN1z CyeRK5exREjcjirBdqlssXvnrZp0pxYfaorPfJwxQEoYuIwp9B/Uc70p5SDXcQRnOpzR F1AhmkKgX2SKZycSzqYSaW7e34xMPkrvIHibczoaidRRAOgh4ZsPyq0rmuN7kqlpoR8b dVntr7VsPyWf9q2UIzRPPdEsOJIitMc7ob+zWmUlXIaTU83ZH+HvEUXmZeNV6iHnP0AW TYSamRcafqhP19UXIyAWfVguDZCW+FEkvPcf2gvIRKNnejfQE5nmfS4xqpZtJ/1rpZEI R0OQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn4-20020a1709070d0400b0073d8663d88csi2346592ejc.685.2022.09.02.12.09.36; Fri, 02 Sep 2022 12:10:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229919AbiIBSym (ORCPT + 99 others); Fri, 2 Sep 2022 14:54:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230182AbiIBSyg (ORCPT ); Fri, 2 Sep 2022 14:54:36 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B55B81EECE for ; Fri, 2 Sep 2022 11:54:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3F051B82D06 for ; Fri, 2 Sep 2022 18:54:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D53C2C433C1 for ; Fri, 2 Sep 2022 18:54:30 +0000 (UTC) Subject: [PATCH v1] NFSD: Increase NFSD_MAX_OPS_PER_COMPOUND From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Fri, 02 Sep 2022 14:54:29 -0400 Message-ID: <166214486962.101939.2252490595444681944.stgit@bazille.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org When attempting an NFSv4 mount, a Solaris NFSv4 client builds a single large COMPOUND that chains a series of LOOKUPs to get to the pseudo filesystem root directory that is to be mounted. The Linux NFS server's current maximum of 16 operations per NFSv4 COMPOUND is not large enough to ensure that this works for paths that are more than a few components deep. Since NFSD_MAX_OPS_PER_COMPOUND is mostly a sanity check, and most NFSv4 COMPOUNDS are between 3 and 6 operations (thus they do not trigger any re-allocation of the operation array on the server), increasing this maximum should result in little to no impact. The ops array can get large now, so allocate it via vmalloc() to help ensure memory fragmentation won't cause an allocation failure. Link: https://bugzilla.kernel.org/show_bug.cgi?id=216383 Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 5 ++--- fs/nfsd/state.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 1e9690a061ec..a04b9b29678f 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2369,10 +2369,9 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp) return true; if (argp->opcnt > ARRAY_SIZE(argp->iops)) { - argp->ops = kzalloc(argp->opcnt * sizeof(*argp->ops), GFP_KERNEL); + argp->ops = vcalloc(argp->opcnt, sizeof(*argp->ops)); if (!argp->ops) { argp->ops = argp->iops; - dprintk("nfsd: couldn't allocate room for COMPOUND\n"); return false; } } @@ -5394,7 +5393,7 @@ void nfsd4_release_compoundargs(struct svc_rqst *rqstp) struct nfsd4_compoundargs *args = rqstp->rq_argp; if (args->ops != args->iops) { - kfree(args->ops); + vfree(args->ops); args->ops = args->iops; } while (args->to_free) { diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index ae596dbf8667..5d28beb290fe 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -175,7 +175,7 @@ static inline struct nfs4_delegation *delegstateid(struct nfs4_stid *s) /* Maximum number of slots per session. 160 is useful for long haul TCP */ #define NFSD_MAX_SLOTS_PER_SESSION 160 /* Maximum number of operations per session compound */ -#define NFSD_MAX_OPS_PER_COMPOUND 16 +#define NFSD_MAX_OPS_PER_COMPOUND 50 /* Maximum session per slot cache size */ #define NFSD_SLOT_CACHE_SIZE 2048 /* Maximum number of NFSD_SLOT_CACHE_SIZE slots per session */