From patchwork Wed Oct 23 23:55:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11208059 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5137D13BD for ; Wed, 23 Oct 2019 23:58:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 27B852084C for ; Wed, 23 Oct 2019 23:58:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aywqOgpj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726986AbfJWX6L (ORCPT ); Wed, 23 Oct 2019 19:58:11 -0400 Received: from mail-il1-f194.google.com ([209.85.166.194]:44487 "EHLO mail-il1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725852AbfJWX6L (ORCPT ); Wed, 23 Oct 2019 19:58:11 -0400 Received: by mail-il1-f194.google.com with SMTP id f13so20628939ils.11 for ; Wed, 23 Oct 2019 16:58:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=JHWq1+nQ3vKrCj1F2y6oUgBDKRRyOYQaLQciB12XliA=; b=aywqOgpjubZhIVDtyLSKjSbQifGTNhYfUsfiT5NlU/0TySC2EOmHslp2wK0IaM/xrN y0rGdzXol1YJIcqZMh4dtOD+GZv8iw7pY+KkrmD3g4nQSE0SE6ni/ZhRQLEy42vSsNan vM6INfOXYfoJwH3qL5mrsjhGzI3ePZtDtXsCqHMRoT7lUVtyD5piBwoSy14XCISBbUHY FdOs3sX8KndOc0JS5nYeGSjj2xw6yTg8RQBaLNs9TODQbdOJA9cDX2lg1N2aP5QSQnr4 ZJQj8OcIQw5kUVygiiCmbHczi1b3AHzgenNwplYhs2FXrJpgjSrNs6xUgKBm+PTjOfFq Xo4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JHWq1+nQ3vKrCj1F2y6oUgBDKRRyOYQaLQciB12XliA=; b=E3rM8XFzMWlJdVQnage+7keW4gqz0ELbpImPEZwLqvjaluFl7PDWCHRMqq0wuSeLbA J86GCKcKo7sQPLF93H58yQ2Y70TiXs2tPQesob//Q5U9QfovTvCg2syKXmwF+VjPggfh jBenaleE9w1wIBaOXFRULKop4GhHx11ruKMceY19qk9ZAuLtFKVV+w4FzKaRTXtALqZA strrYAViwf8Oax01D3ZH797DdKmCT+3BU1Uqirg5sBDRthx0SG4kIoIUp58Djli6hcdo nTrgvu/T5BgApHKZ5Tq8bCjenvZS9tNWxmZ/pWMmn0nowQgDRF68wqsfgCYdjznMEYyo r5kA== X-Gm-Message-State: APjAAAXZVJCHSK7TzKnNOnXvc+FzNvn8WZla6QucGr0GCxVDvfTzV+Nu StYKrXY0pV4hpdlspRqUoLLiyXQ= X-Google-Smtp-Source: APXvYqwpQ8elE/BR6UkRN5kky/PLDdL4+DfsO02V/a7tVI4XSEOQ5dEg9NuIt7jfd8bsPGohMXTyCA== X-Received: by 2002:a92:3985:: with SMTP id h5mr22755189ilf.251.1571875090121; Wed, 23 Oct 2019 16:58:10 -0700 (PDT) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id z18sm2405409iob.47.2019.10.23.16.58.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 16:58:09 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 01/14] NFSv4: Don't allow a cached open with a revoked delegation Date: Wed, 23 Oct 2019 19:55:47 -0400 Message-Id: <20191023235600.10880-2-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191023235600.10880-1-trond.myklebust@hammerspace.com> References: <20191023235600.10880-1-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If the delegation is marked as being revoked, we must not use it for cached opens. Fixes: 869f9dfa4d6d ("NFSv4: Fix races between nfs_remove_bad_delegation() and delegation return") Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 3 +-- fs/nfs/delegation.h | 1 + fs/nfs/nfs4proc.c | 6 +----- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 071b90a45933..5f3eea926af5 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -42,8 +42,7 @@ void nfs_mark_delegation_referenced(struct nfs_delegation *delegation) set_bit(NFS_DELEGATION_REFERENCED, &delegation->flags); } -static bool -nfs4_is_valid_delegation(const struct nfs_delegation *delegation, +bool nfs4_is_valid_delegation(const struct nfs_delegation *delegation, fmode_t flags) { if (delegation != NULL && (delegation->type & flags) == flags && diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h index 9eb87ae4c982..2b35a99929a0 100644 --- a/fs/nfs/delegation.h +++ b/fs/nfs/delegation.h @@ -69,6 +69,7 @@ bool nfs4_copy_delegation_stateid(struct inode *inode, fmode_t flags, nfs4_state bool nfs4_refresh_delegation_stateid(nfs4_stateid *dst, struct inode *inode); void nfs_mark_delegation_referenced(struct nfs_delegation *delegation); +bool nfs4_is_valid_delegation(const struct nfs_delegation *delegation, fmode_t flags); int nfs4_have_delegation(struct inode *inode, fmode_t flags); int nfs4_check_delegation(struct inode *inode, fmode_t flags); bool nfs4_delegation_flush_on_close(const struct inode *inode); diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index ab8ca20fd579..294ea8c1a163 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -1436,11 +1436,7 @@ static int can_open_cached(struct nfs4_state *state, fmode_t mode, static int can_open_delegated(struct nfs_delegation *delegation, fmode_t fmode, enum open_claim_type4 claim) { - if (delegation == NULL) - return 0; - if ((delegation->type & fmode) != fmode) - return 0; - if (test_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) + if (!nfs4_is_valid_delegation(delegation, fmode)) return 0; switch (claim) { case NFS4_OPEN_CLAIM_NULL: From patchwork Wed Oct 23 23:55:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11208063 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B623F1390 for ; Wed, 23 Oct 2019 23:58:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 94C892084C for ; Wed, 23 Oct 2019 23:58:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iq2Sc6U+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388872AbfJWX6N (ORCPT ); Wed, 23 Oct 2019 19:58:13 -0400 Received: from mail-il1-f194.google.com ([209.85.166.194]:33508 "EHLO mail-il1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725852AbfJWX6M (ORCPT ); Wed, 23 Oct 2019 19:58:12 -0400 Received: by mail-il1-f194.google.com with SMTP id v2so20669730ilm.0 for ; Wed, 23 Oct 2019 16:58:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=UQJtG0eF3ROCDcYr9wQJYVSG7YUZRmSPD3to91dvFSk=; b=iq2Sc6U+KcNW4lr49M4x33ApWffbZnqoIRNeSkFmUwFV+2zPZDGHpuJ0tNncqDHH3r NSmd6GOaxp5SVaH4AmZ2lUSLNLl3RETo5h/s5Pkhwibeo1gs4OrFr/XgXXqXrr2BS+3M hQsDI46K2CDQfYZk3j4grU+rcSaIlGmlszcHzV86NTaZ0+GyNvjpAEmDQGaaWUZbhIzV Pw4Cj7SSouS9yekaUnpJ6diZc/3Xt3CTQV+LnxPlcY40CXcfEGXwtn1ZTTKYKrPrUSEg 3QL6Ypqhv8RYaQsotXhL+mf+n9ilQf/x7Tp9kahmui4I8H2H5MAcifpbNYwj82oEXutF 4Z2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UQJtG0eF3ROCDcYr9wQJYVSG7YUZRmSPD3to91dvFSk=; b=ZS7AtDTCquap4YK00XgncEaiolrtmjMGJVUhPT0B3FDavFmKEbCGsRyrIaNuMlf9oQ YL1eBt46sQuevf2t6nd6EN/4sOg+VYTY5oY5x9eyqShtHUBTBcNAwPBmCJfr3Idf13lD 8SvwXaR50nLRO6NW2pmxSexjp0tam+9yVqaXxB2mWz5ty5nMs3YsKPx0PKa2p6M6xHSB 9ldXqDXYDEp66TN5ejCIgZVnbEGypzuaztGznVoud0/4WhFoxjryyA7IW5RTbQPQWDB6 FA2Go6Z6+6wMjv6OgOdna+yc7AglKYQTAOgrY26tlc+z+0XGvanoAVcg0p185SniuJFx vXQQ== X-Gm-Message-State: APjAAAULP0YiEA6aEsz3FOMYYptx7a+HtrlS5dydnR0DwYe0e0iSXXW7 LAspsUiekIayeCajU+Dd4Ok5VAY= X-Google-Smtp-Source: APXvYqz9RA4lBtZKECl+AkEg56FIkR7KNF6SS0f2szufNHQSijA+7Wt61iuEKTqRcxS8eycN+fcdsA== X-Received: by 2002:a92:980f:: with SMTP id l15mr14130641ili.152.1571875091277; Wed, 23 Oct 2019 16:58:11 -0700 (PDT) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id z18sm2405409iob.47.2019.10.23.16.58.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 16:58:10 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 02/14] NFSv4: Fix delegation handling in update_open_stateid() Date: Wed, 23 Oct 2019 19:55:48 -0400 Message-Id: <20191023235600.10880-3-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191023235600.10880-2-trond.myklebust@hammerspace.com> References: <20191023235600.10880-1-trond.myklebust@hammerspace.com> <20191023235600.10880-2-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If the delegation is marked as being revoked, then don't use it in the open state structure. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 294ea8c1a163..c407e2eed3d5 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -1740,14 +1740,12 @@ static int update_open_stateid(struct nfs4_state *state, goto no_delegation; spin_lock(&deleg_cur->lock); - if (rcu_dereference(nfsi->delegation) != deleg_cur || - test_bit(NFS_DELEGATION_RETURNING, &deleg_cur->flags) || - (deleg_cur->type & fmode) != fmode) + if (!nfs4_is_valid_delegation(deleg_cur, fmode)) goto no_delegation_unlock; if (delegation == NULL) delegation = &deleg_cur->stateid; - else if (!nfs4_stateid_match(&deleg_cur->stateid, delegation)) + else if (!nfs4_stateid_match_other(&deleg_cur->stateid, delegation)) goto no_delegation_unlock; nfs_mark_delegation_referenced(deleg_cur); From patchwork Wed Oct 23 23:55:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11208067 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0629A13BD for ; Wed, 23 Oct 2019 23:58:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D90752084C for ; Wed, 23 Oct 2019 23:58:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jFWMUQO4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404604AbfJWX6P (ORCPT ); Wed, 23 Oct 2019 19:58:15 -0400 Received: from mail-il1-f193.google.com ([209.85.166.193]:36014 "EHLO mail-il1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404433AbfJWX6P (ORCPT ); Wed, 23 Oct 2019 19:58:15 -0400 Received: by mail-il1-f193.google.com with SMTP id s75so10887479ilc.3 for ; Wed, 23 Oct 2019 16:58:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=tn1GwUnFN+9fNysXf8S2SeglI6pzUZKhCexEJ7h+6JM=; b=jFWMUQO4iG6BAeP2LghwOjIOfJkOO5UdcdPwbZxVi7wOjGZwVIlVZqKMxGm4ZqwTDB RDGu7hC9VEV/C79cfTN4KB+tS0rZjP0vfnxgjbKAVz0QPaSHbeoVOBY1+5SCenj6rcRT Xy5LcWzKQS6gCXkZfRrzFLMD/rW509XWKDmWwLm4Qxm81SrkfZLYAdpvEwBx4bQSEpOU q8GBD1GPrGR2vu7MsyQlBKeQXVIJoMCupYpya7MT4IMihZe0QB40/YxOmpWbsvEmyH2X +F79JB4WU4eB2YIt2Md/0FlBYSVtoygHpQ420Jt/eGmP80ljRNrHP3AYTL62bMLlj7bL o6Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tn1GwUnFN+9fNysXf8S2SeglI6pzUZKhCexEJ7h+6JM=; b=TkROl1cl/wNoPOxOQwozMrLcDp5h9uMJYtLWW/5uxGC3GDWCHxkbzoPXtuWmtqgzXm vmNXeH2QuSdmbYYtjWcKXnFR/E8HtiiSnS5xLs6S69JxvCq6MhAUHYL/mu5IIYoPeXcR D0Mij45GZ+NUunIAounylJfV7AcINJ+d6siBnMjLohipLL4GPGcytrnwTkXP8f4K6UnO pCX4z2jJ9v1rEOIzoRAuf8EOShk0P94Qqq+Mf5RLiXSdt8997px2OH/3PdTH0+umqhdw vfks9HpqouizgCeLnYNHg/qUZxuM/7MLV5PaC8Tyo4MbGeHnlxW0GoQBk0JT39IzSK8t TtoA== X-Gm-Message-State: APjAAAUgoMNPkwmKv3cUp4rQcS5JcFeUY0nQZO8xmraV/iINOR1XXPx6 4Mbt+GskcNrXWyUrxFb5fVlGCjQ= X-Google-Smtp-Source: APXvYqyXMIOU0pL/xD2PrcnVkIyoy04qp08VWhXRc4V3+lVvuJz4VS7R+5SXkeZzjH5AZS6itmo60g== X-Received: by 2002:a92:9f85:: with SMTP id z5mr22275395ilk.214.1571875091984; Wed, 23 Oct 2019 16:58:11 -0700 (PDT) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id z18sm2405409iob.47.2019.10.23.16.58.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 16:58:11 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 03/14] NFSv4: nfs4_callback_getattr() should ignore revoked delegations Date: Wed, 23 Oct 2019 19:55:49 -0400 Message-Id: <20191023235600.10880-4-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191023235600.10880-3-trond.myklebust@hammerspace.com> References: <20191023235600.10880-1-trond.myklebust@hammerspace.com> <20191023235600.10880-2-trond.myklebust@hammerspace.com> <20191023235600.10880-3-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If the delegation has been revoked, ignore it. Signed-off-by: Trond Myklebust --- fs/nfs/callback_proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c index db3e7771e597..58a77c41ff36 100644 --- a/fs/nfs/callback_proc.c +++ b/fs/nfs/callback_proc.c @@ -50,7 +50,7 @@ __be32 nfs4_callback_getattr(void *argp, void *resp, nfsi = NFS_I(inode); rcu_read_lock(); delegation = rcu_dereference(nfsi->delegation); - if (delegation == NULL || (delegation->type & FMODE_WRITE) == 0) + if (!nfs4_is_valid_delegation(delegation, FMODE_WRITE)) goto out_iput; res->size = i_size_read(inode); res->change_attr = delegation->change_attr; From patchwork Wed Oct 23 23:55:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11208065 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 48A6313BD for ; Wed, 23 Oct 2019 23:58:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 260AD2084C for ; Wed, 23 Oct 2019 23:58:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="O7j6RCVE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392808AbfJWX6O (ORCPT ); Wed, 23 Oct 2019 19:58:14 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:44608 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725852AbfJWX6O (ORCPT ); Wed, 23 Oct 2019 19:58:14 -0400 Received: by mail-io1-f66.google.com with SMTP id w12so27189907iol.11 for ; Wed, 23 Oct 2019 16:58:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=qubh+bjzZm2oRJ17euw6moPDnTcR50x5U/G07rZbOqo=; b=O7j6RCVEWiVX5K8REElseAOmx6JaFro0G19e/klH1BQQEhDkz7DPcndD7GdT2V2rfJ v6WGyKPRnvpy9zN+uCUuzrjI1Z6bEIwQQVGt4xfn/Ez/y8Dnz5NP4i4tPzsAccOHsEl+ t1KW2Uh2VH2/pijbPt/h+C1gH4ugAmME/yZfd5bZxYL3ZZNbuyS09pXpwih4eHTrE2ht CnMlApBCuoJa+7tMA4tfur0ghcsZ/0HvdBEkKk+TLHelbjErYB9LQH1MsQr4iooWMaP6 5a1IdgnGQrf28mH6crwYV0weyCL1YeS+BHKDA9QFlJ54abAxTdYxJH7PMj0qiSIBkod6 hrLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qubh+bjzZm2oRJ17euw6moPDnTcR50x5U/G07rZbOqo=; b=dPE8JoOs6LK+B0JJZUue5Ysp+lMg6TEr1rOuoeOTkgysS6vDA5OVqJnxAeyg6KM61C l7HTYim+wBiNeUdbxJce58w1PAt2ZiAYIfel5hjceYKsAbt/yBjwQXeo7A5bkH57axj8 D8z/erWVVwRa88S9m/CiARHFbI3bRtDSVNog62leCObWeYPTzZc+IyYo4Ya1IwsgiCeC gtO/sx4OIEMSqtbWpChEN15AJglPddfAXUW2a2KjNS4GdMRuRJFiRB2L41DNBsK702Oi t95mhBLyDvQ8yVlsv3XphTW6HIsAM/Ytmj0oIPRv/geVOYNLmmma35CBv/c+osoNteUq tosg== X-Gm-Message-State: APjAAAUqN/c9kPpGlXCzGuCsAwW+TrfHxL+YLFLmtOQfPBQmQumVI7Ev zpxZ6QWYSOnFqeDjLXtgnncGLRo= X-Google-Smtp-Source: APXvYqxlH+eHcaec5sdghlqns3z95I8e2+cp3dIUe6ByhHaxB05x1oOSeqcAeHFAqI3+X9Oizm02nQ== X-Received: by 2002:a6b:4405:: with SMTP id r5mr6315346ioa.177.1571875092591; Wed, 23 Oct 2019 16:58:12 -0700 (PDT) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id z18sm2405409iob.47.2019.10.23.16.58.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 16:58:12 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 04/14] NFSv4: Delegation recalls should not find revoked delegations Date: Wed, 23 Oct 2019 19:55:50 -0400 Message-Id: <20191023235600.10880-5-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191023235600.10880-4-trond.myklebust@hammerspace.com> References: <20191023235600.10880-1-trond.myklebust@hammerspace.com> <20191023235600.10880-2-trond.myklebust@hammerspace.com> <20191023235600.10880-3-trond.myklebust@hammerspace.com> <20191023235600.10880-4-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If we're processsing a delegation recall, ignore the delegations that have already been revoked or returned. Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 5f3eea926af5..4bc40c27141b 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -830,7 +830,7 @@ int nfs_async_inode_return_delegation(struct inode *inode, rcu_read_lock(); delegation = rcu_dereference(NFS_I(inode)->delegation); - if (delegation == NULL) + if (!nfs4_is_valid_delegation(delegation, FMODE_READ)) goto out_enoent; if (stateid != NULL && !clp->cl_mvops->match_stateid(&delegation->stateid, stateid)) @@ -855,6 +855,7 @@ nfs_delegation_find_inode_server(struct nfs_server *server, list_for_each_entry_rcu(delegation, &server->delegations, super_list) { spin_lock(&delegation->lock); if (delegation->inode != NULL && + !test_bit(NFS_DELEGATION_REVOKED, &delegation->flags) && nfs_compare_fh(fhandle, &NFS_I(delegation->inode)->fh) == 0) { freeme = igrab(delegation->inode); if (freeme && nfs_sb_active(freeme->i_sb)) From patchwork Wed Oct 23 23:55:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11208069 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8895C1390 for ; Wed, 23 Oct 2019 23:58:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 67A822084C for ; Wed, 23 Oct 2019 23:58:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bfMFp1zE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725852AbfJWX6P (ORCPT ); Wed, 23 Oct 2019 19:58:15 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:35601 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392795AbfJWX6P (ORCPT ); Wed, 23 Oct 2019 19:58:15 -0400 Received: by mail-io1-f66.google.com with SMTP id t18so23078094iog.2 for ; Wed, 23 Oct 2019 16:58:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=nymVrAPiFMFWo6jqKaToF9wF79yeH0rY5WIe9SAR/I8=; b=bfMFp1zEhzYmHDGwjI8NJ9gD3o46yqKvh0LDk3b7+nlyfVwLOPVbsWLG12beTr0xGG z+oBuk7P9lZj6GL7rMg12nTlieP9jV6lTaUJvt4vOqlscJ71Orst9P3j9W4C/ViHyQVP mVt6esTk99uTC2VpcO88naR8Qiqr55wBCg3qt9jTmKI8kP0mCGA3UoSNHJmHNvKqPxPP M+aE6N5hdWhcW6eGcpcN+ACk0Saxuy22bdrOuoL21wfiJJD4LVlLWC2vgbt5FakZj6kF 28AAn94H9PJhXelekct397lwYCCsUkcerG2ie6aWWVyh8+7AapplJZGH/ZOUlrsR0UyJ ljyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nymVrAPiFMFWo6jqKaToF9wF79yeH0rY5WIe9SAR/I8=; b=HWmVHAKaRQOpHM9SCOOzESD5coBdUDw/7ClAwdGe5ep6Rl9Ts6UD+k2dD9VOwcLPFO +E3u5UVgnALyYGpG5DlXGl2nNzzS7UMzP6RfBgP+ox8MF3+VBtrEXG030oSZz4Blof4/ zP4NmfINLiwQaJ/YKwHJEhlNXF6UPIfT8ZJXe9SFqirYvmV2UOZKaAczbzEx1zmz8+tH UC6l0xYVBMgcCKR/FYDjX/a8WXMhKu/4Ufhgd6RMF9iU85bK7GzP+CZDsWsAPfoO47mF j+eQAmEbhJpZfpWTl5yUglUgbRb1cxh7A/OqJN0CfE2Vj+G+JcMj1zd2Jf8GQb3e32p9 eV/w== X-Gm-Message-State: APjAAAXh1fKVNKNyNGQXq2+GoVkGH7GM044HA8pi1iRK9TbWg1xAS377 p6MGLyt3Dsm0ozo6CwZ9bd/UNIk= X-Google-Smtp-Source: APXvYqzqvmxFPTUXRKTJTXEte3rCkk4c/ipWQMGu3tZGeSJQPAIvgEAEpEZZAt4duFuTfgzQBajUTg== X-Received: by 2002:a05:6602:1216:: with SMTP id y22mr6567877iot.16.1571875093387; Wed, 23 Oct 2019 16:58:13 -0700 (PDT) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id z18sm2405409iob.47.2019.10.23.16.58.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 16:58:12 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 05/14] NFSv4: fail nfs4_refresh_delegation_stateid() when the delegation was revoked Date: Wed, 23 Oct 2019 19:55:51 -0400 Message-Id: <20191023235600.10880-6-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191023235600.10880-5-trond.myklebust@hammerspace.com> References: <20191023235600.10880-1-trond.myklebust@hammerspace.com> <20191023235600.10880-2-trond.myklebust@hammerspace.com> <20191023235600.10880-3-trond.myklebust@hammerspace.com> <20191023235600.10880-4-trond.myklebust@hammerspace.com> <20191023235600.10880-5-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If the delegation was revoked, we don't want to retry the delegreturn. Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 4bc40c27141b..f90c3cf82f8f 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -1179,6 +1179,7 @@ bool nfs4_refresh_delegation_stateid(nfs4_stateid *dst, struct inode *inode) rcu_read_lock(); delegation = rcu_dereference(NFS_I(inode)->delegation); if (delegation != NULL && + !test_bit(NFS_DELEGATION_REVOKED, &delegation->flags) && nfs4_stateid_match_other(dst, &delegation->stateid)) { dst->seqid = delegation->stateid.seqid; return ret; From patchwork Wed Oct 23 23:55:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11208071 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE9EA1920 for ; Wed, 23 Oct 2019 23:58:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CD8722084C for ; Wed, 23 Oct 2019 23:58:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="W0BVL9Zt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404634AbfJWX6P (ORCPT ); Wed, 23 Oct 2019 19:58:15 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:36239 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404444AbfJWX6P (ORCPT ); Wed, 23 Oct 2019 19:58:15 -0400 Received: by mail-io1-f67.google.com with SMTP id c16so7350854ioc.3 for ; Wed, 23 Oct 2019 16:58:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=GB+oz+E3Tf2emfRr8xrOMGx0H/ELIDQcqTouy4vbLVg=; b=W0BVL9ZtR+8T2D+KxXiMSMXIn1iEhCJNMxDWDtHRG0s/PUKDlFCtDvpayOapt7umg1 1ZpABTrZDX/QezlkJlB5iYK/+EHe5Hs3XLYTxnrPoSirGPZ6kKFn8PpMLUeX5yDeXLV0 xaOnRTvM2crqCXk5djQHsAh5pnHvJoOW6IwiCZ090QXjo2701K/BeXkSlhYx7pGbevwH y6xhA/zjG5q1YWWXmUCWwVdHKwbI8mnUbS1e0joWq0/kIzGqlijWkati3OGdIGs7ELIp RhJHacue+JjuXF6gqXn1YoIu2gIzOCIdoJv7o1g9SNR3FcjFQZHnHUlysKuq41VUFt6p ikjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GB+oz+E3Tf2emfRr8xrOMGx0H/ELIDQcqTouy4vbLVg=; b=gTuYDPeswKyW1SNCrrxWJ6Okp+mSKKys/xZEo1L1KWHwOCZ4AhCyAykRUV/dh5bMJX MTkIX8IWsF7L0TcskeXaEV9RawORajJHzgUQqI1wheRuF2FW0KKLh0WFh2Kn0JysqLbh gLh2gD1nhuEnp+l5V0gq2uF1nUuUKAkgvdBjv75wCcrEt4GJaUh6xgMrxlaF+j7hFGHF Oc5gq8VctHXYvY7VwGttBFt54wLgpKdjGhUrTQ6UDCE9KLCO1x9Kh0nKQbF0HefC3Ztx Gjgl4JrqUOtfqb70SAucWxwjjk6T4klGAUGynrbUaDdqaIn4ee+88wbu8wpkU4/ogXTW p+/Q== X-Gm-Message-State: APjAAAWzBHUdMU1N+YqvkRRShe4ojFDStoxX1y5ho0YCjccuY5kNxX4y gT5PIsFGGMcCDZaKDAxxs80Otzo= X-Google-Smtp-Source: APXvYqxqJ+msqRGblyZZXUjrSsGvTRN+Lusx+Fawhz8j4d+mq+sELbNiasyym7qurexF4Mkwf3AQfQ== X-Received: by 2002:a6b:fa19:: with SMTP id p25mr240132ioh.125.1571875094215; Wed, 23 Oct 2019 16:58:14 -0700 (PDT) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id z18sm2405409iob.47.2019.10.23.16.58.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 16:58:13 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 06/14] NFS: Rename nfs_inode_return_delegation_noreclaim() Date: Wed, 23 Oct 2019 19:55:52 -0400 Message-Id: <20191023235600.10880-7-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191023235600.10880-6-trond.myklebust@hammerspace.com> References: <20191023235600.10880-1-trond.myklebust@hammerspace.com> <20191023235600.10880-2-trond.myklebust@hammerspace.com> <20191023235600.10880-3-trond.myklebust@hammerspace.com> <20191023235600.10880-4-trond.myklebust@hammerspace.com> <20191023235600.10880-5-trond.myklebust@hammerspace.com> <20191023235600.10880-6-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Rename nfs_inode_return_delegation_noreclaim() to nfs_inode_evict_delegation(), which better describes what it does. Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 11 +++++++---- fs/nfs/delegation.h | 2 +- fs/nfs/nfs4super.c | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index f90c3cf82f8f..e60737be6f26 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -574,19 +574,22 @@ int nfs_client_return_marked_delegations(struct nfs_client *clp) } /** - * nfs_inode_return_delegation_noreclaim - return delegation, don't reclaim opens + * nfs_inode_evict_delegation - return delegation, don't reclaim opens * @inode: inode to process * * Does not protect against delegation reclaims, therefore really only safe - * to be called from nfs4_clear_inode(). + * to be called from nfs4_clear_inode(). Guaranteed to always free + * the delegation structure. */ -void nfs_inode_return_delegation_noreclaim(struct inode *inode) +void nfs_inode_evict_delegation(struct inode *inode) { struct nfs_delegation *delegation; delegation = nfs_inode_detach_delegation(inode); - if (delegation != NULL) + if (delegation != NULL) { + set_bit(NFS_DELEGATION_INODE_FREEING, &delegation->flags); nfs_do_return_delegation(inode, delegation, 1); + } } /** diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h index 2b35a99929a0..9a14a7ca1df9 100644 --- a/fs/nfs/delegation.h +++ b/fs/nfs/delegation.h @@ -43,7 +43,7 @@ void nfs_inode_reclaim_delegation(struct inode *inode, const struct cred *cred, fmode_t type, const nfs4_stateid *stateid, unsigned long pagemod_limit); int nfs4_inode_return_delegation(struct inode *inode); int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid); -void nfs_inode_return_delegation_noreclaim(struct inode *inode); +void nfs_inode_evict_delegation(struct inode *inode); struct inode *nfs_delegation_find_inode(struct nfs_client *clp, const struct nfs_fh *fhandle); void nfs_server_return_all_delegations(struct nfs_server *); diff --git a/fs/nfs/nfs4super.c b/fs/nfs/nfs4super.c index 04c57066a11a..2c9cbade561a 100644 --- a/fs/nfs/nfs4super.c +++ b/fs/nfs/nfs4super.c @@ -92,8 +92,8 @@ static void nfs4_evict_inode(struct inode *inode) { truncate_inode_pages_final(&inode->i_data); clear_inode(inode); - /* If we are holding a delegation, return it! */ - nfs_inode_return_delegation_noreclaim(inode); + /* If we are holding a delegation, return and free it */ + nfs_inode_evict_delegation(inode); /* Note that above delegreturn would trigger pnfs return-on-close */ pnfs_return_layout(inode); pnfs_destroy_layout(NFS_I(inode)); From patchwork Wed Oct 23 23:55:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11208073 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6A4641390 for ; Wed, 23 Oct 2019 23:58:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 491FE2084C for ; Wed, 23 Oct 2019 23:58:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VXBBrlAM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404444AbfJWX6Q (ORCPT ); Wed, 23 Oct 2019 19:58:16 -0400 Received: from mail-il1-f196.google.com ([209.85.166.196]:33808 "EHLO mail-il1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404433AbfJWX6Q (ORCPT ); Wed, 23 Oct 2019 19:58:16 -0400 Received: by mail-il1-f196.google.com with SMTP id a13so6303580ilp.1 for ; Wed, 23 Oct 2019 16:58:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=+EtWcd+iPMrQx+J+zI9H8qCQS/FT6dcSSPMKFDxnKyI=; b=VXBBrlAMC9fgI8ECLKrNfrjC6R+sEeQaU3aSNkuRkWCj+2nQTzvSYZmTG+7xPjU63B 2Gmf3mC77y9xKmTXRcSVbDSbX4/iEFODCaX6+sBl4F4IhWjR53rtRaRMDwCxTf0t5TYy yaXzpGY8FGOrtJut1Tb9PkCZZkoiXl0j+MGgyZJsqTnVm8TUgdITFqxsZ8wWWx4ixDSn A8AtlXhqe/A3pDaNfvTqo/62a/gDFt99wZASILoC1tbEOvTTR7Z/mTX5xGOFbH8aPVte BcolLa1eELvMV/xdH2hPORDgErOq9mqmoOJAA/Kmi7/VcGMZbkS/lUnrunX+K2PHVmbZ xRWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+EtWcd+iPMrQx+J+zI9H8qCQS/FT6dcSSPMKFDxnKyI=; b=WI8lOQGSFqLpcks7eXsFBL6dTlvCSX9RV6zg5VNV9Rk6U2vHrZPzlSeKQ4z12UWaTI tvrJ+wE/v4l3S5clSpYeEl9cFnJJWv5K3u8neCJ2IeHqpDCnKaR0kaWPtcb/aBplgv/7 EtuWkr1zFVOEylNqhYzJVaSdmbqWQKQrPDBxpTM1DMIsU474XkZb0HkSYdB4XnNDzMwQ yQpIvuyyj6LT8V5I7XVII+UPHCo8NGQJgO+KXg77mWNd7AGEFAPifC7eOhMrAfK65OQr VLEV4UZ0kMSZ37/U79TfaBrTk0gcqswrwMXro3tqT6fIa8Uou7lasSzs2+BR6dlWqE6L qTjw== X-Gm-Message-State: APjAAAVvfWxI2dYXKUQfnPZzOupZUMeBqc1zNHei80mr1W+ttdmnExWA kT3DpHaqPLfe4jlCPmDhbHFazAI= X-Google-Smtp-Source: APXvYqzn6JLx+Wc9y6XXu8ELvEeNY4b16AaMUAdnjyVGFPiNjvEtpI0NzSothPm2X7oQiydB05ELbw== X-Received: by 2002:a92:4144:: with SMTP id o65mr37498482ila.222.1571875094804; Wed, 23 Oct 2019 16:58:14 -0700 (PDT) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id z18sm2405409iob.47.2019.10.23.16.58.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 16:58:14 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 07/14] NFSv4: Don't remove the delegation from the super_list more than once Date: Wed, 23 Oct 2019 19:55:53 -0400 Message-Id: <20191023235600.10880-8-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191023235600.10880-7-trond.myklebust@hammerspace.com> References: <20191023235600.10880-1-trond.myklebust@hammerspace.com> <20191023235600.10880-2-trond.myklebust@hammerspace.com> <20191023235600.10880-3-trond.myklebust@hammerspace.com> <20191023235600.10880-4-trond.myklebust@hammerspace.com> <20191023235600.10880-5-trond.myklebust@hammerspace.com> <20191023235600.10880-6-trond.myklebust@hammerspace.com> <20191023235600.10880-7-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Add a check to ensure that we haven't already removed the delegation from the inode after we take all the relevant locks. Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index e60737be6f26..b49faf1b3d91 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -287,6 +287,10 @@ nfs_detach_delegation_locked(struct nfs_inode *nfsi, return NULL; spin_lock(&delegation->lock); + if (!delegation->inode) { + spin_unlock(&delegation->lock); + return NULL; + } set_bit(NFS_DELEGATION_RETURNING, &delegation->flags); list_del_rcu(&delegation->super_list); delegation->inode = NULL; From patchwork Wed Oct 23 23:55:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11208075 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D4F0613BD for ; Wed, 23 Oct 2019 23:58:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B3DEE2084C for ; Wed, 23 Oct 2019 23:58:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VtZGLzmC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406151AbfJWX6R (ORCPT ); Wed, 23 Oct 2019 19:58:17 -0400 Received: from mail-il1-f194.google.com ([209.85.166.194]:33807 "EHLO mail-il1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404828AbfJWX6Q (ORCPT ); Wed, 23 Oct 2019 19:58:16 -0400 Received: by mail-il1-f194.google.com with SMTP id a13so6303597ilp.1 for ; Wed, 23 Oct 2019 16:58:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=CIbITOUXPbXRnQXw5ojtD+uvzTEzCqXnEDbdi6EaBWA=; b=VtZGLzmCpfgdJHOCcwWYiUJPhRbyA42u4jn1Z+bJ0GmRbL+hrn+BD8RDHtEyNlVHpa PgwDwvLhaTNV6VlU0l8r5Ejfx4R+ftSSypJLLQNTCLqmODFdual1v7Bb/YC+hlxAnqzL HwAuSrHxFswyU53AMZv1nk1mb3rdAA3SjA3gDXAcNLBVVIVRnYF178fvb67mEvTh+XsF js9BsTkkPQrThUGWi77noqj3ylrKnQUZ9giLUE/9sYPhzlqc6dM+4OUpqbAnucJkEAu8 RJ4OUi9tuGAC4+RPFIV5ffKiC4qJjOtCtq6OzM2D2c0wVa7Am8g+5zzSLr1ODS24RSSt tXWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CIbITOUXPbXRnQXw5ojtD+uvzTEzCqXnEDbdi6EaBWA=; b=RlMT0+1KhLF5N5P3X/RNu3DDylUUnGNGtAZZLveyuZVYOVlfApwxtj4w/PJA1X383n JXKCkWrO5gKIYB6zqlAnlqmv3a5XoMhfibdCniVu3279cL02+4FR9RsegmGzDUAAkCdj 1FNcloX2Ub5aP0Mx50O1JgWVBc3cvlMcxbsed2GMtgPHqtO/ZezLhEoZHEue58gE0lv9 fZzFGlIGxgPGSmhzI9eRk4No0ThBgEU/muKNtmtErPfPJbuw76xvnUSRDdqJb+Jr3tWw c92QJvO/NHM8ywFVKw7gW9/fAVLtodZV8+0okCBKg3kPDrQAO1khl4z1N/4DnGi1Va8e lN3A== X-Gm-Message-State: APjAAAW1aMnBhF25NN91rD4nBxheQP/pjGNsw10mbUNrBpyUQOTb4E3+ wnZ1BjdHcS1/Nl1XE73oQ+AAXjI= X-Google-Smtp-Source: APXvYqznw3jR8r0y62UF9ktSXxRuBkvGinzutonvCYzngxHbx5sS8mTigb1+lkS72pg4cKfO9EpopA== X-Received: by 2002:a92:188:: with SMTP id 130mr20976393ilb.177.1571875095458; Wed, 23 Oct 2019 16:58:15 -0700 (PDT) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id z18sm2405409iob.47.2019.10.23.16.58.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 16:58:15 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 08/14] NFSv4: Hold the delegation spinlock when updating the seqid Date: Wed, 23 Oct 2019 19:55:54 -0400 Message-Id: <20191023235600.10880-9-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191023235600.10880-8-trond.myklebust@hammerspace.com> References: <20191023235600.10880-1-trond.myklebust@hammerspace.com> <20191023235600.10880-2-trond.myklebust@hammerspace.com> <20191023235600.10880-3-trond.myklebust@hammerspace.com> <20191023235600.10880-4-trond.myklebust@hammerspace.com> <20191023235600.10880-5-trond.myklebust@hammerspace.com> <20191023235600.10880-6-trond.myklebust@hammerspace.com> <20191023235600.10880-7-trond.myklebust@hammerspace.com> <20191023235600.10880-8-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index b49faf1b3d91..d9c80871cecc 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -376,8 +376,10 @@ int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred, /* Is this an update of the existing delegation? */ if (nfs4_stateid_match_other(&old_delegation->stateid, &delegation->stateid)) { + spin_lock(&old_delegation->lock); nfs_update_inplace_delegation(old_delegation, delegation); + spin_unlock(&old_delegation->lock); goto out; } /* From patchwork Wed Oct 23 23:55:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11208077 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3DE2413BD for ; Wed, 23 Oct 2019 23:58:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1C5EE2084C for ; Wed, 23 Oct 2019 23:58:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ghHySkV2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406349AbfJWX6S (ORCPT ); Wed, 23 Oct 2019 19:58:18 -0400 Received: from mail-il1-f193.google.com ([209.85.166.193]:39462 "EHLO mail-il1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404433AbfJWX6R (ORCPT ); Wed, 23 Oct 2019 19:58:17 -0400 Received: by mail-il1-f193.google.com with SMTP id i12so10115025ils.6 for ; Wed, 23 Oct 2019 16:58:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Q/TLhPeG3i+gvasxZ5F8IXG4BfmaFJzWMMDpYSNVO/Q=; b=ghHySkV231ZTGhvj6Gal/5Xk5ZTdTxiviquIjYiXrluNNv3Iypi0j3UUlrz7+Gh6s9 Ekjr6lrG1U9BwZelg0yDu6V8Mhb1PgqTY7YZ6POIINrn3upJK+ok4qUhN0+sdwB5O9kW jMuuuvcD7Kg3yfmcan3ez2jtHO6Q+Kpy7qgfx3LlrL/fYr5hdU/c5YEBv35a0alrJz2S ++CiQwrWYY/fRp4eERBfmioeaeY1Z9REd2VOcSdox9dQt79J9zNRlwXXPrVIsc8rni6Q sR9LbhIFN64DsVVL8Bu+8abRnuJD6vz+HCF4ip6R7X3JvWJ1fBriqNt7DzGZjJLnQY3z 9KRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Q/TLhPeG3i+gvasxZ5F8IXG4BfmaFJzWMMDpYSNVO/Q=; b=LzwrFuAoW2GVL3vuRT0Xn6kgZP6s4u+tneSw3IQZIjCWS4l1vQLPYbtaZqZidwJfWL HUBMtDFpbM6Zdvef2D4mmvf0281e//HbwvIExs+dAwvqtA765CXgjCZS5o3dzqUypyuX bDCsFLUKlyekWWg5l+MpctEyWJS3koL1geTXtdiinOZDn2RYlW/2s6mDl0V+ida+jUfm 8YP/Xp/fGyCIF7ebYSC7Tn8mZ+rAQnTsu/RiCf/iIkVi4xd0rthmgwsKvfNXFbxMOBkG BvpvDZBAPKQaJEIxgR+emR/baqN3UVDdHdqRXfRnPn92tBVSPNZdw9jHL1Pa9lu84CUX D28Q== X-Gm-Message-State: APjAAAVQrrKqAgwgR65rj4rfGUO8chGztCxglTxK2WHQQSrr0X5rSAxb qojaJ7wF6k2jLt9WVYiytkQ726k= X-Google-Smtp-Source: APXvYqxjCQP/UGcNB9OYe/cLit40gAu5yewl7GJm/nbC22NVyf3dHG/nsr6wqg6dyyYsK8TLYGlp0Q== X-Received: by 2002:a05:6e02:c8e:: with SMTP id b14mr42597553ile.16.1571875096089; Wed, 23 Oct 2019 16:58:16 -0700 (PDT) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id z18sm2405409iob.47.2019.10.23.16.58.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 16:58:15 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 09/14] NFSv4: Clear the NFS_DELEGATION_REVOKED flag in nfs_update_inplace_delegation() Date: Wed, 23 Oct 2019 19:55:55 -0400 Message-Id: <20191023235600.10880-10-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191023235600.10880-9-trond.myklebust@hammerspace.com> References: <20191023235600.10880-1-trond.myklebust@hammerspace.com> <20191023235600.10880-2-trond.myklebust@hammerspace.com> <20191023235600.10880-3-trond.myklebust@hammerspace.com> <20191023235600.10880-4-trond.myklebust@hammerspace.com> <20191023235600.10880-5-trond.myklebust@hammerspace.com> <20191023235600.10880-6-trond.myklebust@hammerspace.com> <20191023235600.10880-7-trond.myklebust@hammerspace.com> <20191023235600.10880-8-trond.myklebust@hammerspace.com> <20191023235600.10880-9-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If the server sent us a new delegation stateid that is more recent than the one that got revoked, then clear the NFS_DELEGATION_REVOKED flag. Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index d9c80871cecc..b6cc2e71fcdb 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -332,6 +332,7 @@ nfs_update_inplace_delegation(struct nfs_delegation *delegation, delegation->stateid.seqid = update->stateid.seqid; smp_wmb(); delegation->type = update->type; + clear_bit(NFS_DELEGATION_REVOKED, &delegation->flags); } } From patchwork Wed Oct 23 23:55:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11208079 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7CB901920 for ; Wed, 23 Oct 2019 23:58:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5BD672084C for ; Wed, 23 Oct 2019 23:58:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NW0ud2L2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404433AbfJWX6S (ORCPT ); Wed, 23 Oct 2019 19:58:18 -0400 Received: from mail-il1-f196.google.com ([209.85.166.196]:42339 "EHLO mail-il1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406310AbfJWX6S (ORCPT ); Wed, 23 Oct 2019 19:58:18 -0400 Received: by mail-il1-f196.google.com with SMTP id o16so12566256ilq.9 for ; Wed, 23 Oct 2019 16:58:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=T8D6q1Ea4/af1vMO59OuldPoVzw8cQL6pHgSwOa5LsI=; b=NW0ud2L2VFbksapFCxjzV267S3fj01kAjj+CzQ+eQ/mTMdZmX4ncevHMpL4kNruKud R0dmybnr7mt4UpU94maKbRuKfeYGuFvhPe9yZz0v/ZgwMlC8hz2vMIlAYamDRM9QLSp7 blq/tay9QgkQ7GwTlIdWpoOIrTzrkCZGAje+tFuu1y6rkMX1BZ3fkgU1e1NUJez00quV qbvT2xZYhhz+/Sker/E2F0dRgRoEtjjcZUoInrzcmKyOxyjTjAga8yH0JecGGPqCjw4C UqSaflBkHpP/M+ZI7bGlc8g1myUzUE6D/v9Gw9Ath33Wqdnvc25LFu3T0r44DPA8VxRt kZlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T8D6q1Ea4/af1vMO59OuldPoVzw8cQL6pHgSwOa5LsI=; b=KrSdQs1+rr8tUKNzYluYbW4Dy2iSR6kdETt+lX0MHIYdh3YfR9wTxvCN6Ro595B9WE VpOjRXc9wJ6OiC+ZpoRkOXie6Gkw7i7aTUxPeoJdnvg/7/B7HC8+aUblhRyIaXgVHbGl oIazx+SmeAIKGMEnsru85shsftagJPYZB7RSPs82TOcKrxAIsHcHp2fwWygnn17k9+p4 tyJ6dehU1pmgh4scNJp0YxzS5IcLZUKGaS7M65bZnPWLsFTt62KJFhk2IgFudLB/AINC J+zz6/0VFqmrlp27ET5M+0Fj3rMl95eol2H0l92xgyCVPcdzmefXGL1QBUVNwe7FRV9h fkPA== X-Gm-Message-State: APjAAAXIn59pdJN+njkZxqyVhPGYTjtbzS+o3AH5fd6iacN4Ml4VaPTA E5ACj6e13p168GPCH2hxTCwkf8Q= X-Google-Smtp-Source: APXvYqxKQ/BDhKC0MMbh55Ug8HqSKag9rcwBapJmayaLTq3Xtsho5/mMaRtxeoxQlIlm07KuCtS+HA== X-Received: by 2002:a92:b70b:: with SMTP id k11mr24324324ili.125.1571875096739; Wed, 23 Oct 2019 16:58:16 -0700 (PDT) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id z18sm2405409iob.47.2019.10.23.16.58.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 16:58:16 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 10/14] NFSv4: Update the stateid seqid in nfs_revoke_delegation() Date: Wed, 23 Oct 2019 19:55:56 -0400 Message-Id: <20191023235600.10880-11-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191023235600.10880-10-trond.myklebust@hammerspace.com> References: <20191023235600.10880-1-trond.myklebust@hammerspace.com> <20191023235600.10880-2-trond.myklebust@hammerspace.com> <20191023235600.10880-3-trond.myklebust@hammerspace.com> <20191023235600.10880-4-trond.myklebust@hammerspace.com> <20191023235600.10880-5-trond.myklebust@hammerspace.com> <20191023235600.10880-6-trond.myklebust@hammerspace.com> <20191023235600.10880-7-trond.myklebust@hammerspace.com> <20191023235600.10880-8-trond.myklebust@hammerspace.com> <20191023235600.10880-9-trond.myklebust@hammerspace.com> <20191023235600.10880-10-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If we revoke a delegation, but the stateid's seqid is newer, then ensure we update the seqid when marking the delegation as revoked. Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index b6cc2e71fcdb..5a87d32a8d7c 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -760,8 +760,19 @@ static bool nfs_revoke_delegation(struct inode *inode, if (stateid == NULL) { nfs4_stateid_copy(&tmp, &delegation->stateid); stateid = &tmp; - } else if (!nfs4_stateid_match(stateid, &delegation->stateid)) - goto out; + } else { + if (!nfs4_stateid_match_other(stateid, &delegation->stateid)) + goto out; + spin_lock(&delegation->lock); + if (stateid->seqid) { + if (nfs4_stateid_is_newer(&delegation->stateid, stateid)) { + spin_unlock(&delegation->lock); + goto out; + } + delegation->stateid.seqid = stateid->seqid; + } + spin_unlock(&delegation->lock); + } nfs_mark_delegation_revoked(NFS_SERVER(inode), delegation); ret = true; out: From patchwork Wed Oct 23 23:55:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11208081 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5692D1390 for ; Wed, 23 Oct 2019 23:58:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 354C12084C for ; Wed, 23 Oct 2019 23:58:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BAqj9nqS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406310AbfJWX6T (ORCPT ); Wed, 23 Oct 2019 19:58:19 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:32917 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406360AbfJWX6S (ORCPT ); Wed, 23 Oct 2019 19:58:18 -0400 Received: by mail-io1-f68.google.com with SMTP id z19so27283285ior.0 for ; Wed, 23 Oct 2019 16:58:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=zVqTmIUAXC7dPNeIDF1vIwLG+V39yijm9mkc4U7mxII=; b=BAqj9nqSnSg8+cP/uaHM3TVJeHsFoH43baHKQmmTVdHmxaDWamJ4lFtuJh/Z0Anl0q /WlpgTRMiL1ej8UfaI6Sn7yVR1et0xTela2869M094SOYT1xWTHcmqqVZypcGZUjc7rI iTIQ5zsAXvQUQlKuDQO64aqEgHoF3koaJYhTndsEpEnRnTjGItPjfAiJ5McdYQO3AtKn FBD7Bea5zgZ2hdrgecYWMQ9AF9krh6+4uwlXbSN87vPHsz8gi5e78h7wYdOLXVcR+98J YLjS4TvXan7DN3sAsutATw20MQM+vs4nh74bnADOiA5mPcNWgcqUNWRIu5g5Evl+NvLd cT7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zVqTmIUAXC7dPNeIDF1vIwLG+V39yijm9mkc4U7mxII=; b=WAY/8Awm9nL/fbn6bMcrOldBy+T7WRfAp7SzA7UJJB/Mer6y6EaSExjoRYJam4shtG 1BKLtr4AewGO+SjHEmrj/0hN/1VtcTV4LxgLtJaB3QGWCO6Pb1rpfA2adIqPJYYALXQF ADBBIffpg+74UltWFU40T44s6zW3dvtXJwAEhMp1yWbFIQcnwAF+rGDpWU6CXUHdz2ES QTv12AdpaVemeCUe2/2IQ5bEcjRNDVR48NRFwPe6uWGTJSoZOswMM1EW2frU/NUR6gPN C0MhkpSJP0lNe2i/KEvu4Pc4NUKl1O9hgumqe9BegEsXxGy6QiYUtl+og4jMTMB2l5op H0IA== X-Gm-Message-State: APjAAAXBRlis4zdhiXnXFpWHFETe59TRsvNCj6nGTJFxlmAvFmg1e5LG 1ag9UjsSMXflkmoNXO1EWP2I428= X-Google-Smtp-Source: APXvYqzglbUMbA4hTm6D7fx/O18oAE0zuF4gSs5wexOgna6rxOaERnG2x0y1iSlPxIVHyKdDhF1uvA== X-Received: by 2002:a6b:37c6:: with SMTP id e189mr6062695ioa.122.1571875097473; Wed, 23 Oct 2019 16:58:17 -0700 (PDT) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id z18sm2405409iob.47.2019.10.23.16.58.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 16:58:16 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 11/14] NFSv4: Revoke the delegation on success in nfs4_delegreturn_done() Date: Wed, 23 Oct 2019 19:55:57 -0400 Message-Id: <20191023235600.10880-12-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191023235600.10880-11-trond.myklebust@hammerspace.com> References: <20191023235600.10880-1-trond.myklebust@hammerspace.com> <20191023235600.10880-2-trond.myklebust@hammerspace.com> <20191023235600.10880-3-trond.myklebust@hammerspace.com> <20191023235600.10880-4-trond.myklebust@hammerspace.com> <20191023235600.10880-5-trond.myklebust@hammerspace.com> <20191023235600.10880-6-trond.myklebust@hammerspace.com> <20191023235600.10880-7-trond.myklebust@hammerspace.com> <20191023235600.10880-8-trond.myklebust@hammerspace.com> <20191023235600.10880-9-trond.myklebust@hammerspace.com> <20191023235600.10880-10-trond.myklebust@hammerspace.com> <20191023235600.10880-11-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If the delegation was successfully returned, then mark it as revoked. Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 32 ++++++++++++++++++++++++++++++++ fs/nfs/delegation.h | 1 + fs/nfs/nfs4proc.c | 1 + 3 files changed, 34 insertions(+) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 5a87d32a8d7c..b214b88b35b5 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -795,6 +795,38 @@ void nfs_remove_bad_delegation(struct inode *inode, } EXPORT_SYMBOL_GPL(nfs_remove_bad_delegation); +void nfs_delegation_mark_returned(struct inode *inode, + const nfs4_stateid *stateid) +{ + struct nfs_delegation *delegation; + + if (!inode) + return; + + rcu_read_lock(); + delegation = rcu_dereference(NFS_I(inode)->delegation); + if (!delegation) + goto out_rcu_unlock; + + spin_lock(&delegation->lock); + if (!nfs4_stateid_match_other(stateid, &delegation->stateid)) + goto out_spin_unlock; + if (stateid->seqid && + nfs4_stateid_is_newer(&delegation->stateid, stateid)) + goto out_clear_returning; + + set_bit(NFS_DELEGATION_REVOKED, &delegation->flags); + +out_clear_returning: + clear_bit(NFS_DELEGATION_RETURNING, &delegation->flags); +out_spin_unlock: + spin_unlock(&delegation->lock); +out_rcu_unlock: + rcu_read_unlock(); + + nfs_inode_find_state_and_recover(inode, stateid); +} + /** * nfs_expire_unused_delegation_types * @clp: client to process diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h index 9a14a7ca1df9..7f0151c40d2f 100644 --- a/fs/nfs/delegation.h +++ b/fs/nfs/delegation.h @@ -53,6 +53,7 @@ void nfs_expire_unreferenced_delegations(struct nfs_client *clp); int nfs_client_return_marked_delegations(struct nfs_client *clp); int nfs_delegations_present(struct nfs_client *clp); void nfs_remove_bad_delegation(struct inode *inode, const nfs4_stateid *stateid); +void nfs_delegation_mark_returned(struct inode *inode, const nfs4_stateid *stateid); void nfs_delegation_mark_reclaim(struct nfs_client *clp); void nfs_delegation_reap_unclaimed(struct nfs_client *clp); diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index c407e2eed3d5..4375b07ede25 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -6211,6 +6211,7 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata) if (exception.retry) goto out_restart; } + nfs_delegation_mark_returned(data->inode, data->args.stateid); data->rpc_status = task->tk_status; return; out_restart: From patchwork Wed Oct 23 23:55:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11208083 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9FBE41920 for ; Wed, 23 Oct 2019 23:58:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7E7112084C for ; Wed, 23 Oct 2019 23:58:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="F8iyvgWo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406375AbfJWX6U (ORCPT ); Wed, 23 Oct 2019 19:58:20 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:38017 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404828AbfJWX6T (ORCPT ); Wed, 23 Oct 2019 19:58:19 -0400 Received: by mail-io1-f68.google.com with SMTP id u8so27184124iom.5 for ; Wed, 23 Oct 2019 16:58:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=0BwJqCylHLRphTfKIND1800ET172jmjuxg1et45hUiU=; b=F8iyvgWo8B5mXctVS7vYw92SDiKon8fG8pK63JcAwh6LXWaH7LCAIVqfuwBrnIE/KC doNo8hgDt3XIt86QPv4y28JnhmvXEiyhQbVcVRotBPzZHvNG18BdRPXJoxH/W2Ss+6ek zxXeKjZ8KcDaTC4aN92na+cQNXQEQ96auTpFQHj/Hn7fuMWM/2prQh1dpQsy+xwns5yt ksX5ILNgEGrLa5HRudGVc6+AkvV92RG9zD68zePooEgoQN7Rn0vv1E9pFlhLQIwN3NPZ YcgQvhrHzxWLPId81RUY789YNsTwa8U0vXW0C/B9MW3fQ/lqgUWfyAHLrDcOj6scVia4 GtHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0BwJqCylHLRphTfKIND1800ET172jmjuxg1et45hUiU=; b=eJOOhacVrmlxBr7OP2avyuLfSbYuCavWvZjuSx2GnlohQ0bl13LshIr75fvKv29sUh Ycdyqki0Njq7tu1fTmn3aRK05+haPEjUWEXz4RSPbuykedMqPQca2HeevyWAMhxTlEGH 946oHTRrLqYBogg0ntI9oo0Aq5edO7V8Rudr902IgK7XIUVuBZp+hzqq1bI97E3bTHAo c/ZvYHmy2oDESQRYQEjh6eTaH5oLq3FmTEAMku30avA6zzyrfMEZmoB9H8FgKtMs+9tL H0YZOr983rIV1y15dBE/EneMLKUqUhcFV1CKEI/Psu5eEjk0rw3fQyUxGjvEwVHx2KI0 EWQQ== X-Gm-Message-State: APjAAAXUkkxUcVrJVE9QFcWu3/T2Q+nqI2kJ5N0ra3j+WvVuxqVqQtLy nqd9fmm/ueQZZjyGhOQOJ2nC32A= X-Google-Smtp-Source: APXvYqzHN2BMFhAHfpKIVsrAsPBGIMAHzBuAH0QpdRq7/plPVb3CKW1jKFyDrMe/2AkGYxzdc4vzjA== X-Received: by 2002:a5e:c748:: with SMTP id g8mr5992094iop.149.1571875098189; Wed, 23 Oct 2019 16:58:18 -0700 (PDT) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id z18sm2405409iob.47.2019.10.23.16.58.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 16:58:17 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 12/14] NFSv4: Ignore requests to return the delegation if it was revoked Date: Wed, 23 Oct 2019 19:55:58 -0400 Message-Id: <20191023235600.10880-13-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191023235600.10880-12-trond.myklebust@hammerspace.com> References: <20191023235600.10880-1-trond.myklebust@hammerspace.com> <20191023235600.10880-2-trond.myklebust@hammerspace.com> <20191023235600.10880-3-trond.myklebust@hammerspace.com> <20191023235600.10880-4-trond.myklebust@hammerspace.com> <20191023235600.10880-5-trond.myklebust@hammerspace.com> <20191023235600.10880-6-trond.myklebust@hammerspace.com> <20191023235600.10880-7-trond.myklebust@hammerspace.com> <20191023235600.10880-8-trond.myklebust@hammerspace.com> <20191023235600.10880-9-trond.myklebust@hammerspace.com> <20191023235600.10880-10-trond.myklebust@hammerspace.com> <20191023235600.10880-11-trond.myklebust@hammerspace.com> <20191023235600.10880-12-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If the delegation was revoked, or is already being returned, just clear the NFS_DELEGATION_RETURN and NFS_DELEGATION_RETURN_IF_CLOSED flags and keep going. Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index b214b88b35b5..150a3bf7b35c 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -465,8 +465,6 @@ static bool nfs_delegation_need_return(struct nfs_delegation *delegation) { bool ret = false; - if (test_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) - goto out; if (test_and_clear_bit(NFS_DELEGATION_RETURN, &delegation->flags)) ret = true; if (test_and_clear_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags) && !ret) { @@ -478,7 +476,10 @@ static bool nfs_delegation_need_return(struct nfs_delegation *delegation) ret = true; spin_unlock(&delegation->lock); } -out: + if (test_bit(NFS_DELEGATION_RETURNING, &delegation->flags) || + test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) + ret = false; + return ret; } From patchwork Wed Oct 23 23:55:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11208085 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1374413BD for ; Wed, 23 Oct 2019 23:58:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E5ADD207FD for ; Wed, 23 Oct 2019 23:58:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="e58ll6Xu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2408035AbfJWX6V (ORCPT ); Wed, 23 Oct 2019 19:58:21 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:36246 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406360AbfJWX6U (ORCPT ); Wed, 23 Oct 2019 19:58:20 -0400 Received: by mail-io1-f67.google.com with SMTP id c16so7351021ioc.3 for ; Wed, 23 Oct 2019 16:58:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=7NGYtoz2hLdsD68NTZu+3+OvCT8wa4PcwXvK18IJXRY=; b=e58ll6XuUeBp3TYaARZN9OCtvjikdoUogi7vEaf4taxEPSPA4dK9xfMXMFQBGSVyFY jpObzqKzMLRymHU2oG85X0qVUYGtx+h0jlvr1abBRFahrrCX8nEITDz9V+nsILG9dUJv Spm7Z78eyvKRWah+BYP9OvJTYAjICSn/BJepbDNqUXNwVbbKbaFQ0QB4UU/RaV286tnu VS/xlIKFj0T18vRNuVnsfg3SxY1ULJvNvHgz/imqB9a9/a0PBq+hHFs7sjl+C1bOo113 r/xd3w2hnkvbyjZ4k4OpFCRP9Dw6s51lJeEAdliTrYs23oxsu4DIqM/u/4JjekUqTfM7 eDaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7NGYtoz2hLdsD68NTZu+3+OvCT8wa4PcwXvK18IJXRY=; b=Fgm/52azh7yGE1b2GpGo8TfzhsQSnSy9ZGew3c+XqBthf/Nu2aVN3erU49o6k87HQ2 k3D9IjtQMNF/DvsRv+9KROgMx1zOcmaqlshPcExAYm8PyK6rPJkImazqpn1a61drUabV TTSSQ2UZqX19WIMw92a6oGa2FqIZVYsp0/BSGub47RrCheXjjsCQa21iH1hVmplJbMJy FW8B/V3OLP9AaDPDQ7HdzBmfvbR54g2ZAVcWQ6w/TCaOVRQfL6CcATP7vo7KeaTxweWx NLrsv0UcYZlE1CnitjL6PQBx6n9JPY33ecSoVm+3qIXXejKSoHQJcBCqFGcm4TrkcHja +khw== X-Gm-Message-State: APjAAAVzXzNkmOx2eU19uBn+YTDFejH9Ix9X8ghkMJ4GwYacUckS8sX0 4nsCjYFnqHYpgEDPXRA5vBi52mk= X-Google-Smtp-Source: APXvYqw92/FQkOPpJprRkE3S9YWn03Ceo/jeXf+wqijy2K/b6C1xl0OSCK+Crfgkham1jguaF2WCWQ== X-Received: by 2002:a02:ac81:: with SMTP id x1mr12046863jan.133.1571875098827; Wed, 23 Oct 2019 16:58:18 -0700 (PDT) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id z18sm2405409iob.47.2019.10.23.16.58.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 16:58:18 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 13/14] NFSv4: Don't reclaim delegations that have been returned or revoked Date: Wed, 23 Oct 2019 19:55:59 -0400 Message-Id: <20191023235600.10880-14-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191023235600.10880-13-trond.myklebust@hammerspace.com> References: <20191023235600.10880-1-trond.myklebust@hammerspace.com> <20191023235600.10880-2-trond.myklebust@hammerspace.com> <20191023235600.10880-3-trond.myklebust@hammerspace.com> <20191023235600.10880-4-trond.myklebust@hammerspace.com> <20191023235600.10880-5-trond.myklebust@hammerspace.com> <20191023235600.10880-6-trond.myklebust@hammerspace.com> <20191023235600.10880-7-trond.myklebust@hammerspace.com> <20191023235600.10880-8-trond.myklebust@hammerspace.com> <20191023235600.10880-9-trond.myklebust@hammerspace.com> <20191023235600.10880-10-trond.myklebust@hammerspace.com> <20191023235600.10880-11-trond.myklebust@hammerspace.com> <20191023235600.10880-12-trond.myklebust@hammerspace.com> <20191023235600.10880-13-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If the delegation has already been revoked, we want to avoid reclaiming it on reboot. Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 150a3bf7b35c..00c6c343dced 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -188,7 +188,7 @@ void nfs_inode_reclaim_delegation(struct inode *inode, const struct cred *cred, delegation = rcu_dereference(NFS_I(inode)->delegation); if (delegation != NULL) { spin_lock(&delegation->lock); - if (delegation->inode != NULL) { + if (nfs4_is_valid_delegation(delegation, FMODE_READ)) { nfs4_stateid_copy(&delegation->stateid, stateid); delegation->type = type; delegation->pagemod_limit = pagemod_limit; From patchwork Wed Oct 23 23:56:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11208087 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7B6341920 for ; Wed, 23 Oct 2019 23:58:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5978D2084C for ; Wed, 23 Oct 2019 23:58:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WidDz8oK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406360AbfJWX6V (ORCPT ); Wed, 23 Oct 2019 19:58:21 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:39010 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404828AbfJWX6V (ORCPT ); Wed, 23 Oct 2019 19:58:21 -0400 Received: by mail-io1-f65.google.com with SMTP id y12so9639416ioa.6 for ; Wed, 23 Oct 2019 16:58:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=x3qKv2XL6fhCyvFwJljuqovgKRE53a58X4jjdOhqd/M=; b=WidDz8oK1mb4Z9dNQM2xI/Na4YJGdgwbH7vrPUOjrSqaOsIyqygL6eNVsYkbQPS4sY Psz02XLLWqcbokpXBs53nedchFQHWjVdnvgdUVkHs73HShp7JsU5pSpUAGkkjImnUnpm XvEBL4E6NYVNl6u8WrbVd7v94/L3Ag2x59jWb016sMgEwsxt3pBdlJzJEZ7BNf7k4Ldx TWEaQP7ZrmSRusAOUDQmn6rkJJ6cVo/msQ1OVCyTAxprKbHxkihgdBZN7Fd6NqNHCyV5 AqE8Ysg+ujg+/DqRSPUpq8ShnH5iqoP8E2RUALrez5MOhivUfvThVhREJ0t4UR/ELWI7 3JVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=x3qKv2XL6fhCyvFwJljuqovgKRE53a58X4jjdOhqd/M=; b=tOF7KZ+lpMB1H5gNMjDRj0lAn+BoretnIlkHhgIjyru2eOBxDEPgu6e+pnkxP9TYP0 ZhLgDMEBJxKPghJ3/WyDSmz0w2iKO2wYdx0Wj/72MAVVu44Aldkatf6Y9Pc49uUcSpUO kyRortE3MoDtVQiY2xVAd+Dh6KX/om2EXBWpvVhBeg1YixE91QK6J4g29oTQjfNp/qzn dXgpldV0Yvz+vl8ldjtekIcoI7Ea+OGxEQklkYuq0iLmK2M6tlEo4wIu3zDOzAXKw2tC dAY8e5eN7vfBYANezZh02uYKsnqtMjgUK+gxt/wSGxw/ggGYCf150s719X0U1QSLwtvL dnqg== X-Gm-Message-State: APjAAAVNZhmhsbkXWCs401fKYw/65oADgfahua+K6WBrCCGnnPTLRd+p McKcmzI2sgEln9Dd4YIs8Drtp/k= X-Google-Smtp-Source: APXvYqz0AWkPWN1xI05MQkX9AIP7zvn9oqMFgwnWi6w5SuvwExNj6Zc94zJmPjUQKZqVPgpSawq/Ug== X-Received: by 2002:a6b:b458:: with SMTP id d85mr6302385iof.287.1571875099567; Wed, 23 Oct 2019 16:58:19 -0700 (PDT) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id z18sm2405409iob.47.2019.10.23.16.58.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 16:58:19 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 14/14] NFSv4: Fix races between open and delegreturn Date: Wed, 23 Oct 2019 19:56:00 -0400 Message-Id: <20191023235600.10880-15-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191023235600.10880-14-trond.myklebust@hammerspace.com> References: <20191023235600.10880-1-trond.myklebust@hammerspace.com> <20191023235600.10880-2-trond.myklebust@hammerspace.com> <20191023235600.10880-3-trond.myklebust@hammerspace.com> <20191023235600.10880-4-trond.myklebust@hammerspace.com> <20191023235600.10880-5-trond.myklebust@hammerspace.com> <20191023235600.10880-6-trond.myklebust@hammerspace.com> <20191023235600.10880-7-trond.myklebust@hammerspace.com> <20191023235600.10880-8-trond.myklebust@hammerspace.com> <20191023235600.10880-9-trond.myklebust@hammerspace.com> <20191023235600.10880-10-trond.myklebust@hammerspace.com> <20191023235600.10880-11-trond.myklebust@hammerspace.com> <20191023235600.10880-12-trond.myklebust@hammerspace.com> <20191023235600.10880-13-trond.myklebust@hammerspace.com> <20191023235600.10880-14-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If the server returns the same delegation in an open that we just used in a delegreturn, we need to ensure we don't apply that stateid if the delegreturn has freed it on the server. To do so, we ensure that we do not free the storage for the delegation until either it is replaced by a new one, or we throw the inode out of cache. Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 00c6c343dced..db7cf480c108 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -218,7 +218,6 @@ static int nfs_do_return_delegation(struct inode *inode, struct nfs_delegation * delegation->cred, &delegation->stateid, issync); - nfs_free_delegation(delegation); return res; } @@ -291,7 +290,6 @@ nfs_detach_delegation_locked(struct nfs_inode *nfsi, spin_unlock(&delegation->lock); return NULL; } - set_bit(NFS_DELEGATION_RETURNING, &delegation->flags); list_del_rcu(&delegation->super_list); delegation->inode = NULL; rcu_assign_pointer(nfsi->delegation, NULL); @@ -318,10 +316,12 @@ nfs_inode_detach_delegation(struct inode *inode) struct nfs_server *server = NFS_SERVER(inode); struct nfs_delegation *delegation; - delegation = nfs_start_delegation_return(nfsi); - if (delegation == NULL) - return NULL; - return nfs_detach_delegation(nfsi, delegation, server); + rcu_read_lock(); + delegation = rcu_dereference(nfsi->delegation); + if (delegation != NULL) + delegation = nfs_detach_delegation(nfsi, delegation, server); + rcu_read_unlock(); + return delegation; } static void @@ -420,8 +420,10 @@ int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred, spin_unlock(&clp->cl_lock); if (delegation != NULL) nfs_free_delegation(delegation); - if (freeme != NULL) + if (freeme != NULL) { nfs_do_return_delegation(inode, freeme, 0); + nfs_free_delegation(freeme); + } return status; } @@ -431,7 +433,6 @@ int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred, static int nfs_end_delegation_return(struct inode *inode, struct nfs_delegation *delegation, int issync) { struct nfs_client *clp = NFS_SERVER(inode)->nfs_client; - struct nfs_inode *nfsi = NFS_I(inode); int err = 0; if (delegation == NULL) @@ -453,8 +454,6 @@ static int nfs_end_delegation_return(struct inode *inode, struct nfs_delegation nfs_abort_delegation_return(delegation, clp); goto out; } - if (!nfs_detach_delegation(nfsi, delegation, NFS_SERVER(inode))) - goto out; err = nfs_do_return_delegation(inode, delegation, issync); out: @@ -597,6 +596,7 @@ void nfs_inode_evict_delegation(struct inode *inode) if (delegation != NULL) { set_bit(NFS_DELEGATION_INODE_FREEING, &delegation->flags); nfs_do_return_delegation(inode, delegation, 1); + nfs_free_delegation(delegation); } } @@ -744,10 +744,9 @@ static void nfs_mark_delegation_revoked(struct nfs_server *server, { set_bit(NFS_DELEGATION_REVOKED, &delegation->flags); delegation->stateid.type = NFS4_INVALID_STATEID_TYPE; - nfs_mark_return_delegation(server, delegation); } -static bool nfs_revoke_delegation(struct inode *inode, +static void nfs_revoke_delegation(struct inode *inode, const nfs4_stateid *stateid) { struct nfs_delegation *delegation; @@ -780,19 +779,12 @@ static bool nfs_revoke_delegation(struct inode *inode, rcu_read_unlock(); if (ret) nfs_inode_find_state_and_recover(inode, stateid); - return ret; } void nfs_remove_bad_delegation(struct inode *inode, const nfs4_stateid *stateid) { - struct nfs_delegation *delegation; - - if (!nfs_revoke_delegation(inode, stateid)) - return; - delegation = nfs_inode_detach_delegation(inode); - if (delegation) - nfs_free_delegation(delegation); + nfs_revoke_delegation(inode, stateid); } EXPORT_SYMBOL_GPL(nfs_remove_bad_delegation); @@ -816,7 +808,7 @@ void nfs_delegation_mark_returned(struct inode *inode, nfs4_stateid_is_newer(&delegation->stateid, stateid)) goto out_clear_returning; - set_bit(NFS_DELEGATION_REVOKED, &delegation->flags); + nfs_mark_delegation_revoked(NFS_SERVER(inode), delegation); out_clear_returning: clear_bit(NFS_DELEGATION_RETURNING, &delegation->flags);