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: 13024991 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF0ADC38A02 for ; Sun, 30 Oct 2022 07:35:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229476AbiJ3Hf6 (ORCPT ); Sun, 30 Oct 2022 03:35:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230041AbiJ3Hfv (ORCPT ); Sun, 30 Oct 2022 03:35:51 -0400 X-Greylist: delayed 508 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sun, 30 Oct 2022 00:35:11 PDT Received: from smtp.smtpout.orange.fr (smtp-15.smtpout.orange.fr [80.12.242.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EF8D9CE26 for ; Sun, 30 Oct 2022 00:35:11 -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 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org '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);