Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp1558706rwa; Sun, 21 Aug 2022 11:04:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR7PMlxpMRaVQbdtXwL9BU7DphP4v9/LU0AUXC4f0UtXB/3AnIPPoppeq4bN6LY8hDSypIGF X-Received: by 2002:aa7:cc06:0:b0:440:7258:ad16 with SMTP id q6-20020aa7cc06000000b004407258ad16mr13150973edt.74.1661105098986; Sun, 21 Aug 2022 11:04:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661105098; cv=none; d=google.com; s=arc-20160816; b=uG/u1t7sVYybmmEcHRXsqyvuhDNGG1XwlyBXZvQydqyJrab31YxABpB2aI1Yen/nln KGkh4y13/R6nQ5SqfldnzkqxGY+40gpfv6z8brHWGSEJCvkvTH5HLkW0OYPsFf9mvcLW VGvBqVKkTR5CNhZ+kMOi7zF0dbLyrMwRlyCWx/OSZwFxopzmQC5Bl+mFaswyx3iOjAbk MpalcH5V1hiytDdPlFV15BlwUF8dbMV+wts5+BibQ0zBj522zkXjtmJ3EgFT+RcBudt1 H/qEYV0ZYlhVJe/up3hYgVoHUfSd9IkQensjPO6zGSvv5QO85RCBwUIretZULaHPgk8j pnrA== 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:cc:to:from:subject; bh=y/CwLitnPjXa+2NEjnio+zAWkmptCewR9iePXk8DSm4=; b=kEez+9r2gd6AFmAsxt6qkUu+75y9ccQQ9gKtigjsSIHd7cqcuUP0QW6S3MzG3u63S5 4JLsPLbiVQ9igIwOXEjSirywkWlCdM/MZhgf52ed642K4RIGOlIwm/LZCHKiaGhEuHn9 cz4Yv9nTIFFXbiAf7JIOJarNAtAdgZqryUs1Eu/PPopfuVHTExvqoqrZ7+8lrg0gni/O RAZK1e6AqVw5vz2XPeUTJRwro0CNr2Bzy0nqv4n93vwtXQ3xOBjpvZtaTihWDzNRuN25 7L3RA9NfDMWdN1hSPk/4z976yrMXrpxHR5E7T5uz2In6TclX6D13P3R2Q7I3D1bGKAe6 BtOQ== 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 hq37-20020a1709073f2500b00730d5c78b76si7879847ejc.961.2022.08.21.11.04.16; Sun, 21 Aug 2022 11:04:58 -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 S229491AbiHUSDX (ORCPT + 99 others); Sun, 21 Aug 2022 14:03:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229560AbiHUSDW (ORCPT ); Sun, 21 Aug 2022 14:03:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E5D3766C for ; Sun, 21 Aug 2022 11:03:20 -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 dfw.source.kernel.org (Postfix) with ESMTPS id DF83160F1A for ; Sun, 21 Aug 2022 18:03:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 252ACC433C1; Sun, 21 Aug 2022 18:03:19 +0000 (UTC) Subject: [PATCH RFC] NFSD: Process some operations before returning NFS4ERR_RESOURCE From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: don.brady@delphix.com Date: Sun, 21 Aug 2022 14:03:18 -0400 Message-ID: <166110487595.12503.10743719436399570590.stgit@manet.1015granger.net> User-Agent: StGit/1.5.dev2+g9ce680a5 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 If an NFS server returns RESOURCE on the first operation in an NFSv4 COMPOUND, there's no way for a client to make forward progress. Instead, make the server process as many operations in a large COMPOUND as it can before returning NFS4ERR_RESOURCE on the first operation it did not process. Suggested-by: Bruce Fields Link: https://bugzilla.kernel.org/show_bug.cgi?id=216383 Fixes: 0078117c6d91 ("nfsd: return RESOURCE not GARBAGE_ARGS on too many ops") Signed-off-by: Chuck Lever --- fs/nfsd/nfs4proc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) Hi- Request for comments, compile-tested only. diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index a72ab97f77ef..094cf4520931 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -2633,9 +2633,6 @@ nfsd4_proc_compound(struct svc_rqst *rqstp) status = nfserr_minor_vers_mismatch; if (nfsd_minorversion(nn, args->minorversion, NFSD_TEST) <= 0) goto out; - status = nfserr_resource; - if (args->opcnt > NFSD_MAX_OPS_PER_COMPOUND) - goto out; status = nfs41_check_op_ordering(args); if (status) { @@ -2650,6 +2647,11 @@ nfsd4_proc_compound(struct svc_rqst *rqstp) trace_nfsd_compound(rqstp, args->opcnt); while (!status && resp->opcnt < args->opcnt) { + if (unlikely(resp->opcnt > NFSD_MAX_OPS_PER_COMPOUND)) { + status = nfserr_resource; + break; + } + op = &args->ops[resp->opcnt++]; /*