Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1207526rwn; Thu, 8 Sep 2022 15:29:58 -0700 (PDT) X-Google-Smtp-Source: AA6agR6Iz81r5Sm6/2+/4/wWCZ95bzQXLOV04Zw3nRykeLwiXFtpCkCRn35CzMOQZrbjP2nqBcoz X-Received: by 2002:a2e:9241:0:b0:26b:daf1:293b with SMTP id v1-20020a2e9241000000b0026bdaf1293bmr1353477ljg.71.1662676197863; Thu, 08 Sep 2022 15:29:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662676197; cv=none; d=google.com; s=arc-20160816; b=BtMkRtZKHWcaDCiAgzml/qiWds3FQS9TJmcSpAr/BtlE5TZUWvAurnaF89GQgJ8/fO p/VO/Gf1Vd/RQ6WQUZtCAY3b0zy4c1y34dPqXb7AojUJIRH1WOsxhb731cEcWod2DOu6 wEhFHL8SkVkL0v4YKJkxBoTYKncctGhwWAAvHujE4VISGlOxOXN8HAVp0O527qrtZqHz cV1f+lTVo5Ju9eJYOJIpNefgkHhM9mr0+9hnvCabFHaM7gXDqgqlygkWP+j3Jw6YnpHN 3Zq+HKdDLw0PJ2dOqjMEcrNCEUimhzf8zr1SJ9x0jMEzquPVSA3c+vTuk2ygKYjETDtp QiLA== 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=XLE+J94drU2vW9isDMr0ztRT+MM4z0lN4k0lcXsXPIw=; b=LvB/AjZ6fVfsdrXGgzjWb1YZmNyHaKBMNdslwrISPEPnCigbk2Qfy7LXU5L7hsGpYg rRExxIKN2EKvg35feyvh+oRVx6i75eisXBumiUf+5ZzvHpCVFc6+/wZmS8WBojj3yYKh 9rGsvhkJ25NcrLHPLimjt8wF0X7TXX28azFoGTlPNz3aJ8kcRn82/f8dlfpQpjUC81f0 1CxasO58Lsc7EhrYv7LW2ZGcsLedeVghO2RFV4MFx9ouSK3rprnDf/LPi78FsdQxlsKK 47/e/Ie0IXxxLZFe+1u/l61yP56UDi6TVnUylwwE6YLs77EvTFJMu9ImUUiXBvzr85nE RPQA== 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 g4-20020a2eb0c4000000b0026b661c3e8dsi25655ljl.372.2022.09.08.15.29.29; Thu, 08 Sep 2022 15:29:57 -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 S229764AbiIHWOX (ORCPT + 99 others); Thu, 8 Sep 2022 18:14:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229728AbiIHWOW (ORCPT ); Thu, 8 Sep 2022 18:14:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C0051FB for ; Thu, 8 Sep 2022 15:14:21 -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 1892A61E2E for ; Thu, 8 Sep 2022 22:14:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70A82C433D6 for ; Thu, 8 Sep 2022 22:14:20 +0000 (UTC) Subject: [PATCH v4 7/8] NFSD: Make nfsd4_rename() wait before returning NFS4ERR_DELAY From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Thu, 08 Sep 2022 18:14:19 -0400 Message-ID: <166267525948.1842.17093479396791635591.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_rename() can kick off a CB_RECALL (via vfs_rename() -> leases_conflict()) 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_rename() again, once. This version of the patch handles renaming an existing file, but does not deal with renaming onto an existing file. That case will still always trigger an NFS4ERR_DELAY. Link: https://bugzilla.linux-nfs.org/show_bug.cgi?id=354 Tested-by: Igor Mammedov Signed-off-by: Chuck Lever --- fs/nfsd/vfs.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 03a826ccc165..b597cb2af949 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -1681,7 +1681,15 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen, .new_dir = tdir, .new_dentry = ndentry, }; - host_err = vfs_rename(&rd); + int retries; + + for (retries = 1;;) { + host_err = vfs_rename(&rd); + if (host_err != -EAGAIN || !retries--) + break; + if (!nfsd_wait_for_delegreturn(rqstp, d_inode(odentry))) + break; + } if (!host_err) { host_err = commit_metadata(tfhp); if (!host_err)