Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp378705imn; Wed, 3 Aug 2022 07:45:12 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uyOi0RzP9xXbWfFNNJzo2dZ9d+AQ6CTeeTzVzKoMU2+fegEgxemQ7rHiu6Pw01vtZ+dhvN X-Received: by 2002:a17:907:2cf2:b0:72b:4a01:e8bb with SMTP id hz18-20020a1709072cf200b0072b4a01e8bbmr21078112ejc.673.1659537912451; Wed, 03 Aug 2022 07:45:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659537912; cv=none; d=google.com; s=arc-20160816; b=vFYvHYPBTtxFE2RPr3hNKGxUaD/sJABW8qCuo+Nc5ziKRh7E9eJc+2Op8I92twtv4m cNzvwY22FTTBTAqUP+ZVxjplG7iwUCzDpHIQhRidyUtf/IWa1J99NhO7jp1QA6YFyxKy XcWe7me4gyOCa2/N19yAz3hRx2m5dPvWPQTpwC8/1UtuDlQfXygMLTRb5lWX5LfkUGbj hhVgYRHRKc59npZeKwAqTgGB5tRfJ0sPLMTB9D1XtGOaaJ2IJJNVgS+/EzGKzNwwVA9w CEG+E7dSTVBumqqD81emD6BqwUjO5B2ILaqnGpFWu9jXqgz+3wIeMe8fb7AcNUVZQJFY /Ueg== 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:cc:to:from :subject; bh=LuIJTIBhVV7d0YNkm31MwxSC9abqXJASmOlTvASBPao=; b=VdHPf/qJr78QP/DsOpYelt6aRP8sWZHyZQbwxhpKLbg3HrdGROndIw2H8IqCXGN7fP EKUdc4JAIWSyhpJiLNrjJKB28X96metXQ2GWfHzHt5gjMJ++6P6+IypjB76VihITALNH VkfSfzVUqODyPWTmQHJTorkXJZm3QC9NqE1dxQWYJlLwUWbT1IQeFobO0Rny2wnpsPpn t8TIW75JTcXKkdF+XxTDArZ44/SK8Ymffc2ho5KawuwCHINLBk3YRHscI4jkKo7xIr5K Kh3BNKjDyaF2OUfzo5VWsZt+Gsv1Ruu3DgvouLmZE2ZifHLeDMVd2YEZb506QX3f8YO/ JWoA== 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 di17-20020a170906731100b0072a6e7a054dsi6473297ejc.975.2022.08.03.07.44.46; Wed, 03 Aug 2022 07:45:12 -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 S232747AbiHCOht (ORCPT + 99 others); Wed, 3 Aug 2022 10:37:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232079AbiHCOht (ORCPT ); Wed, 3 Aug 2022 10:37:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8269019C1D for ; Wed, 3 Aug 2022 07:37:48 -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 1DCA06164A for ; Wed, 3 Aug 2022 14:37:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58AA3C433C1; Wed, 3 Aug 2022 14:37:47 +0000 (UTC) Subject: [PATCH v2 3/3] NFSD: Make nfsd4_rename() wait before returning NFS4ERR_DELAY From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: imammedo@redhat.com Date: Wed, 03 Aug 2022 10:37:46 -0400 Message-ID: <165953746619.1658.12640644653566498600.stgit@manet.1015granger.net> In-Reply-To: <165953688893.1658.15242150042289528147.stgit@manet.1015granger.net> References: <165953688893.1658.15242150042289528147.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 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. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4proc.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 62a267bb2ce5..2e484aafc41c 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1056,17 +1056,32 @@ nfsd4_rename(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, { struct nfsd4_rename *rename = &u->rename; __be32 status; + int retries; if (opens_in_grace(SVC_NET(rqstp))) return nfserr_grace; - status = nfsd_rename(rqstp, &cstate->save_fh, rename->rn_sname, - rename->rn_snamelen, &cstate->current_fh, - rename->rn_tname, rename->rn_tnamelen); - if (status) - return status; - set_change_info(&rename->rn_sinfo, &cstate->current_fh); - set_change_info(&rename->rn_tinfo, &cstate->save_fh); - return nfs_ok; + + retries = 1; + do { + status = nfsd_rename(rqstp, &cstate->save_fh, rename->rn_sname, + rename->rn_snamelen, &cstate->current_fh, + rename->rn_tname, rename->rn_tnamelen); + if (status == nfs_ok) { + set_change_info(&rename->rn_sinfo, &cstate->current_fh); + set_change_info(&rename->rn_tinfo, &cstate->save_fh); + break; + } + if (status != nfserr_jukebox) + break; + if (!retries--) + break; + + fh_clear_pre_post_attrs(&cstate->save_fh); + fh_clear_pre_post_attrs(&cstate->current_fh); + nfsd4_wait_for_delegreturn(rqstp, &cstate->current_fh); + } while (1); + + return status; } static __be32