From patchwork Sun Oct 30 07:26:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 12936 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1682040wru; Sun, 30 Oct 2022 00:33:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5V3ugrfedwnytvNtmZG+PDdXKXnBFGafcjfvm7Z2DM92x16kNZF/MmKUZSeg9cnZSxestZ X-Received: by 2002:a17:902:6bc6:b0:183:e8a2:9760 with SMTP id m6-20020a1709026bc600b00183e8a29760mr8016501plt.157.1667115221070; Sun, 30 Oct 2022 00:33:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667115221; cv=none; d=google.com; s=arc-20160816; b=aRS8cUgOrb0Gd81/XQVPtjvn2WJqRu3zyF6JPqesoxU8LERYxu3WRazxvyVmQquRL1 7q/4Gokgh0IPiwjYuuQw0GOo0y8N3Rcw62kR063100ggi0xn9SiQ10eL5Frd2hR6agE1 w01fr88wkMA2wqSAcvdA8gpPvpbQqlaDiFkQug+P3ET945Cyuj5WA4g3KnhJs3ATjKHJ VK2eTAglLYuFnLDefFJRUoydSw0+6dmDY67+UqhCIpRbE4+nRA7uy6fAGKC0W2zqUchQ pbUVt1cpzqj/z36ciQ4N9r64sw6SE8B+qf8V4WYaPH0+3s6iDjelphFbj2FAyqx6NQAi VVLA== 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 :message-id:date:subject:cc:to:from; bh=FGnin7iaJF2yW82xlkFEoGMjvoKHbCYmnGo+AI/v+tY=; b=fgW5jLQwk2+BMWNn3711rPjJxLc1RtxcFIq6jUa8XaKfWdOzdUc/f+so+LzPtlbbsg ZRmsFHJZWB3edcnTYDhgxwQjGNhyo5cZ1wVlfOSbLSOqOjIsFxvA4pAD1Ji8wqVJ7j92 rSMW9Z+lL/EO1Udpwlot7dlbR74ZbkyJlJL+Qz0vlzE+VbOX9QTENetL3/oqvnA5yYDi PrywGz639zL48GVwbt3VkmbYh2vWmx0MsVFGvRxlnvGTT5+QelJ3jlOut/e927HJnfvj IXvdMMqyouF9gX+plOMuapvNlnnQxsRht3Pc5r/5FUkuruh1VcHSDwaNmePyWw06yEPk yfFA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k3-20020a170902c40300b00186e8526793si5493601plk.143.2022.10.30.00.33.28; Sun, 30 Oct 2022 00:33:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229886AbiJ3H0r (ORCPT + 99 others); Sun, 30 Oct 2022 03:26:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229862AbiJ3H0q (ORCPT ); Sun, 30 Oct 2022 03:26:46 -0400 Received: from smtp.smtpout.orange.fr (smtp-15.smtpout.orange.fr [80.12.242.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05F752C7 for ; Sun, 30 Oct 2022 00:26:43 -0700 (PDT) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id p2iPojcIb94emp2iPo27xg; Sun, 30 Oct 2022 08:26:42 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 30 Oct 2022 08:26:42 +0100 X-ME-IP: 86.243.100.34 From: Christophe JAILLET To: Chuck Lever , Jeff Layton , "J. Bruce Fields" , Dai Ngo Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-nfs@vger.kernel.org Subject: [PATCH] NFSD: Fix the share reservation conflict to courteous server logic in nfs4_upgrade_open() Date: Sun, 30 Oct 2022 08:26:39 +0100 Message-Id: <7ed2d8f1ee8c441a13b450c5e5c50f13fae3a2b9.1667114760.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748097010154019465?= X-GMAIL-MSGID: =?utf-8?q?1748097010154019465?= 'status != nfserr_share_denied' is known to be true because we test 'status == nfs_ok' the line just above. So nfs4_resolve_deny_conflicts_locked() can never be called. Fix the logic and avoid the dead code. Fixes: 3d6942715180 ("NFSD: add support for share reservation conflict to courteous server") Signed-off-by: Christophe JAILLET --- This patch is speculative. It is compile tested only. REVIEW WITH CARE. --- fs/nfsd/nfs4state.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 1ded89235111..de0565e9485c 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -5260,15 +5260,13 @@ nfs4_upgrade_open(struct svc_rqst *rqstp, struct nfs4_file *fp, spin_lock(&fp->fi_lock); status = nfs4_file_check_deny(fp, open->op_share_deny); if (status == nfs_ok) { - if (status != nfserr_share_denied) { - set_deny(open->op_share_deny, stp); - fp->fi_share_deny |= + set_deny(open->op_share_deny, stp); + fp->fi_share_deny |= (open->op_share_deny & NFS4_SHARE_DENY_BOTH); - } else { - if (nfs4_resolve_deny_conflicts_locked(fp, false, - stp, open->op_share_deny, false)) - status = nfserr_jukebox; - } + } else if (status == nfserr_share_denied) { + if (nfs4_resolve_deny_conflicts_locked(fp, false, stp, + open->op_share_deny, false)) + status = nfserr_jukebox; } spin_unlock(&fp->fi_lock);