Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1201162rwn; Thu, 8 Sep 2022 15:22:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR6El2czF1J8/Xpcgb7B2cgCO/vfpF0kYyLMhKhTH6vJGBHWFqCascdS8um/Yed9xEMOLoOk X-Received: by 2002:a17:90a:ba01:b0:200:8769:1c34 with SMTP id s1-20020a17090aba0100b0020087691c34mr6436171pjr.0.1662675722179; Thu, 08 Sep 2022 15:22:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662675722; cv=none; d=google.com; s=arc-20160816; b=zzIH5+OVxKVaUSTJsd/UqPaHGkszVLT0SrbWQKtiARupn5ndB3jL4KtbFzGNeJWUgj 3NieyngSkHetzJ97OlUatQ1zDFbQQcl7zlFTGOMcAkFpQuEUY60tR11cArOMxyFPCKR4 9sb74/+3tdnyvEaztQ9GLxwbtPl5cc+7zh6lB6kDhayKl1f7GNyhXnm49NsJh8jswUfN dvhCRTPPAhT/4M6hxK+UAiZM/Vfugocenk+RKMEsK/SjLOJ3TwWIgNQktkAYIycuRBZY MFEZNhzEjBX9XnIhVu3BR/DZJmcrHHnUaMTgW+hWo0aVNuHsCAXUsADDc0VfqGvq5EMz N9tA== 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=3dyU40YfguYpRJSZPD2Yl53NYPqyeh+reHLWSFobzYQ=; b=noLmFUR7umDADH77xj6/6pzJu6NcWxmqxRf6PPvKVLN+fR05nFNqI8vhlFMSaUjSst +Ra31DchXLOVjIZBG/uihny4yCZGD3Ds1ZKI8IYGjco5ce8FT6M2zyDeuQ8r84ERHwfF AXo7G+OoKUouf9yywt8ZBE/mG74jfxgyeVxuP+aMVIlUga3bgbBy4t3hb5srNeF3QhgU cFDaQYa3pm532bx9c5/IU9GyEC3P8KjMG+fNuCGg91WwJ6ltCUHSwFy6xs1rz0td8qu6 OrofCAKlnRq/TD3/41HG+/TdAWILDaWIXb2blr3B9VyBts6uqbnKgtH+jUsZjVU4pFYf pqhA== 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 ob3-20020a17090b390300b002009afa00d7si192339pjb.175.2022.09.08.15.21.39; Thu, 08 Sep 2022 15:22:02 -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 S229728AbiIHWOa (ORCPT + 99 others); Thu, 8 Sep 2022 18:14:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229891AbiIHWO3 (ORCPT ); Thu, 8 Sep 2022 18:14:29 -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 B5FC0F0F for ; Thu, 8 Sep 2022 15:14:27 -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 53E7B61D99 for ; Thu, 8 Sep 2022 22:14:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A783BC433C1 for ; Thu, 8 Sep 2022 22:14:26 +0000 (UTC) Subject: [PATCH v4 8/8] NFSD: Make nfsd4_remove() wait before returning NFS4ERR_DELAY From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Thu, 08 Sep 2022 18:14:25 -0400 Message-ID: <166267526571.1842.11502743715868609327.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_unlink() can kick off a CB_RECALL (via vfs_unlink() -> 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_unlink() 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 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index b597cb2af949..adb2624eca64 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -1773,9 +1773,18 @@ nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, fh_fill_pre_attrs(fhp); if (type != S_IFDIR) { + int retries; + if (rdentry->d_sb->s_export_op->flags & EXPORT_OP_CLOSE_BEFORE_UNLINK) nfsd_close_cached_files(rdentry); - host_err = vfs_unlink(&init_user_ns, dirp, rdentry, NULL); + + for (retries = 1;;) { + host_err = vfs_unlink(&init_user_ns, dirp, rdentry, NULL); + if (host_err != -EAGAIN || !retries--) + break; + if (!nfsd_wait_for_delegreturn(rqstp, rinode)) + break; + } } else { host_err = vfs_rmdir(&init_user_ns, dirp, rdentry); }