Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1574424pxb; Thu, 16 Sep 2021 10:11:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9DRQZLKoz71CyN1YMwH1PHTSWyrmmBvNC49mV/mAysufAuHPKhDT/9nvjQlyC4eYuWFmH X-Received: by 2002:a17:907:75ca:: with SMTP id jl10mr7477853ejc.302.1631812301122; Thu, 16 Sep 2021 10:11:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631812301; cv=none; d=google.com; s=arc-20160816; b=Bt2WJEy6Bd9c+B0SFiRSPowLOMEUgtnTQkYz1aeCMgNvRtCh1Blw2WyfpVcOMuDmW1 7N+wc89G9L5aqjfbXuyRD+1KEenJKBALuEZr8SoXUHyA7gXTplTUYDS4S1WYn+nwRYof 0VckYmXUiGopYJMwfLB6FJiYgpPtRPV9g5128u6/CVSM+7ICs7p4KczTMs4kykTihkX/ 1m+9CXFGP8H0sJLklGwa94uaaZ5U9nu8n+IokEj0ix0H9EHqlUqDxcDy9/M/BvVyrs+t wd5mM81EreyaS7pi17R/XGizfZgfBHvyNNyK5sy5LV5icpGgKDl1hXRV2mZz6d8Dq7QR 3D7w== 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:subject:cc:to :from:dkim-signature; bh=gsXYcVzcxv9WdTlCSKwuIsCwBkNZM8+TF9PrB9L5xW8=; b=wbWxWa0PUigdq8KcIrNbw/B6YvawCfJZIiT4qMVT+xVOkya9Y8euUSSMBCl8DpomuN Hr1zkPrfuf7ivw2Uqq44wz/XMAz1C/Wjy734c9J3Ci7OIU3gUgmq871dlwsuPTOEJKf3 RrD6k29oKAcNyRA0cBaYUkXJb+d0/1V3cB/42AVsEy72Lthr8QsiaX6QPe8Hi2zzZDCT LVMfysEvExOmajhzMSi8MH2Yhax57FOuFN7M2aQN9LFUlDivhmIkxJsotr/FmxuVAv04 gzvvMx3aZIIwr9EfK583RtTsJEA++fXgoFWpm4h7jnSGgZzeZclrzKYH0sZXC3L4ydsc ECPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=S3nvnb41; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i11si5247686edb.471.2021.09.16.10.11.15; Thu, 16 Sep 2021 10:11:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=S3nvnb41; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344954AbhIPRKT (ORCPT + 99 others); Thu, 16 Sep 2021 13:10:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:55314 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347194AbhIPQ6O (ORCPT ); Thu, 16 Sep 2021 12:58:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D8F0260FDA; Thu, 16 Sep 2021 16:31:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631809897; bh=vkYMu+dPWMQdhEJAxzhhOqCVwB0RUJL1EkParM8RUvQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S3nvnb41jV8GIgK404LRnEXuic4sXICNoybE1N3GExELYnp8yddMELbxW4lPUuh4q RjvNBaAz4cTeD1FEV8zGalqj595insHz8KqeCooG/LyFfjdb6KekWXEEU0mGnyG08U BWhA54hFPactNhODfzei8svefjbBfyjT9duW1NSg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "J. Bruce Fields" , Anna Schumaker , Chuck Lever , Sasha Levin Subject: [PATCH 5.13 324/380] nfs: dont atempt blocking locks on nfs reexports Date: Thu, 16 Sep 2021 18:01:21 +0200 Message-Id: <20210916155815.062565265@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155803.966362085@linuxfoundation.org> References: <20210916155803.966362085@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: J. Bruce Fields [ Upstream commit f657f8eef3ff870552c9fd2839e0061046f44618 ] NFS implements blocking locks by blocking inside its lock method. In the reexport case, this blocks the nfs server thread, which could lead to deadlocks since an nfs server thread might be required to unlock the conflicting lock. It also causes a crash, since the nfs server thread assumes it can free the lock when its lm_notify lock callback is called. Ideal would be to make the nfs lock method return without blocking in this case, but for now it works just not to attempt blocking locks. The difference is just that the original client will have to poll (as it does in the v4.0 case) instead of getting a callback when the lock's available. Signed-off-by: J. Bruce Fields Acked-by: Anna Schumaker Signed-off-by: Chuck Lever Signed-off-by: Sasha Levin --- fs/nfs/export.c | 2 +- fs/nfsd/nfs4state.c | 8 ++++++-- include/linux/exportfs.h | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/fs/nfs/export.c b/fs/nfs/export.c index 37a1a88df771..d772c20bbfd1 100644 --- a/fs/nfs/export.c +++ b/fs/nfs/export.c @@ -180,5 +180,5 @@ const struct export_operations nfs_export_ops = { .fetch_iversion = nfs_fetch_iversion, .flags = EXPORT_OP_NOWCC|EXPORT_OP_NOSUBTREECHK| EXPORT_OP_CLOSE_BEFORE_UNLINK|EXPORT_OP_REMOTE_FS| - EXPORT_OP_NOATOMIC_ATTR, + EXPORT_OP_NOATOMIC_ATTR|EXPORT_OP_SYNC_LOCKS, }; diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index ab81e8ae3265..938b54aa1aa9 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -6727,6 +6727,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct nfsd4_blocked_lock *nbl = NULL; struct file_lock *file_lock = NULL; struct file_lock *conflock = NULL; + struct super_block *sb; __be32 status = 0; int lkflg; int err; @@ -6748,6 +6749,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, dprintk("NFSD: nfsd4_lock: permission denied!\n"); return status; } + sb = cstate->current_fh.fh_dentry->d_sb; if (lock->lk_is_new) { if (nfsd4_has_session(cstate)) @@ -6796,7 +6798,8 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, fp = lock_stp->st_stid.sc_file; switch (lock->lk_type) { case NFS4_READW_LT: - if (nfsd4_has_session(cstate)) + if (nfsd4_has_session(cstate) && + !(sb->s_export_op->flags & EXPORT_OP_SYNC_LOCKS)) fl_flags |= FL_SLEEP; fallthrough; case NFS4_READ_LT: @@ -6808,7 +6811,8 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, fl_type = F_RDLCK; break; case NFS4_WRITEW_LT: - if (nfsd4_has_session(cstate)) + if (nfsd4_has_session(cstate) && + !(sb->s_export_op->flags & EXPORT_OP_SYNC_LOCKS)) fl_flags |= FL_SLEEP; fallthrough; case NFS4_WRITE_LT: diff --git a/include/linux/exportfs.h b/include/linux/exportfs.h index fe848901fcc3..3260fe714846 100644 --- a/include/linux/exportfs.h +++ b/include/linux/exportfs.h @@ -221,6 +221,8 @@ struct export_operations { #define EXPORT_OP_NOATOMIC_ATTR (0x10) /* Filesystem cannot supply atomic attribute updates */ +#define EXPORT_OP_SYNC_LOCKS (0x20) /* Filesystem can't do + asychronous blocking locks */ unsigned long flags; }; -- 2.30.2