Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp354157pxb; Mon, 16 Aug 2021 07:00:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4XuEgJAYzsUFARBxKDGMHFFkIid1Jd63LtQ5wVuEDbK2nc0BzfxlOCzfvmPZRUNayuFUj X-Received: by 2002:a17:906:38db:: with SMTP id r27mr16745467ejd.338.1629122454754; Mon, 16 Aug 2021 07:00:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629122454; cv=none; d=google.com; s=arc-20160816; b=jKIefi9kYxHdRY2pffk8v4VPPOhH5k/u5x6YI8OX8Q9eYw4cT/9rumfaolLFk+f5wY PB6zPo9QkrsCcfiAoOl9ukzrrDQBTbK23gCdp4F0eoq5r9CoXXxZIjrXklfXp6pxPUOZ PgiLDsoIzxz+xP7fr8EqjCEGXzHwJsWP8EvFhBfI+QcUF9wYuZ3U29YbbAahxh+Sg81I zEgLxp2zmLpOjB35eGQN3hPuT7j5OgaJz5oxekBCpXnpAHa3BvcKiCVRtgu2F4YidNZT ap0buhZp9HQHqn23+p+SXoGaDBkJsrff6JJ7GND/HfdmMwtgGSzbHgbNIkVhMBBfx+0O vZOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-filter; bh=aHtTgJs0OTmpE1wSXgL4n1E55T610dfoZhxbv/3dnFk=; b=DU5U9JnekrquCTHlKS8cYMgGWi8x13D6XxggojydL2nuzD0BD0mDGjcr+q+Jh2toUl bGQgzZDUZb+Afi6lQdTSBbax4bghFBp05PkeA/ZPGwB2k9vMMDVqQDZGhEvHeROi/XVl V0w7vuWuBWKGYld1hfKlyi8ruDLaFmP0xCz5Looy43WbZmebPSsbAQiWuxLbgEpwP1EK LbnXVwgqhsT7UruQCNSavSS8OWadorL6tkD5FC87sqj99/ScifjbiQ4AecYj8vb+fWMD 79F+BbS37cQz55hHlWYnso0cOQTFihkzJCEzU9lOp36OOmypqe7Phw256QGANSodw6bb vIGA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ne20si11017654ejc.429.2021.08.16.07.00.28; Mon, 16 Aug 2021 07:00:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231656AbhHPOAu (ORCPT + 99 others); Mon, 16 Aug 2021 10:00:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231768AbhHPOAX (ORCPT ); Mon, 16 Aug 2021 10:00:23 -0400 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E716DC06129F for ; Mon, 16 Aug 2021 06:59:30 -0700 (PDT) Received: by fieldses.org (Postfix, from userid 2815) id 89995620D; Mon, 16 Aug 2021 09:59:28 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org 89995620D From: "J. Bruce Fields" To: Trond Myklebust , Anna Schumaker Cc: daire@dneg.com, linux-nfs@vger.kernel.org, "J. Bruce Fields" Subject: [PATCH 8/8] nfs: don't allow reexport reclaims Date: Mon, 16 Aug 2021 09:59:27 -0400 Message-Id: <1629122367-18541-9-git-send-email-bfields@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1629122367-18541-1-git-send-email-bfields@redhat.com> References: <1629122367-18541-1-git-send-email-bfields@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: "J. Bruce Fields" In the reexport case, nfsd is currently passing along locks with the reclaim bit set. The client sends a new lock request, which is granted if there's currently no conflict--even if it's possible a conflicting lock could have been briefly held in the interim. We don't currently have any way to safely grant reclaim, so for now let's just deny them all. I'm doing this by passing the reclaim bit to nfs and letting it fail the call, with the idea that eventually the client might be able to do something more forgiving here. Signed-off-by: J. Bruce Fields --- fs/nfs/file.c | 3 +++ fs/nfsd/nfs4state.c | 3 +++ fs/nfsd/nfsproc.c | 1 + include/linux/errno.h | 1 + include/linux/fs.h | 1 + 5 files changed, 9 insertions(+) diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 1fef107961bc..7411658f8b05 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -806,6 +806,9 @@ int nfs_lock(struct file *filp, int cmd, struct file_lock *fl) nfs_inc_stats(inode, NFSIOS_VFSLOCK); + if (fl->fl_flags & FL_RECLAIM) + return -ENOGRACE; + /* No mandatory locks over NFS */ if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK) goto out_err; diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index bebe86cce7c7..212f43fa5cba 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -6903,6 +6903,9 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, if (!locks_in_grace(net) && lock->lk_reclaim) goto out; + if (lock->lk_reclaim) + fl_flags |= FL_RECLAIM; + fp = lock_stp->st_stid.sc_file; switch (lock->lk_type) { case NFS4_READW_LT: diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c index 60d7c59e7935..90fcd6178823 100644 --- a/fs/nfsd/nfsproc.c +++ b/fs/nfsd/nfsproc.c @@ -881,6 +881,7 @@ nfserrno (int errno) { nfserr_serverfault, -ENFILE }, { nfserr_io, -EUCLEAN }, { nfserr_perm, -ENOKEY }, + { nfserr_no_grace, -ENOGRACE}, }; int i; diff --git a/include/linux/errno.h b/include/linux/errno.h index d73f597a2484..8b0c754bab02 100644 --- a/include/linux/errno.h +++ b/include/linux/errno.h @@ -31,5 +31,6 @@ #define EJUKEBOX 528 /* Request initiated, but will not complete before timeout */ #define EIOCBQUEUED 529 /* iocb queued, will get completion event */ #define ERECALLCONFLICT 530 /* conflict with recalled state */ +#define ENOGRACE 531 /* NFS file lock reclaim refused */ #endif diff --git a/include/linux/fs.h b/include/linux/fs.h index 640574294216..1f5c3dbce1da 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -997,6 +997,7 @@ static inline struct file *get_file(struct file *f) #define FL_UNLOCK_PENDING 512 /* Lease is being broken */ #define FL_OFDLCK 1024 /* lock is "owned" by struct file */ #define FL_LAYOUT 2048 /* outstanding pNFS layout */ +#define FL_RECLAIM 4096 /* reclaiming from a reboot server */ #define FL_CLOSE_POSIX (FL_POSIX | FL_CLOSE) -- 2.31.1