From nobody Wed Apr 8 21:39:10 2026 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 26C31FA3742 for ; Sun, 30 Oct 2022 07:26:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229895AbiJ3H0r (ORCPT ); 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 'status !=3D nfserr_share_denied' is known to be true because we test 'status =3D=3D 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 c= ourteous 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 nf= s4_file *fp, spin_lock(&fp->fi_lock); status =3D nfs4_file_check_deny(fp, open->op_share_deny); if (status =3D=3D nfs_ok) { - if (status !=3D nfserr_share_denied) { - set_deny(open->op_share_deny, stp); - fp->fi_share_deny |=3D + set_deny(open->op_share_deny, stp); + fp->fi_share_deny |=3D (open->op_share_deny & NFS4_SHARE_DENY_BOTH); - } else { - if (nfs4_resolve_deny_conflicts_locked(fp, false, - stp, open->op_share_deny, false)) - status =3D nfserr_jukebox; - } + } else if (status =3D=3D nfserr_share_denied) { + if (nfs4_resolve_deny_conflicts_locked(fp, false, stp, + open->op_share_deny, false)) + status =3D nfserr_jukebox; } spin_unlock(&fp->fi_lock); =20 --=20 2.34.1