Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1202941rwn; Thu, 8 Sep 2022 15:24:07 -0700 (PDT) X-Google-Smtp-Source: AA6agR5SIlN0R26+NhJvjbG8+SgmT0ir11LFggK7jUXQbGcBGE8qbLEjyUtRIFTysQh0ZdMybGms X-Received: by 2002:a63:1e11:0:b0:41c:d233:31f8 with SMTP id e17-20020a631e11000000b0041cd23331f8mr9578876pge.228.1662675847584; Thu, 08 Sep 2022 15:24:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662675847; cv=none; d=google.com; s=arc-20160816; b=0OjQ+JOmr6NfsIaedxdwNez1mtdW4iDeA18IZoLvSlMYfHUC47QRaHFemHhUY2SJ1G RgvqFkk8ANKVcm+yJHDXV8ESeZJy564Pt4IekY2WeGtGobzj4t5zA/RsayGpcP6syhi+ fKdt4tUKLSnA9jBpEIjHLP1hE3aqkhYUCJoXSVo+XUg5z4dyd8lNE5QSSOMUW6IlbpHE akYiuXUU0IB/c/2Pj2ntsOkvStEndrL6d5DLCm73yyFspky1li89/ctga8+DddexOTFB yccPQJhYY1um1C7kZs8GfMvbsGdQurP83+Vt+JIdx1ZhAilimuoxGyhpPb5pRA+ZbBC9 iABg== 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:references:in-reply-to:message-id:date:to:from:subject; bh=BLfDHypzkbWvCAKFme6xkCLKdYxdKf8xL7ZgIV9dnzE=; b=VxTI8DvhhbRmgP9oeZJnvPHorH8HLKkWpLVAO1c1KuplRnURUkin9dlpa3FNjFYOsO NhWocSGPqlnWBpbgCK/5o2nQ5qNWuGJqtvIsqdFg0OjSO2MQouYiuX//1nHSYwZ6mWwN cI2FH157nZ0kTdfuEYOyLLonIt+K+ZzYx75uMm5QSAo8omvDlQQIu2wKd3rsPz7iFHFv aIwrRmDOGxlwPKDXWzRswnvgUfkhR/onl+CS3njAs+unf5xYePL0ft+JWXZofy5z92cp zrTnf/E+IJMRargxTZR74bd5XHRYhTafWN88cTHc8+khE4uzHUfHBRa3/JU9SaAwbn3d 6AHQ== 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 i27-20020a63221b000000b0043041b4e7efsi21722185pgi.740.2022.09.08.15.23.54; Thu, 08 Sep 2022 15:24:07 -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 S229620AbiIHWOR (ORCPT + 99 others); Thu, 8 Sep 2022 18:14:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229764AbiIHWOQ (ORCPT ); Thu, 8 Sep 2022 18:14:16 -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 45FDF1098DE for ; Thu, 8 Sep 2022 15:14:15 -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 D747961E2E for ; Thu, 8 Sep 2022 22:14:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A79DC433C1 for ; Thu, 8 Sep 2022 22:14:14 +0000 (UTC) Subject: [PATCH v4 6/8] NFSD: Make nfsd4_setattr() wait before returning NFS4ERR_DELAY From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Thu, 08 Sep 2022 18:14:13 -0400 Message-ID: <166267525333.1842.10708885965116635193.stgit@manet.1015granger.net> In-Reply-To: <166267495153.1842.14474564029477470642.stgit@manet.1015granger.net> References: <166267495153.1842.14474564029477470642.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 nfsd_setattr() can kick off a CB_RECALL (via notify_change() -> break_lease()) if a delegation is present. Before returning NFS4ERR_DELAY, give the client holding that delegation a chance to return it and then retry the nfsd_setattr() again, once. Link: https://bugzilla.linux-nfs.org/show_bug.cgi?id=354 Tested-by: Igor Mammedov Signed-off-by: Chuck Lever --- fs/nfsd/vfs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 02f31d8c727a..03a826ccc165 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -394,6 +394,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, int host_err; bool get_write_count; bool size_change = (iap->ia_valid & ATTR_SIZE); + int retries; if (iap->ia_valid & ATTR_SIZE) { accmode |= NFSD_MAY_WRITE|NFSD_MAY_OWNER_OVERRIDE; @@ -455,7 +456,13 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, } inode_lock(inode); - host_err = __nfsd_setattr(dentry, iap); + for (retries = 1;;) { + host_err = __nfsd_setattr(dentry, iap); + if (host_err != -EAGAIN || !retries--) + break; + if (!nfsd_wait_for_delegreturn(rqstp, inode)) + break; + } if (attr->na_seclabel && attr->na_seclabel->len) attr->na_labelerr = security_inode_setsecctx(dentry, attr->na_seclabel->data, attr->na_seclabel->len);