From patchwork Thu Oct 31 22:40:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11221957 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 DB9E215AB for ; Thu, 31 Oct 2019 22:43:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AC49E2087F for ; Thu, 31 Oct 2019 22:43:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CJFmrogX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727528AbfJaWnF (ORCPT ); Thu, 31 Oct 2019 18:43:05 -0400 Received: from mail-yw1-f68.google.com ([209.85.161.68]:45118 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726506AbfJaWnE (ORCPT ); Thu, 31 Oct 2019 18:43:04 -0400 Received: by mail-yw1-f68.google.com with SMTP id x65so2773868ywf.12 for ; Thu, 31 Oct 2019 15:43:04 -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=6bmFBvm80lqZFmkuf5C7SAwGSogwl2AA+I9jrrqwyOQ=; b=CJFmrogXSo7UNNQVMEG8eZnUofcmRqRcdUcZFZucHaYzOsWQfleMRCka5SaWLg34Uw TgzlMD9fqmQP7JB6i6F/jiR/ZWUFMPPESG1BaRWxpkalISogtS+NQMveQs3r+ibq+crE FM7/Gi0TMyeKNte0di6vvJ8SIPSBeJ5pWEBMuvN0DWPx0GEp7jF/buJ96FpZ9hmH5jW/ l6i6cV/is1OuCi+gqUyXqBphAikxd7DB02IZ3IGIkXcIM8DRc9nCb7s7dLs1ARnZsr4o XrcP5mOrJy51L5UiicHCwvdfXp6tkRHpKsS1s5GcSN+x+07fi0EdPF/sFbN4PYbvoCFv szlg== 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=6bmFBvm80lqZFmkuf5C7SAwGSogwl2AA+I9jrrqwyOQ=; b=CB8ot7JN4pYnwkJAKbr7uHDNEe/G+U+AFkSs/Vmcem3qrjA3jSBwUkJPqc3o+d9OlK eP8UdXEcMeVruQRTck9hR/Hff3KioM5fc6gRWz5fVIx8Bw2vYVp6o+1lErMR1iO0u2bq DVvYFfhnxe96U/Wr1De4mx8dJTBtWsK0xKLFdoHozeB5ZHbWoUa/BT3870Hay/EE2don KlJUAb9U8fUq7GbICM75akmKJGk8Ay7qT8AKVmb0ZEkFjzRQpSf8GAjjoEOPd0y6/T1O sQPSQ0HPRuAtwTY59f1fzA6UxJH1sATb3LzSY8FWgkLRus0f7ltqe3HVwd7BI9ptkgH2 joaw== X-Gm-Message-State: APjAAAVPXOspo+hA4gGkQo/AIuREYUZbXkN/TuR7RL1j3kOrUgeef40D W4k4y51HO1uA9ZuauIOCpAzQj5U= X-Google-Smtp-Source: APXvYqw4wd8lGqGL8LCaJEUqE+8zPuuyUYfIdRNLMdaCJmy/Gmrh3/Mxpg0pUa9XvZ2uqTjH6e1dXg== X-Received: by 2002:a81:7a56:: with SMTP id v83mr4433932ywc.226.1572561783462; Thu, 31 Oct 2019 15:43:03 -0700 (PDT) Received: from localhost.localdomain ([50.105.87.1]) by smtp.gmail.com with ESMTPSA id d192sm1720287ywb.3.2019.10.31.15.43.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 15:43:02 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 01/20] NFSv4: Don't allow a cached open with a revoked delegation Date: Thu, 31 Oct 2019 18:40:32 -0400 Message-Id: <20191031224051.8923-2-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191031224051.8923-1-trond.myklebust@hammerspace.com> References: <20191031224051.8923-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 | 10 ++++++++++ fs/nfs/delegation.h | 1 + fs/nfs/nfs4proc.c | 7 ++----- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 071b90a45933..ccdfb5f98f35 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -53,6 +53,16 @@ nfs4_is_valid_delegation(const struct nfs_delegation *delegation, return false; } +struct nfs_delegation *nfs4_get_valid_delegation(const struct inode *inode) +{ + struct nfs_delegation *delegation; + + delegation = rcu_dereference(NFS_I(inode)->delegation); + if (nfs4_is_valid_delegation(delegation, 0)) + return delegation; + return NULL; +} + static int nfs4_do_check_delegation(struct inode *inode, fmode_t flags, bool mark) { diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h index 9eb87ae4c982..8b14d441e699 100644 --- a/fs/nfs/delegation.h +++ b/fs/nfs/delegation.h @@ -68,6 +68,7 @@ int nfs4_lock_delegation_recall(struct file_lock *fl, struct nfs4_state *state, bool nfs4_copy_delegation_stateid(struct inode *inode, fmode_t flags, nfs4_stateid *dst, const struct cred **cred); bool nfs4_refresh_delegation_stateid(nfs4_stateid *dst, struct inode *inode); +struct nfs_delegation *nfs4_get_valid_delegation(const struct inode *inode); void nfs_mark_delegation_referenced(struct nfs_delegation *delegation); int nfs4_have_delegation(struct inode *inode, fmode_t flags); int nfs4_check_delegation(struct inode *inode, fmode_t flags); diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index ab8ca20fd579..caacf5e7f5e1 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -1440,8 +1440,6 @@ static int can_open_delegated(struct nfs_delegation *delegation, fmode_t fmode, return 0; if ((delegation->type & fmode) != fmode) return 0; - if (test_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) - return 0; switch (claim) { case NFS4_OPEN_CLAIM_NULL: case NFS4_OPEN_CLAIM_FH: @@ -1810,7 +1808,6 @@ static void nfs4_return_incompatible_delegation(struct inode *inode, fmode_t fmo static struct nfs4_state *nfs4_try_open_cached(struct nfs4_opendata *opendata) { struct nfs4_state *state = opendata->state; - struct nfs_inode *nfsi = NFS_I(state->inode); struct nfs_delegation *delegation; int open_mode = opendata->o_arg.open_flags; fmode_t fmode = opendata->o_arg.fmode; @@ -1827,7 +1824,7 @@ static struct nfs4_state *nfs4_try_open_cached(struct nfs4_opendata *opendata) } spin_unlock(&state->owner->so_lock); rcu_read_lock(); - delegation = rcu_dereference(nfsi->delegation); + delegation = nfs4_get_valid_delegation(state->inode); if (!can_open_delegated(delegation, fmode, claim)) { rcu_read_unlock(); break; @@ -2371,7 +2368,7 @@ static void nfs4_open_prepare(struct rpc_task *task, void *calldata) data->o_arg.open_flags, claim)) goto out_no_action; rcu_read_lock(); - delegation = rcu_dereference(NFS_I(data->state->inode)->delegation); + delegation = nfs4_get_valid_delegation(data->state->inode); if (can_open_delegated(delegation, data->o_arg.fmode, claim)) goto unlock_no_action; rcu_read_unlock(); From patchwork Thu Oct 31 22:40:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11221959 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 3867013BD for ; Thu, 31 Oct 2019 22:43:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 16BC82087F for ; Thu, 31 Oct 2019 22:43:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZL+tT7ff" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727595AbfJaWnG (ORCPT ); Thu, 31 Oct 2019 18:43:06 -0400 Received: from mail-yb1-f194.google.com ([209.85.219.194]:41547 "EHLO mail-yb1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726506AbfJaWnG (ORCPT ); Thu, 31 Oct 2019 18:43:06 -0400 Received: by mail-yb1-f194.google.com with SMTP id b2so3098781ybr.8 for ; Thu, 31 Oct 2019 15:43:05 -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=faFf2iylaTkeS0qV7rlKf6L0S80aVsYgn7LhWX7gbUg=; b=ZL+tT7ffriF6uh0WQGwMSzS7PWFpvVOIPUrn1S/MqiMGXPVk5evnxNxFHnF63pysC4 A3E10um4nNgwBghBHD7pfQYubPlKSY5qNxZ2zCSaEHARhz+vuxZ8IIBcHPv5qsJquCB5 9D7XE4cJ++U/+h86u5fm5dW/3mMKN3tvtbt4UG2DRNP91Xtcbf2JlDtQePHNTiGV+/XS kqssNAKqzFBIh3wh8gYZnD+TS86DPTdicsc5IQ1vVJHLD4hEtLzk26cWzzGLkTx6Oxj7 fi1tp/imLIWpJtFAUf8C1u1a0+mjok6NDPbUAA/PGtnOpP+jMLwPIbCDiiWqtfwJOIAl AkXQ== 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=faFf2iylaTkeS0qV7rlKf6L0S80aVsYgn7LhWX7gbUg=; b=BZUlDf1w6PFtfb8oqxf6EGrzMs3OuxdNZ5R2RkKDUQ7SnQ/Z2Vq5Af8Rcv2n/PgrN+ 7aRTvhhY0LiRB5xsx64FMaj4oaWIwKh6KTQBLXv+w0SWMGEqX4lUggbGKDxiB76E+8EO SHB1KJl2gLkhKca7HKnPLPgRnktpBj4bCpgoYRBgO7wO4ivz37Kpp/Bdr7qvtysEpkd+ xUVpzco1p6QNRBesEEr9sxxmgcXK/Ei+M7/pCuftw81LabpUUHn1ozMzgzVQSu4Ih6OL LfQEmfiqSsQaKAuW1ic3SWgierYfBxHQR84XH7L5ZAyTUVcxuyJ9tqd+UBthtuIDqJig 98CQ== X-Gm-Message-State: APjAAAVlZsUBfX/2dX5Ucg2iqqHY0/mgyHUHKrGBAE3BZE+gOobPO3jE NMDCQ96nQTlUyrOPVDaUU4rI6fk= X-Google-Smtp-Source: APXvYqzhnFKRQEEb7y+MLZqfoq2tgx+u5ccPcewddQkkfjLAwJib7KSVNPQLa1kJ6a0heMG5fZR5LQ== X-Received: by 2002:a25:4b03:: with SMTP id y3mr6681269yba.497.1572561784793; Thu, 31 Oct 2019 15:43:04 -0700 (PDT) Received: from localhost.localdomain ([50.105.87.1]) by smtp.gmail.com with ESMTPSA id d192sm1720287ywb.3.2019.10.31.15.43.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 15:43:04 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 02/20] NFS: Fix an RCU lock leak in nfs4_refresh_delegation_stateid() Date: Thu, 31 Oct 2019 18:40:33 -0400 Message-Id: <20191031224051.8923-3-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191031224051.8923-2-trond.myklebust@hammerspace.com> References: <20191031224051.8923-1-trond.myklebust@hammerspace.com> <20191031224051.8923-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 A typo in nfs4_refresh_delegation_stateid() means we're leaking an RCU lock, and always returning a value of 'false'. As the function description states, we were always supposed to return 'true' if a matching delegation was found. Fixes: 12f275cdd163 ("NFSv4: Retry CLOSE and DELEGRETURN on NFS4ERR_OLD_STATEID.") Cc: stable@vger.kernel.org # v4.15+ 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 ccdfb5f98f35..af549d70ec50 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -1191,7 +1191,7 @@ bool nfs4_refresh_delegation_stateid(nfs4_stateid *dst, struct inode *inode) if (delegation != NULL && nfs4_stateid_match_other(dst, &delegation->stateid)) { dst->seqid = delegation->stateid.seqid; - return ret; + ret = true; } rcu_read_unlock(); out: From patchwork Thu Oct 31 22:40:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11221961 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 4655413BD for ; Thu, 31 Oct 2019 22:43:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 23E572087F for ; Thu, 31 Oct 2019 22:43:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QnHBWqXS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727617AbfJaWnH (ORCPT ); Thu, 31 Oct 2019 18:43:07 -0400 Received: from mail-yb1-f196.google.com ([209.85.219.196]:38261 "EHLO mail-yb1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726506AbfJaWnH (ORCPT ); Thu, 31 Oct 2019 18:43:07 -0400 Received: by mail-yb1-f196.google.com with SMTP id w6so1529600ybj.5 for ; Thu, 31 Oct 2019 15:43:07 -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=+n0mJF9y5GMEWpMGMu9q3t13jMd2L4Qm6XXL5xJbWQ0=; b=QnHBWqXSnCi5GtVlZ6sPy5I73fBI7KH0OiE0LMTpZ/g80MKdks2c5HfC9AnKANZkcI fFhaDQ+a3vACMUzQ8DJlCpTLaN5O67pKy94mFgz3ooRh16e/YULtSue3R625QnG/qwS8 BJhGR5D4//VzTau6OVmIGTJNPE5hzWgRrB9iKRRkVs2C/VPHOADH8ucmijDhA81HuSZ/ pXwnQuW0BN2n+v+/btP8at8iTgwbPoUzvnCUHUXyhvW853afYer8WnrlAjWbCSXpWsGY zJQGAmqQq0loWOXA5SQTsVZ2wE7Vbt1+R86u8cUaKAuUgUGeteVNL7VLetfPTt+tOT0I 1wCw== 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=+n0mJF9y5GMEWpMGMu9q3t13jMd2L4Qm6XXL5xJbWQ0=; b=ovjUPJC/hreXOAYRGXoQ+R+s0c7Q30Mv6j5OI/g2SkN1PC6uaum8ePdLvD+eDzPv2D zvCOfVZlSTEorZe/5uA1NolPu2QM1y9HC/oQbkA/MsiPi9oclbvyfjcdV1CqsNa2dYZ0 1CKoOr0ijbjGU6Ilt1hjTxTrVEennORLWbPHxhwV9pl7HVZPMBQ1yAK38XB0VU9WkW06 gU6C+B7eZ37/3hx+6/t/iE3b2MFKD07zE7KE+bT+r2MSNCdY4bclAQZYrR9PAPGaWxng GPfaIIZ0SNSI8eruNV+Jucu2yAbTMG42X63vKO2z2vqMoOPmaDh/XH8R1+pYFmCyNP3m ialQ== X-Gm-Message-State: APjAAAUNbemz2COePo9wbqsougnXyN1hlQCaHff5U75lJ/LlJcqwqdwU Ak4AXXER9leZw0zMd35JPp8XuLc= X-Google-Smtp-Source: APXvYqy0RkOYNd6pV8NjJzxaFfc4AKuex+9xyBidGjsVFRPJK+GWJ8nhWq6Xx54GAK0g6PGRGW0sZA== X-Received: by 2002:a25:6345:: with SMTP id x66mr6572298ybb.212.1572561786003; Thu, 31 Oct 2019 15:43:06 -0700 (PDT) Received: from localhost.localdomain ([50.105.87.1]) by smtp.gmail.com with ESMTPSA id d192sm1720287ywb.3.2019.10.31.15.43.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 15:43:05 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 03/20] NFSv4: Fix delegation handling in update_open_stateid() Date: Thu, 31 Oct 2019 18:40:34 -0400 Message-Id: <20191031224051.8923-4-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191031224051.8923-3-trond.myklebust@hammerspace.com> References: <20191031224051.8923-1-trond.myklebust@hammerspace.com> <20191031224051.8923-2-trond.myklebust@hammerspace.com> <20191031224051.8923-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 is marked as being revoked, then don't use it in the open state structure. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index caacf5e7f5e1..217885e32852 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -1737,7 +1737,7 @@ static int update_open_stateid(struct nfs4_state *state, ret = 1; } - deleg_cur = rcu_dereference(nfsi->delegation); + deleg_cur = nfs4_get_valid_delegation(state->inode); if (deleg_cur == NULL) goto no_delegation; @@ -1749,7 +1749,7 @@ static int update_open_stateid(struct nfs4_state *state, 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 Thu Oct 31 22:40:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11221963 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 0ABCC14E5 for ; Thu, 31 Oct 2019 22:43:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DB24B20873 for ; Thu, 31 Oct 2019 22:43:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Rezvl+z5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727462AbfJaWnK (ORCPT ); Thu, 31 Oct 2019 18:43:10 -0400 Received: from mail-yb1-f195.google.com ([209.85.219.195]:38262 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726506AbfJaWnK (ORCPT ); Thu, 31 Oct 2019 18:43:10 -0400 Received: by mail-yb1-f195.google.com with SMTP id w6so1529642ybj.5 for ; Thu, 31 Oct 2019 15:43:08 -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=wffmvJOuCjzexwiA9Y47Ehh0DUr7m1PyECllZf2CLXs=; b=Rezvl+z5g9RsrKkdX0aP/qJYj3rGaxbOTitT6BkKJUllnOkXEDEUcBIa6bpL/0dxIA Z5mPNrYVR68BH5onyRmGO1x+VMwQLwcNRNQkHT2UFybr+Bfzu5YSBxdeUwsqswTrQ+mW dZwRz2tTEALPBzaCRAaWiOpwNOENd35fk11b/76Jqgdx8aA0Dz9zqVA9qDtXchsLUuOu SmhQYCT97ZdxNbiCNoif424IfX2SYWFLd+G7zZEJjB7W2dM+PbVVnVVvoUvjsxG+CFxz EZJVwjaN7Fr3ByuJ77AJyWtASPvyTX9xqxaqFKtdPAlmSVOQglRNOmzXvlxCQcQGxX1s UG2A== 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=wffmvJOuCjzexwiA9Y47Ehh0DUr7m1PyECllZf2CLXs=; b=UBTX/ljxddfsnoIxpNaynLN11iaLuxl/N+EV1egpzhkODHPTHfkQpKfkzMivijkENJ sgZwWm08zsTpjqSeFAe6G6M99xy6jG+kAkGfkEjBlR7efbfuNqh0XjoO9unam+qgD5L+ yjJQ7fzt3k0xrEx3b57ODNR9F6tWBYSIXHulQGh++e7QCERlSidnlCVeOyPHtdCO66bu czUdqWZRpcxc8oUNrnOZgUoZHtM3/jDzkcUP1/J+Necnu2YyhE1zr1jnwTT6GFf+s/Wq mFZHChZJGW3hcuu4qYn4X2p0B/biV7QavX+7mEy44oZB7sItXh/gY/VvC+u5Ge2xQJrR pshw== X-Gm-Message-State: APjAAAVL0Plrbed7P0Ss5IIwiZPFXyTM6goQS0q6+PWBAVBMjoAE36Kl RiNhc3g/vKVVa9muMxVep3FBLY0= X-Google-Smtp-Source: APXvYqz8f5ryy59RcyQXewajrc6Tt1pnWjS7aUjcO7NA7P1oVThDJo1KdZSr0ZTjB8UGCWJLObQwWQ== X-Received: by 2002:a25:4643:: with SMTP id t64mr6714427yba.498.1572561787432; Thu, 31 Oct 2019 15:43:07 -0700 (PDT) Received: from localhost.localdomain ([50.105.87.1]) by smtp.gmail.com with ESMTPSA id d192sm1720287ywb.3.2019.10.31.15.43.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 15:43:06 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 04/20] NFSv4: nfs4_callback_getattr() should ignore revoked delegations Date: Thu, 31 Oct 2019 18:40:35 -0400 Message-Id: <20191031224051.8923-5-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191031224051.8923-4-trond.myklebust@hammerspace.com> References: <20191031224051.8923-1-trond.myklebust@hammerspace.com> <20191031224051.8923-2-trond.myklebust@hammerspace.com> <20191031224051.8923-3-trond.myklebust@hammerspace.com> <20191031224051.8923-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 the delegation has been revoked, ignore it. Signed-off-by: Trond Myklebust --- fs/nfs/callback_proc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c index db3e7771e597..cd4c6bc81cae 100644 --- a/fs/nfs/callback_proc.c +++ b/fs/nfs/callback_proc.c @@ -26,7 +26,6 @@ __be32 nfs4_callback_getattr(void *argp, void *resp, struct cb_getattrargs *args = argp; struct cb_getattrres *res = resp; struct nfs_delegation *delegation; - struct nfs_inode *nfsi; struct inode *inode; res->status = htonl(NFS4ERR_OP_NOT_IN_SESSION); @@ -47,9 +46,8 @@ __be32 nfs4_callback_getattr(void *argp, void *resp, -ntohl(res->status)); goto out; } - nfsi = NFS_I(inode); rcu_read_lock(); - delegation = rcu_dereference(nfsi->delegation); + delegation = nfs4_get_valid_delegation(inode); if (delegation == NULL || (delegation->type & FMODE_WRITE) == 0) goto out_iput; res->size = i_size_read(inode); From patchwork Thu Oct 31 22:40:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11221965 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 8942614E5 for ; Thu, 31 Oct 2019 22:43:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6669B2087F for ; Thu, 31 Oct 2019 22:43:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Txih3q9X" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727482AbfJaWnN (ORCPT ); Thu, 31 Oct 2019 18:43:13 -0400 Received: from mail-yw1-f68.google.com ([209.85.161.68]:34737 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726506AbfJaWnM (ORCPT ); Thu, 31 Oct 2019 18:43:12 -0400 Received: by mail-yw1-f68.google.com with SMTP id z144so1170882ywd.1 for ; Thu, 31 Oct 2019 15:43: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=TfZVcSzmWXLHAI2RilE5A2qvNvo3cZYOLKr7++TYasQ=; b=Txih3q9XiNr9biu+aLby4Td6GNKkvEnwDzUfHs2UqPJOuVwrk1K4FTd6WLNfe57tgS FD+bZDuz8psDixQlN8+31xykGWYBt2wrUyBYG8Ro+3QsyBkYOTmDWrpp69C7VgzSI0Yp 0thBM3k+3nwtmlNwv8GWT+RyQi9m+eaeWKcoHFOSBpaQucBu8mOqSvlABD+5pXBgNdnn OQojRgN7Wx+BL+x1SKsLvyzgbhPtwNDB05aFtHwG9ZwIk0XJ6vTYdUIIiIpkIzUq7JDo 4gXIfI8Zo2jaSTOICobLQIwUjzGXWiQbCOX1X2MHNatkwKq3DvjzoN41M4X3yuPALjhT dLhQ== 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=TfZVcSzmWXLHAI2RilE5A2qvNvo3cZYOLKr7++TYasQ=; b=jQz6aCey7y0PE+CBacIBiz+glNorPwa6dltEOcD9JA+VAlvZM0A+4g3cdICkxi7cQt 0zhE2ullZuBgEvLHFWHfeE+grdEdfURBcziuVmoYJ1R2E+DuaFD7aq1PJdITuU+Kd/uk MFt3Q2CIimJhuh6nQouwQdYzu6alGmQGRfVA/XqQf2IOlSpvXKJeRlZdSrgjMnD7QnLD WwsDRalAj08PCGUFwztWCS0R/qDvsF7jWvfotBo3HZM8V4z5sTl2pyeTbB16o1u9uUaF 9Sj/v3fWbD1NTal+kSA7T/KJbxLD5krf28ghBzCHzhCnHbZh+71hVvOweHALenOYqmt/ q2eA== X-Gm-Message-State: APjAAAWBRWP4zQCEaGzi44vNLkP9jfieAWRDUR2frkTEj9pqg7YcG2Wn JVUxxg2F9ZsItgNEF0dpCpyTosw= X-Google-Smtp-Source: APXvYqyGc50kovm4JxkCO8pLB6CSq4/PjQP/FhaKxoDHXl+w0yAdRnnn5/CtMNAH0y9bzuya0aUQ9A== X-Received: by 2002:a81:2a08:: with SMTP id q8mr6343465ywq.195.1572561789342; Thu, 31 Oct 2019 15:43:09 -0700 (PDT) Received: from localhost.localdomain ([50.105.87.1]) by smtp.gmail.com with ESMTPSA id d192sm1720287ywb.3.2019.10.31.15.43.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 15:43:08 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 05/20] NFSv4: Delegation recalls should not find revoked delegations Date: Thu, 31 Oct 2019 18:40:36 -0400 Message-Id: <20191031224051.8923-6-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191031224051.8923-5-trond.myklebust@hammerspace.com> References: <20191031224051.8923-1-trond.myklebust@hammerspace.com> <20191031224051.8923-2-trond.myklebust@hammerspace.com> <20191031224051.8923-3-trond.myklebust@hammerspace.com> <20191031224051.8923-4-trond.myklebust@hammerspace.com> <20191031224051.8923-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 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 af549d70ec50..c34bb81d37e2 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -840,7 +840,7 @@ int nfs_async_inode_return_delegation(struct inode *inode, struct nfs_delegation *delegation; rcu_read_lock(); - delegation = rcu_dereference(NFS_I(inode)->delegation); + delegation = nfs4_get_valid_delegation(inode); if (delegation == NULL) goto out_enoent; if (stateid != NULL && @@ -866,6 +866,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 Thu Oct 31 22:40:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11221967 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 0927D13BD for ; Thu, 31 Oct 2019 22:43:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DAED32087F for ; Thu, 31 Oct 2019 22:43:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Gv3X9sYr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726506AbfJaWnN (ORCPT ); Thu, 31 Oct 2019 18:43:13 -0400 Received: from mail-yw1-f65.google.com ([209.85.161.65]:34735 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727611AbfJaWnN (ORCPT ); Thu, 31 Oct 2019 18:43:13 -0400 Received: by mail-yw1-f65.google.com with SMTP id z144so1170883ywd.1 for ; Thu, 31 Oct 2019 15:43: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=UlqTHE9RJ9ECVULqQDQnX713O/HJPvYKOpACXCXCWSg=; b=Gv3X9sYrbGOtIElJQq9KkNDi9vyL7x9RXdyQV3I6nsKP8SeoQxXITX93r/NepiYPQo O97wxR8ZJ+SwKJ+2VRK4BeBSAFJNPFbi793DXFh5xlAB/P2ZA7iFIN+I9gD5lFkxhS3q dGlF00blonqiy+hZBgFE4Et/5/wo2ycuV6r/Ep0+2J59FAv/yBTzb+4RNJrbapV+EruH Goh2Kg+CyvbVu4TB+9BAB9/Qbne11T2/IgYfuSLMMyXNIzbFeSvrjMqqx52hT7uvRcpn lhCUMxfkfkCsEEGxZot7sUBwdxWbuSwG4po+hCt3/vaOZWxspEjz//daR/3h9p1wiVwR 2CMw== 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=UlqTHE9RJ9ECVULqQDQnX713O/HJPvYKOpACXCXCWSg=; b=UyE8wW+TKKz4bVju/8+VMVYEIJOZ4VmAKlFCzyYJ0wmyYGhyJvkk1kl3tSeu3aC9eI vMgFMzXRClaUXX4HSkzoQnssyrjmdrToyowcoGoJ51IRNLa6OaGlCADWPJcMXhpf2OlQ 1lmo/0FADlrmeUXalM+vqot0/C+SLej9lvuxDYEa8yk8SS0GIl2D/SUSvRfjHQpdm2RP etfggKxHL1M2kihVqAMm5eP/qp0PGmRgL8t/LA+QqAkj6OSFmm4i539QfG6yrex8NiTb cXkTbQJ+fZuGbgdWyR6xlDIl94egytcLXFARAX4dB3ChKnJMWx0azs7gRp8mzJ/kTs85 zENA== X-Gm-Message-State: APjAAAV7dSpAfpcJb2zd4xlKQyo7pOmtsTBJuXwIscrMTw/BUqeKYSou SFNSh7Dpw/oEq7cVGW13WE2ZKPw= X-Google-Smtp-Source: APXvYqyIFiRPUNhx8HnrTh9n2np27vWhXL+WYpqZnYuwe1nRssQY4IoaEJmLJ3AZ2TovFflPfR2Axg== X-Received: by 2002:a81:b188:: with SMTP id p130mr4829632ywh.482.1572561791369; Thu, 31 Oct 2019 15:43:11 -0700 (PDT) Received: from localhost.localdomain ([50.105.87.1]) by smtp.gmail.com with ESMTPSA id d192sm1720287ywb.3.2019.10.31.15.43.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 15:43:10 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 06/20] NFSv4: fail nfs4_refresh_delegation_stateid() when the delegation was revoked Date: Thu, 31 Oct 2019 18:40:37 -0400 Message-Id: <20191031224051.8923-7-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191031224051.8923-6-trond.myklebust@hammerspace.com> References: <20191031224051.8923-1-trond.myklebust@hammerspace.com> <20191031224051.8923-2-trond.myklebust@hammerspace.com> <20191031224051.8923-3-trond.myklebust@hammerspace.com> <20191031224051.8923-4-trond.myklebust@hammerspace.com> <20191031224051.8923-5-trond.myklebust@hammerspace.com> <20191031224051.8923-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 If the delegation was revoked, we don't want to retry the delegreturn. 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 c34bb81d37e2..630167e243be 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -1190,7 +1190,8 @@ bool nfs4_refresh_delegation_stateid(nfs4_stateid *dst, struct inode *inode) rcu_read_lock(); delegation = rcu_dereference(NFS_I(inode)->delegation); if (delegation != NULL && - nfs4_stateid_match_other(dst, &delegation->stateid)) { + nfs4_stateid_match_other(dst, &delegation->stateid) && + !test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) { dst->seqid = delegation->stateid.seqid; ret = true; } From patchwork Thu Oct 31 22:40:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11221969 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 254B313BD for ; Thu, 31 Oct 2019 22:43:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0507A2087F for ; Thu, 31 Oct 2019 22:43:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Gy5p46Tl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727624AbfJaWnO (ORCPT ); Thu, 31 Oct 2019 18:43:14 -0400 Received: from mail-yb1-f194.google.com ([209.85.219.194]:38265 "EHLO mail-yb1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727611AbfJaWnO (ORCPT ); Thu, 31 Oct 2019 18:43:14 -0400 Received: by mail-yb1-f194.google.com with SMTP id w6so1529775ybj.5 for ; Thu, 31 Oct 2019 15:43: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=JF4c76sI+h5J2OwX5ENMfoC6j5DXu//F/qWIv+iv3q0=; b=Gy5p46Tl1+G3B5erIQTB/OsufbXW8OXFq6QT9HGnbys4Wwzr+pQdF3ueq1OahMRIQW 2khs0Z+NyXEFqpuw5jeXqFJ8Q0cdnVHNs7vodgj4LOlwNlNIdp6EGOJS8zuAjQUnnacz ror96Sn7kYvPmYVUW4Tjv6kgzY2bAAt5Lgc216f1QtX3EZdD+T+TtDlhglTbH5XbhXYS ONR0sutsi6RpbaMa977MJnZ6kAIy+M4VUDNLo59JSkfdC9/Rqt0gQPAltGrSa2HMeWk+ qoZFimGKPIpvJnl26zBkvP5XBza2Oc02L+vBSXSw8H0wknTq59brs7bKvq3jrRhi3vdV Dk7Q== 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=JF4c76sI+h5J2OwX5ENMfoC6j5DXu//F/qWIv+iv3q0=; b=LeMOhGfq1y8K3h+D/I9tzlML4n/j6Qtqwp0bBk4x2XYxJy9+oJR4Ud9KsrpdcCAPoG V1k1fJjxO4km8p6BcoUpMri37eLUQfGGA7msDS3E021jQz+oWLUNBi4vS54XAN6wPUpG qWS+AI6I0qLoxxNHhExWgQRfoCvg7d8RtTF64QG5uMycAPSBVM7MAeB8zzy1ESgeRqAY 3EfZ1eKx08+u7kAqb8PXgqAFmrEErR3WkK60t4+Om9uJP1oyqYgp1o481Bw9i78jWC/q xaNagy3wvVqYO1Hg7kCbgyKXghonZRImu15aJYi+gHbeT9oK9E2bIU03zK0T/Q6pMctq Am9Q== X-Gm-Message-State: APjAAAVP0o3If7Q3rY9BVad0drWtYLRQhI8a4OKf9q39rQYWJyqLW35m LWK+MTED4TTwTgBQaWqpz/5h7t4= X-Google-Smtp-Source: APXvYqyyWqRe9gMvvL72y8K4Tr0IojYYExC/fDFLF+uV80lqWjQsQxk04z2x0y/gTAlcIQc96JNj3Q== X-Received: by 2002:a25:7395:: with SMTP id o143mr6734752ybc.190.1572561792910; Thu, 31 Oct 2019 15:43:12 -0700 (PDT) Received: from localhost.localdomain ([50.105.87.1]) by smtp.gmail.com with ESMTPSA id d192sm1720287ywb.3.2019.10.31.15.43.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 15:43:11 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 07/20] NFS: Rename nfs_inode_return_delegation_noreclaim() Date: Thu, 31 Oct 2019 18:40:38 -0400 Message-Id: <20191031224051.8923-8-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191031224051.8923-7-trond.myklebust@hammerspace.com> References: <20191031224051.8923-1-trond.myklebust@hammerspace.com> <20191031224051.8923-2-trond.myklebust@hammerspace.com> <20191031224051.8923-3-trond.myklebust@hammerspace.com> <20191031224051.8923-4-trond.myklebust@hammerspace.com> <20191031224051.8923-5-trond.myklebust@hammerspace.com> <20191031224051.8923-6-trond.myklebust@hammerspace.com> <20191031224051.8923-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 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 630167e243be..0c9339d559f5 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -585,19 +585,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 8b14d441e699..74b7fb601365 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 Thu Oct 31 22:40:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11221971 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 74F1615AB for ; Thu, 31 Oct 2019 22:43:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 53B7E2087F for ; Thu, 31 Oct 2019 22:43:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XPiKPVsc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727648AbfJaWnP (ORCPT ); Thu, 31 Oct 2019 18:43:15 -0400 Received: from mail-yw1-f65.google.com ([209.85.161.65]:46157 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727611AbfJaWnP (ORCPT ); Thu, 31 Oct 2019 18:43:15 -0400 Received: by mail-yw1-f65.google.com with SMTP id i2so2772689ywg.13 for ; Thu, 31 Oct 2019 15:43: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=L7PIPNwTpokXVUro30nAvcF3QqeHNnOPKiyU17Tyl8w=; b=XPiKPVscbO9G8foqjNsdvSjaAP1BgR/8GAllFraNT2fXXaCkO12fl164X2/vYr5M6Q rw0R3Xqp7PZVYekqH5IU+WuuqdzbKEe0jKXruioa8vuoouOar+BlZIShiro9JgGec6o4 Rv9IGIdM4QjHL06VUyoqQ0P2TxaCNrVh0ajRR2AdCerj81ojVdqiOZDfx3h0IpCmGy5M RJpA/f6j6StFlEEFG7BAFiEqwr3me/C1xSBJKJeEd9IEI8BAUjiJ1VjB7dDnRZSBC20Y MheA/vdvK37QYEdkrz4GtZrOPdwi1h2R89MvQRI/wYpWjPwjJ5tQRG/tsgF/BWADYLKN RjRw== 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=L7PIPNwTpokXVUro30nAvcF3QqeHNnOPKiyU17Tyl8w=; b=g3m5Ru7UaerPkeJj2wQt19ibDB6XQRhew2ViAaBBn1GkOU4/g2RFQq5A0w4DyUu0f7 C0myNfZY/eqOIqSM7sNvS+Hc9f0JpVo1jhNl8ifdnA3zlcyURj3s9eKAlwIX7QKko12W YfFyOyBNQ7K/a1UPV2DDyFwC+36QMbyP6voc6ioXhbexVa1U6D54DnLYzJbi+FVP3jFV /5zPKxUz5cQukeOTBJe0+Zhg0rEgBBXs+sAC7G0DA1wgkevfMWhYMbzzqYBtnwLimyJU CXub0NUUtf2wYHlmiy6PV+QIwj2V2bkuWxrwq9vORpE94+hWAfPriRATf76Zerw1eF6U 83VA== X-Gm-Message-State: APjAAAWHG0QjBms3fVTgD61B9efriNspjMNSF5A+CoEh7kqB6Up05Cnd yzZiahGrSYm0BuxEIAESBtEqZeQ= X-Google-Smtp-Source: APXvYqxuMrFqkzVSZUVTHR1cxbtU0pWW3GW2MDGoZuMC+OGzIcVE5F0oFS02CkLc7gR3vW5PDnDhVQ== X-Received: by 2002:a81:2d57:: with SMTP id t84mr6237469ywt.426.1572561794213; Thu, 31 Oct 2019 15:43:14 -0700 (PDT) Received: from localhost.localdomain ([50.105.87.1]) by smtp.gmail.com with ESMTPSA id d192sm1720287ywb.3.2019.10.31.15.43.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 15:43:13 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 08/20] NFSv4: Don't remove the delegation from the super_list more than once Date: Thu, 31 Oct 2019 18:40:39 -0400 Message-Id: <20191031224051.8923-9-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191031224051.8923-8-trond.myklebust@hammerspace.com> References: <20191031224051.8923-1-trond.myklebust@hammerspace.com> <20191031224051.8923-2-trond.myklebust@hammerspace.com> <20191031224051.8923-3-trond.myklebust@hammerspace.com> <20191031224051.8923-4-trond.myklebust@hammerspace.com> <20191031224051.8923-5-trond.myklebust@hammerspace.com> <20191031224051.8923-6-trond.myklebust@hammerspace.com> <20191031224051.8923-7-trond.myklebust@hammerspace.com> <20191031224051.8923-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 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 0c9339d559f5..e80419a63fb5 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -298,6 +298,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 Thu Oct 31 22:40:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11221973 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 BC8E014E5 for ; Thu, 31 Oct 2019 22:43:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9A47E2087F for ; Thu, 31 Oct 2019 22:43:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pUw6daur" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727700AbfJaWnR (ORCPT ); Thu, 31 Oct 2019 18:43:17 -0400 Received: from mail-yb1-f194.google.com ([209.85.219.194]:45993 "EHLO mail-yb1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727611AbfJaWnQ (ORCPT ); Thu, 31 Oct 2019 18:43:16 -0400 Received: by mail-yb1-f194.google.com with SMTP id q143so3089016ybg.12 for ; Thu, 31 Oct 2019 15:43: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=aOsiBYJF0l/VKWVtAB4TMzJF5AIwWrJk7gYaSmC5YBE=; b=pUw6daurKLdYcI3ttsS2R1+v8huzbX/wuM1gpHWnXeYa4MFsLHjACnw5FVFCAQ3UxG qzAXTRJkt/FbzPdl3UQIOz3ln1cUe9LE159DSYUbi6xXeqLDshvvz1goYkKX8fMQE/sY 1EQY+M4eSC/YGVkjmh140QmIdbT6onJ0d0WG6SGAn5WgZNtifLfS6L+I0b85a6vlC57l l/pCJpBJsoyhWxFZVX3GOE603eF5e7aKPsBL47w+CxV1YCr+pLwrk5HP2htR2BFIezHB Lz3ddnk8jWMINU8noP1heXQrpCtEE/6e0t+JhgnLQV7cllKIVVv5Lqk5F8T36eY64JLT WP2g== 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=aOsiBYJF0l/VKWVtAB4TMzJF5AIwWrJk7gYaSmC5YBE=; b=W3c+TccFP34QxDCCqI/iFENvusWmSSLuPOR9B0DdEu19mGOGIxPa20wLs8btBk6mM6 BwVfLujpH6hFj4BGZrf/kaD1tqThweCWheMA9iaUd8c7CzCH96AZ7R7tKTHfOroU+DG5 BH+8IrLLF5pPYPl3tO+iYgAcelEJBZ0kOuc6Bi7m3Kr4pTxTvJuRTxPxk5RgxW/ukcc3 iUkeiTHGg0B3SjjuBOys341z7XGZOWuK1AKAdMF5xg7Kyd4EVumwSqQUbahvphGq7rli n2NJmw/Jd7MaeyUqodOWggDMINFd4QLvhv5QmLQbWhG7ArY6ybBdM2pvNvlj3RggZ6eu Bc8w== X-Gm-Message-State: APjAAAXc0rvC3mv6RNug02MqUtS5vUtkwj+E7h1K+eBf1VidTtn6mdSb B6mGsfvHsstNVdLxhKqpe9vTKLU= X-Google-Smtp-Source: APXvYqwaU5Jj43B+pvaFQMvJ1c2+KW0kN6GF2SObI8tUYfs72EkawEWMhDgyrCGYo8zMf2CFX4KbtA== X-Received: by 2002:a25:c5c1:: with SMTP id v184mr6651909ybe.457.1572561795433; Thu, 31 Oct 2019 15:43:15 -0700 (PDT) Received: from localhost.localdomain ([50.105.87.1]) by smtp.gmail.com with ESMTPSA id d192sm1720287ywb.3.2019.10.31.15.43.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 15:43:14 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 09/20] NFSv4: Hold the delegation spinlock when updating the seqid Date: Thu, 31 Oct 2019 18:40:40 -0400 Message-Id: <20191031224051.8923-10-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191031224051.8923-9-trond.myklebust@hammerspace.com> References: <20191031224051.8923-1-trond.myklebust@hammerspace.com> <20191031224051.8923-2-trond.myklebust@hammerspace.com> <20191031224051.8923-3-trond.myklebust@hammerspace.com> <20191031224051.8923-4-trond.myklebust@hammerspace.com> <20191031224051.8923-5-trond.myklebust@hammerspace.com> <20191031224051.8923-6-trond.myklebust@hammerspace.com> <20191031224051.8923-7-trond.myklebust@hammerspace.com> <20191031224051.8923-8-trond.myklebust@hammerspace.com> <20191031224051.8923-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 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 e80419a63fb5..7ebeb57cb597 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -387,8 +387,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 Thu Oct 31 22:40:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11221975 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 0C5EB13BD for ; Thu, 31 Oct 2019 22:43:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DE0F12087F for ; Thu, 31 Oct 2019 22:43:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PADw7enr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727807AbfJaWnS (ORCPT ); Thu, 31 Oct 2019 18:43:18 -0400 Received: from mail-yw1-f67.google.com ([209.85.161.67]:37976 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727611AbfJaWnS (ORCPT ); Thu, 31 Oct 2019 18:43:18 -0400 Received: by mail-yw1-f67.google.com with SMTP id s6so2790745ywe.5 for ; Thu, 31 Oct 2019 15:43: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=cvclt5ZKF/aNwsCBDjZ1qV6Hx5xfjUTWrsbcRqD5wGI=; b=PADw7enr170FiCidlbcNy5reryUqvqhcSjG7n+eVVYhTyzoOTMQsoK32jjbMIopPzJ C1u3f+jJj6o07a/VX/jyOOm5WNSdpG7RpbkroBwndRTw3vEBY8P48naTlleGgvOhWHai MjYMfQGo52h+54oojxWY8mH/BURuvFTIgEym3zdQZj61BtozJZNECXIhj2mDh/nHKXAx n4BbidpKSsvAlGhef+k/og5xdfLbz5sA+J4MCw+ZOoh6V9Ixu50WA+lXlTnYwA60N9Li 78Z+rG6YlrLuQSjud/4K6U4XxAa2tdEN9Wl2ZgHGTThgQpXQO0k2oU9o5rMPatp+ak6O Qg1w== 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=cvclt5ZKF/aNwsCBDjZ1qV6Hx5xfjUTWrsbcRqD5wGI=; b=ZoMcEJpbvRFRNtBOZsPY/HoDthqyYWqTH3qxrv2dqDlx60erlpUaqCNmaQmteSlT2v /qcXRroTACXQ1QaPefE2UvLtX9npaNakFBKVfIFfc/BUvvf9YiodrsqYjEwPSHkQDooO ebwMkHQEpx9WIXESvU1j3aDk/vh8cgP6Nai7BQBK6xxfGYYO56j3n0L8FefQxAhMRm91 wsUx0BFxX5B+cz1ah1ES/5E9kq8vBxK6IJDd5PzRSkMgBOKNKNQNvDuNs0HRVDkgD2Rd 3uxJIwgLz1B4NvCbCWeDOQwxcijcYLP90LBVAiPw/waTbGQpQyNunkgCoNPwaLaR2Usk J1Bw== X-Gm-Message-State: APjAAAUVlt9V/+3gdn+4IrUbyL2lMD1KfYoCcyMAnWE8G8LusSzG4wvo 9JgyKFmp/zpOpGFGTbUKHmD0Jb0= X-Google-Smtp-Source: APXvYqw1Ys8/6u5WwLInDbpC1jTv6XdO5QsxrbKBP1yo2vVm3JVu9j05NLiryijJZtEVbBGeB2+/Pw== X-Received: by 2002:a0d:c802:: with SMTP id k2mr6288716ywd.358.1572561796656; Thu, 31 Oct 2019 15:43:16 -0700 (PDT) Received: from localhost.localdomain ([50.105.87.1]) by smtp.gmail.com with ESMTPSA id d192sm1720287ywb.3.2019.10.31.15.43.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 15:43:15 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 10/20] NFSv4: Clear the NFS_DELEGATION_REVOKED flag in nfs_update_inplace_delegation() Date: Thu, 31 Oct 2019 18:40:41 -0400 Message-Id: <20191031224051.8923-11-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191031224051.8923-10-trond.myklebust@hammerspace.com> References: <20191031224051.8923-1-trond.myklebust@hammerspace.com> <20191031224051.8923-2-trond.myklebust@hammerspace.com> <20191031224051.8923-3-trond.myklebust@hammerspace.com> <20191031224051.8923-4-trond.myklebust@hammerspace.com> <20191031224051.8923-5-trond.myklebust@hammerspace.com> <20191031224051.8923-6-trond.myklebust@hammerspace.com> <20191031224051.8923-7-trond.myklebust@hammerspace.com> <20191031224051.8923-8-trond.myklebust@hammerspace.com> <20191031224051.8923-9-trond.myklebust@hammerspace.com> <20191031224051.8923-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 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 7ebeb57cb597..a0f798d3c74f 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -343,6 +343,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 Thu Oct 31 22:40:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11221977 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 497F414E5 for ; Thu, 31 Oct 2019 22:43:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2746E2087F for ; Thu, 31 Oct 2019 22:43:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GrX8UUOE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727842AbfJaWnT (ORCPT ); Thu, 31 Oct 2019 18:43:19 -0400 Received: from mail-yw1-f66.google.com ([209.85.161.66]:39247 "EHLO mail-yw1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727611AbfJaWnT (ORCPT ); Thu, 31 Oct 2019 18:43:19 -0400 Received: by mail-yw1-f66.google.com with SMTP id k127so2785386ywc.6 for ; Thu, 31 Oct 2019 15:43: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=IIX8Z8mWhJCHEQrj2Qtpg+z0E9LTeoAQUosLeSg92SE=; b=GrX8UUOEE74gx4N6R9jjmg05RjAYoXRJo0GQtZXgwXmgtUcd4UbVt6BIsJy7wskcvy xX3Yk/832jWeOkEkAF78h1O9l12lui/Ky0/sc5FfCD8SvgQwdoXkpNnmFD5awhr35zgS GBvr3e3557X+CNYoET5y4HD+FKJbfQfAkC3ABxEbvNoRC+1FpYjGtRz971FsLLiAwp+g BZbCLFshUog4FiHjJ56jTBIiQfCWXBCfIaTmgpecsOMrsdfHClU3Ii1iJs8wFd5X9IQL KL/+T+S4wzPxS55KPmNxiQ3OBVy6Hq1VfOOL4phTbYsIe/xLDsON85kQiAwGZRlxTH1P 8dtQ== 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=IIX8Z8mWhJCHEQrj2Qtpg+z0E9LTeoAQUosLeSg92SE=; b=c/8o5L1wFQS1ogc5u+h/Bz71jZQ4MaUSM1YbVUQRWb9EH9NfWXmCmPWtaioTBY5bRW sO5E/K2LU+AmqCDbMh2NtqupOty8nrhEhI3XAzfllwQMslI5Q2Ank7bY0uV5Oksl0mDz ucrX65N4Q0xFWXKqv2hicrNIPHPTEh3E6i2bnI92LeLw44LyL/nSOdLD46I6T5C3sGYq QgLFHYlQdZ0bsSQ2upe1l5aiU03Opk5Pnx8Z2WoRK/4nKtc/n85AIy6BYNnOF6zlWmqp 6NMOzW7Hw6j8neQHZAzmnVvrXoyHEZE6+86PLEd1AHU94jF7jDSI2ZWF1kXKbUOYUALx HSoA== X-Gm-Message-State: APjAAAW/In9GFf8gSye1DycEzUijbK2cqknWZKGGMnbRTZ4rffLZLfK3 eYYT/h/Bhby5Bv3fWqkUbWjVB/c= X-Google-Smtp-Source: APXvYqynU34EB/oZC+bMsuNWo8HsG6zep9SZsgNv2lmgAs4iN6FJVeYq+qFzdOuUT1S7JLTBPkMTuw== X-Received: by 2002:a81:9ad3:: with SMTP id r202mr6407754ywg.152.1572561797912; Thu, 31 Oct 2019 15:43:17 -0700 (PDT) Received: from localhost.localdomain ([50.105.87.1]) by smtp.gmail.com with ESMTPSA id d192sm1720287ywb.3.2019.10.31.15.43.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 15:43:17 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 11/20] NFSv4: Update the stateid seqid in nfs_revoke_delegation() Date: Thu, 31 Oct 2019 18:40:42 -0400 Message-Id: <20191031224051.8923-12-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191031224051.8923-11-trond.myklebust@hammerspace.com> References: <20191031224051.8923-1-trond.myklebust@hammerspace.com> <20191031224051.8923-2-trond.myklebust@hammerspace.com> <20191031224051.8923-3-trond.myklebust@hammerspace.com> <20191031224051.8923-4-trond.myklebust@hammerspace.com> <20191031224051.8923-5-trond.myklebust@hammerspace.com> <20191031224051.8923-6-trond.myklebust@hammerspace.com> <20191031224051.8923-7-trond.myklebust@hammerspace.com> <20191031224051.8923-8-trond.myklebust@hammerspace.com> <20191031224051.8923-9-trond.myklebust@hammerspace.com> <20191031224051.8923-10-trond.myklebust@hammerspace.com> <20191031224051.8923-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 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 a0f798d3c74f..aff2416dc277 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -771,8 +771,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 Thu Oct 31 22:40:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11221979 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 2C55D14E5 for ; Thu, 31 Oct 2019 22:43:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 08E8C208C0 for ; Thu, 31 Oct 2019 22:43:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PtmeXKAc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727843AbfJaWnV (ORCPT ); Thu, 31 Oct 2019 18:43:21 -0400 Received: from mail-yw1-f65.google.com ([209.85.161.65]:44317 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727611AbfJaWnV (ORCPT ); Thu, 31 Oct 2019 18:43:21 -0400 Received: by mail-yw1-f65.google.com with SMTP id a83so1367842ywe.11 for ; Thu, 31 Oct 2019 15:43: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=P51JCY1PLmq4de1gWwd77QKvlBGJp+uxbI5eEyjCy3k=; b=PtmeXKAcgx2Slqs5sTD17PxRN/E9LyvEACvd9YNLYHgnzo50/ypkfVL/nkS45yS/hp LfSl1g4pBALviei29B6PtcLn7V4+Kytd8y50Ec93huidHybfkli5p8eGX46BlCiiS46s oVCNN+3RURNhma0JiYAlMQKdgwJlwIvEPwZ7f3qUA5iJ4Aad53RLrGKuXClsnseihGfO j3wiOZW3K2lfat0qslUMHzKp/niyzH+ceE7U416jZNZbsFHnWUQGSmNvKTed+Ky43xTp SbEeBy9c7VeyrFKCycJyFe8l+6lnEKeUVeha1b2zEd8bM4yv6a6XeSMGFNtmNBolJDYg crIQ== 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=P51JCY1PLmq4de1gWwd77QKvlBGJp+uxbI5eEyjCy3k=; b=AM+hArrODQH2HRtkcvws/3xNE/rd1Re+5MFOxm6q/feqvW/MdIoI8S51zvUe8bu7PO hggtFWkTssUV/+Rz+NVtwZl/pXQEENyIu/i+urDNsd4i5Rr/6KkWcYXntNWhKn7Bo4x5 ncRSyIF420kV4gpduh5NBMKZwpEpBi3ddzGSarNhyZblylHZc4D9UWl1efW/M643UDhd wu1h1hC/YzetgCUgewzcVIel24jj/TChQxMeWLzZUcfcNHNTih7nttl5WX/Oyy6EkTDo SuliPFKR9DNXamxkWkfz+94SaaoWB5IxcCfRv0afizVtgXQSH/pcMnVHytje8PN2oHRu 3gBQ== X-Gm-Message-State: APjAAAWoYeAtSp7ELLgLcMyzBI4IbEgP/aeTCIjRBGIdO9MLECOBkH+a AJ6TxZCRUZP0yHmRzqS423Cs1vc= X-Google-Smtp-Source: APXvYqwWZnNIYk4ra7Qyw85/BrRhRwTc24CyU3giBpv80SlG0k9VKo6MVLUzZ4emTUprjtvbrW5qvQ== X-Received: by 2002:a81:27cd:: with SMTP id n196mr6362657ywn.148.1572561799809; Thu, 31 Oct 2019 15:43:19 -0700 (PDT) Received: from localhost.localdomain ([50.105.87.1]) by smtp.gmail.com with ESMTPSA id d192sm1720287ywb.3.2019.10.31.15.43.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 15:43:18 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 12/20] NFSv4: Revoke the delegation on success in nfs4_delegreturn_done() Date: Thu, 31 Oct 2019 18:40:43 -0400 Message-Id: <20191031224051.8923-13-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191031224051.8923-12-trond.myklebust@hammerspace.com> References: <20191031224051.8923-1-trond.myklebust@hammerspace.com> <20191031224051.8923-2-trond.myklebust@hammerspace.com> <20191031224051.8923-3-trond.myklebust@hammerspace.com> <20191031224051.8923-4-trond.myklebust@hammerspace.com> <20191031224051.8923-5-trond.myklebust@hammerspace.com> <20191031224051.8923-6-trond.myklebust@hammerspace.com> <20191031224051.8923-7-trond.myklebust@hammerspace.com> <20191031224051.8923-8-trond.myklebust@hammerspace.com> <20191031224051.8923-9-trond.myklebust@hammerspace.com> <20191031224051.8923-10-trond.myklebust@hammerspace.com> <20191031224051.8923-11-trond.myklebust@hammerspace.com> <20191031224051.8923-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 successfully returned, then mark it as revoked. Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 36 ++++++++++++++++++++++++++++++++++++ fs/nfs/delegation.h | 1 + fs/nfs/nfs4proc.c | 1 + 3 files changed, 38 insertions(+) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index aff2416dc277..8c176c921554 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -806,6 +806,42 @@ 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) { + /* If delegation->stateid is newer, dont mark as returned */ + if (nfs4_stateid_is_newer(&delegation->stateid, stateid)) + goto out_clear_returning; + if (delegation->stateid.seqid != stateid->seqid) + delegation->stateid.seqid = stateid->seqid; + } + + 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 74b7fb601365..15d3484be028 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 217885e32852..a222122e7151 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -6214,6 +6214,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 Thu Oct 31 22:40:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11221981 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 871E913BD for ; Thu, 31 Oct 2019 22:43:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 63F2120873 for ; Thu, 31 Oct 2019 22:43:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aKyv7pmF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727874AbfJaWnW (ORCPT ); Thu, 31 Oct 2019 18:43:22 -0400 Received: from mail-yw1-f67.google.com ([209.85.161.67]:34741 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727611AbfJaWnW (ORCPT ); Thu, 31 Oct 2019 18:43:22 -0400 Received: by mail-yw1-f67.google.com with SMTP id z144so1171053ywd.1 for ; Thu, 31 Oct 2019 15:43:22 -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=qYeYsKsnEQ5L5JWo5ALncCCNlaTcoUQISGF0Hj9ravQ=; b=aKyv7pmFC9cflyqMwx2k/RjI3vKB+mVV0qgpPltswl0Zd4Wf5sjO8O5m+aU4Ng7E7C F3gQQLt1hguzS32Pdm61/kGHCFXqboTwavNRyFCaKgH+tynAUvowq1N4+nEcjssAVkZJ 1QVQF6GMGX02l+QnpcN5ThRUO8zbAXpS25vAuhQQOYAaxpkhFpxKVZEgH6HYGPpEtibn 61O+pkgkjRn7fYyBHLmfLBR9upJ5+eUIjlPfpEhLr3SYZ5/Po03pJb54h+o5Iy7/vqZ+ 0onIEijGRXN2+u/FbYf+CuhA5BpnEzlTVImNNWstDgHZmQ6GJiRCL/+gRxIM4KmqV6q7 abDw== 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=qYeYsKsnEQ5L5JWo5ALncCCNlaTcoUQISGF0Hj9ravQ=; b=kq2nYjnEV9d77qYjoFLBL9E99NLhs8rhe/QxVeW9pmY/iJXUGSO05s07mtSWiOma5E FeiECurZ+9CCJyFFgPSeS5g2HLWpHzIvHMoDM+Xwt4EKfFFMoElYIIvQ6SL3Dfl/Pzxh R2H6XiDZiKP8x5y0LTdCziS5NowdKEuw2a8vbS1rVQVCJaip7sHJNvUWxTK0/13xzp6M 8ABhZlBGq9xLfZXsL+ZKjEucLIeSuZNUoxk3uCu0DuzOqf+PPViHlulYeeVEZnmhhsL+ u9ddisI50Us1I32XZDbOAA8TRhE2eIA7fAYBZeqouxGffdt9ViiABuBjD4VQXEWcCRC3 3idQ== X-Gm-Message-State: APjAAAUXwOUeEzS5w8S8TBwuVkgYLcXdwU11bxdgqLWO1P4n/c43au06 V0K0O+EqcqhDzQQq8fsBzX058Ew= X-Google-Smtp-Source: APXvYqw6d7QIT9lUXU2IRHFEnDM1ceCf4Gz9GeO+6il2+qqO5T8r4lO+doDywpo8P/SeqAAbim7wnw== X-Received: by 2002:a81:6305:: with SMTP id x5mr6390327ywb.312.1572561801290; Thu, 31 Oct 2019 15:43:21 -0700 (PDT) Received: from localhost.localdomain ([50.105.87.1]) by smtp.gmail.com with ESMTPSA id d192sm1720287ywb.3.2019.10.31.15.43.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 15:43:20 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 13/20] NFSv4: Ignore requests to return the delegation if it was revoked Date: Thu, 31 Oct 2019 18:40:44 -0400 Message-Id: <20191031224051.8923-14-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191031224051.8923-13-trond.myklebust@hammerspace.com> References: <20191031224051.8923-1-trond.myklebust@hammerspace.com> <20191031224051.8923-2-trond.myklebust@hammerspace.com> <20191031224051.8923-3-trond.myklebust@hammerspace.com> <20191031224051.8923-4-trond.myklebust@hammerspace.com> <20191031224051.8923-5-trond.myklebust@hammerspace.com> <20191031224051.8923-6-trond.myklebust@hammerspace.com> <20191031224051.8923-7-trond.myklebust@hammerspace.com> <20191031224051.8923-8-trond.myklebust@hammerspace.com> <20191031224051.8923-9-trond.myklebust@hammerspace.com> <20191031224051.8923-10-trond.myklebust@hammerspace.com> <20191031224051.8923-11-trond.myklebust@hammerspace.com> <20191031224051.8923-12-trond.myklebust@hammerspace.com> <20191031224051.8923-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 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 8c176c921554..ebd83e4db300 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -476,8 +476,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) { @@ -489,7 +487,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 Thu Oct 31 22:40:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11221983 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 D1D6614E5 for ; Thu, 31 Oct 2019 22:43:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AF53020873 for ; Thu, 31 Oct 2019 22:43:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dHdHmkJX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727883AbfJaWnY (ORCPT ); Thu, 31 Oct 2019 18:43:24 -0400 Received: from mail-yw1-f66.google.com ([209.85.161.66]:40689 "EHLO mail-yw1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727611AbfJaWnX (ORCPT ); Thu, 31 Oct 2019 18:43:23 -0400 Received: by mail-yw1-f66.google.com with SMTP id a67so2787749ywg.7 for ; Thu, 31 Oct 2019 15:43:23 -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=Qt/cmllgWyFyQXjgEd/PehmbeSEG9aGD5ZDxJMCTumo=; b=dHdHmkJXa7esx20smKDriVkcHdtWvHxQQB3ECLetMA2Gw/uRuC+M6sgaDk1gsPBxGA MQi3Nh7Ez5C4/N4wCv5LnngfGtu6/9354Btqph8n55G5AoSs+1BA5E1pSu7/6C1LX3Kh Ft4adl88Ra+JDRoZiIwfhjnCBGTD7lRorAXHEiPiSI6UCAxs10JTHUF5TLTAURwL9uAb BKsU7IMjvxs8V9a4d/o/azDvA6FmHCXAUCrom52Fz1EIkdBtcOJJyTSAQf4zJI67ew3I Sh85kE1V78keO5Hx5cP9hpC2/yESVYIurx3lfJnHXgBLdzHH4krlRqPsNDdDc8b4Nt3v xg2A== 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=Qt/cmllgWyFyQXjgEd/PehmbeSEG9aGD5ZDxJMCTumo=; b=MmVkbDPurKlqQ3saCVTWPE3EaC8hPYSUXjR4GArPVrx3PmZi/znYhGyLbE/HcQPa/B Z+x4piC6B5tyVtXXAIPOBgs4vR5L4WkxGcruqepiikyYQtUfVMA5XWW7I5g1xpz1s7Al LqQ0S8/F/F4hCMy8/iADQd4EHuS36TBpmJU1kuba8jFm1w7l9sqgyLf1KCjr1ZmEXsIy sO3r87uX/fqJIKiMJAw0/RHuxlI5bjg0wogrOzWV69PM7PTqGkwdIZF/NuQoy4urt73m cIsDfufERtmUma1DGkJcSrZnum5jKiBonhZxXsD7NFVS6ZaRqGUR3/zVYl52XMLnPuBY ungg== X-Gm-Message-State: APjAAAXcwpBJ2Dzawx4PTqkb4l+4TgYQka21KnpAion//v0Kdl+kVhpi 16Jhb8M0mtO7VpxU5DvTmqzwA2I= X-Google-Smtp-Source: APXvYqxrxyrR7x69EevUIhFMapJ73mrTavEE/jfDTQZaAa/i5bPTj9w5w4RxL+YHJEBSnK5iYTErGQ== X-Received: by 2002:a81:4948:: with SMTP id w69mr6312034ywa.404.1572561802541; Thu, 31 Oct 2019 15:43:22 -0700 (PDT) Received: from localhost.localdomain ([50.105.87.1]) by smtp.gmail.com with ESMTPSA id d192sm1720287ywb.3.2019.10.31.15.43.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 15:43:21 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 14/20] NFSv4: Don't reclaim delegations that have been returned or revoked Date: Thu, 31 Oct 2019 18:40:45 -0400 Message-Id: <20191031224051.8923-15-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191031224051.8923-14-trond.myklebust@hammerspace.com> References: <20191031224051.8923-1-trond.myklebust@hammerspace.com> <20191031224051.8923-2-trond.myklebust@hammerspace.com> <20191031224051.8923-3-trond.myklebust@hammerspace.com> <20191031224051.8923-4-trond.myklebust@hammerspace.com> <20191031224051.8923-5-trond.myklebust@hammerspace.com> <20191031224051.8923-6-trond.myklebust@hammerspace.com> <20191031224051.8923-7-trond.myklebust@hammerspace.com> <20191031224051.8923-8-trond.myklebust@hammerspace.com> <20191031224051.8923-9-trond.myklebust@hammerspace.com> <20191031224051.8923-10-trond.myklebust@hammerspace.com> <20191031224051.8923-11-trond.myklebust@hammerspace.com> <20191031224051.8923-12-trond.myklebust@hammerspace.com> <20191031224051.8923-13-trond.myklebust@hammerspace.com> <20191031224051.8923-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 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 ebd83e4db300..78df1cde286e 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -199,7 +199,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, 0)) { nfs4_stateid_copy(&delegation->stateid, stateid); delegation->type = type; delegation->pagemod_limit = pagemod_limit; From patchwork Thu Oct 31 22:40:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11221987 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 BD9EC13BD for ; Thu, 31 Oct 2019 22:43:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9BB01208C0 for ; Thu, 31 Oct 2019 22:43:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vE5l75GV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727611AbfJaWn1 (ORCPT ); Thu, 31 Oct 2019 18:43:27 -0400 Received: from mail-yw1-f65.google.com ([209.85.161.65]:43992 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727922AbfJaWn0 (ORCPT ); Thu, 31 Oct 2019 18:43:26 -0400 Received: by mail-yw1-f65.google.com with SMTP id g77so2780210ywb.10 for ; Thu, 31 Oct 2019 15:43:24 -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=YwWywFVCwgzZ4LH/87FN5wOH2rsbvdar3vb9Xu2sSu4=; b=vE5l75GViOnfTGc9ccxX+PobFZOZ58h8Q7whh3SWc2HzQVt/DqmfUG7W6l4Y/o3G+3 pgIWKc3VDTQT8WXF1fg2BDcr/LLgz8sliIJN9c5cI1bz1SvK4SVR5H+V9jHiYKyrTDtK 09olcGvVh2jchjetz1ycUFIaWuq495by38as/rJrhg3WSSq9LPlOqcAH3mrAe8oRxiWx LuMt2+YvMgqNCA8eIHCb6FAlkWT1S/t2gMHgv49TlEAf8/03M4V9TKpWABNk024fTjq8 zJfLJ4fcPT6v+cuT2voRPaMGPsO1KeXye/9BroMfMdMphZckP3DZ1j5oNdlHguEt2zDP f0fQ== 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=YwWywFVCwgzZ4LH/87FN5wOH2rsbvdar3vb9Xu2sSu4=; b=IewIJTDd8c9q8x49+SsqfFMnyhPZNlIepj423A+FRkqmsEVBFMxnAAaHdvje/wyTgo 0syvX2fxd24Xsn8W6wHcA/0HkXbVqty+t4v1lPCJ58iAYl1W8HICg4UeWnxpblVugXGL zdfQJJEiNB1NhvIq2KchyEwWnQVMJn7Vwa41zTfl9fbc9WGLbq1QivBSf1BzeoaxACU7 NBGq56P1/5ROOHxumFzYgZmKUYg6A8dXhXNJ1uAzr32Y5h2hwxoHkpFht17BNXj5+NFf qSF0hEUrorrg+UTCH5oK3HGoWTuZTFyozbJsPtFIMGyw5LsWJQ4gCESiN2TQwbcGA7ix cvbA== X-Gm-Message-State: APjAAAWBf28cAI5j2u0uUgWosOtAa2khux+8D++Hf6ERWQaUQOyE+drB zDVeAPbmwX6FLx87Hh1KDXaReaI= X-Google-Smtp-Source: APXvYqzyY3Tr9AJABOo9SawxDpTmB1a3UdeAZnuzqdFnQY9hRUGZcHpWfGx2pyobSFBh9uoM8n4u7g== X-Received: by 2002:a81:241:: with SMTP id 62mr6354289ywc.19.1572561803946; Thu, 31 Oct 2019 15:43:23 -0700 (PDT) Received: from localhost.localdomain ([50.105.87.1]) by smtp.gmail.com with ESMTPSA id d192sm1720287ywb.3.2019.10.31.15.43.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 15:43:22 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 15/20] NFSv4: nfs4_return_incompatible_delegation() should check delegation validity Date: Thu, 31 Oct 2019 18:40:46 -0400 Message-Id: <20191031224051.8923-16-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191031224051.8923-15-trond.myklebust@hammerspace.com> References: <20191031224051.8923-1-trond.myklebust@hammerspace.com> <20191031224051.8923-2-trond.myklebust@hammerspace.com> <20191031224051.8923-3-trond.myklebust@hammerspace.com> <20191031224051.8923-4-trond.myklebust@hammerspace.com> <20191031224051.8923-5-trond.myklebust@hammerspace.com> <20191031224051.8923-6-trond.myklebust@hammerspace.com> <20191031224051.8923-7-trond.myklebust@hammerspace.com> <20191031224051.8923-8-trond.myklebust@hammerspace.com> <20191031224051.8923-9-trond.myklebust@hammerspace.com> <20191031224051.8923-10-trond.myklebust@hammerspace.com> <20191031224051.8923-11-trond.myklebust@hammerspace.com> <20191031224051.8923-12-trond.myklebust@hammerspace.com> <20191031224051.8923-13-trond.myklebust@hammerspace.com> <20191031224051.8923-14-trond.myklebust@hammerspace.com> <20191031224051.8923-15-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 Ensure that we check that the delegation is valid in nfs4_return_incompatible_delegation() before we try to return it. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index a222122e7151..c7e4a9ba8420 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -1796,7 +1796,7 @@ static void nfs4_return_incompatible_delegation(struct inode *inode, fmode_t fmo fmode &= FMODE_READ|FMODE_WRITE; rcu_read_lock(); - delegation = rcu_dereference(NFS_I(inode)->delegation); + delegation = nfs4_get_valid_delegation(inode); if (delegation == NULL || (delegation->type & fmode) == fmode) { rcu_read_unlock(); return; From patchwork Thu Oct 31 22:40: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: 11221985 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 8D7BB14E5 for ; Thu, 31 Oct 2019 22:43:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6B5AF2087F for ; Thu, 31 Oct 2019 22:43:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Fq4pu+ak" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728057AbfJaWn1 (ORCPT ); Thu, 31 Oct 2019 18:43:27 -0400 Received: from mail-yw1-f67.google.com ([209.85.161.67]:35426 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727611AbfJaWn0 (ORCPT ); Thu, 31 Oct 2019 18:43:26 -0400 Received: by mail-yw1-f67.google.com with SMTP id r134so2799018ywg.2 for ; Thu, 31 Oct 2019 15:43:26 -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=miHuqUqWzdE1nbZhl0K85EkExwuSgvBYv/eRMB4N1Ko=; b=Fq4pu+akxnGfhPCWfDtr8jOA6vV2beNxDwmzyeU2raiCesZL/4eRlWEGkk5P4o93CA PFwJN+5Wwu2gDhqlj0DGeZUnT2OVoiF+qRWlpW0W83vMczAOYkkIz1iYpmDJsO4VD2gM 8YjmBE6Ze8qTiI7fssjkZ+Zsn7ykkSYY1lfyN/Mb57O5+22bzifDu5yRReMcZQzq3IOm oxZXjvUSF/U6NvTiV7pnmAElS0tqCW8LJw/9heMFVFhYoc3EorxjODX6qIhSRYFQ+jq2 J5jLZY/RKTpXfwY2f3sUrnkNnOIJSalumv+kYiLXquE0B6JFMTjE/fgOzfkOyPT3UoZE Vsmg== 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=miHuqUqWzdE1nbZhl0K85EkExwuSgvBYv/eRMB4N1Ko=; b=gbvBmB+u3pmLI45LUQ4zxz6noRZ6QD5owzzbtLkkw2lR9tzQN7t/QgXD/jAN6YChbj v77SK0gGF4zw6BNyXD+9YpUCK9tCHYJzxsG1oZeNtNj4XDNgLz5d93JM9bAjWGFAueaI i5HQcdGQKZpPBNff1clyRSOqG/FL/I9NJQww7nhogslLFYfzPq2wZs+ND2ey0TMglph7 BxRGDLeEfvAveHmoMQfbuzP+aSSHMG2q8Ud+JO/zC1ClhgJUWjq8nGNYVgKp8bukRyUG MoWF/4698YizA99oIv8WoOiW3GL/gzTRF4+lnzBFeQd04dJS7n128721Xmwks7Z4MaUa 6K9A== X-Gm-Message-State: APjAAAUq7RfJUm6e9PuPKXllNVAKgQrKi/M0gAruXAo0i1yT5toDH66P akODGIvVfdKwticyV6BvIa0Yyms= X-Google-Smtp-Source: APXvYqycYgr4TEz1ESR0AVwCe8Q1PW5wxXMGju8fqoW7biczO419qxkh+R+gQwTlOX2FJPWJ2Ljk4Q== X-Received: by 2002:a81:61c3:: with SMTP id v186mr6313170ywb.151.1572561805336; Thu, 31 Oct 2019 15:43:25 -0700 (PDT) Received: from localhost.localdomain ([50.105.87.1]) by smtp.gmail.com with ESMTPSA id d192sm1720287ywb.3.2019.10.31.15.43.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 15:43:24 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 16/20] NFSv4: Fix nfs4_inode_make_writeable() Date: Thu, 31 Oct 2019 18:40:47 -0400 Message-Id: <20191031224051.8923-17-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191031224051.8923-16-trond.myklebust@hammerspace.com> References: <20191031224051.8923-1-trond.myklebust@hammerspace.com> <20191031224051.8923-2-trond.myklebust@hammerspace.com> <20191031224051.8923-3-trond.myklebust@hammerspace.com> <20191031224051.8923-4-trond.myklebust@hammerspace.com> <20191031224051.8923-5-trond.myklebust@hammerspace.com> <20191031224051.8923-6-trond.myklebust@hammerspace.com> <20191031224051.8923-7-trond.myklebust@hammerspace.com> <20191031224051.8923-8-trond.myklebust@hammerspace.com> <20191031224051.8923-9-trond.myklebust@hammerspace.com> <20191031224051.8923-10-trond.myklebust@hammerspace.com> <20191031224051.8923-11-trond.myklebust@hammerspace.com> <20191031224051.8923-12-trond.myklebust@hammerspace.com> <20191031224051.8923-13-trond.myklebust@hammerspace.com> <20191031224051.8923-14-trond.myklebust@hammerspace.com> <20191031224051.8923-15-trond.myklebust@hammerspace.com> <20191031224051.8923-16-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 Fix the checks in nfs4_inode_make_writeable() to ignore the case where we hold no delegations. Currently, in such a case, we automatically flush writes. Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 78df1cde286e..e3d8055f0c6d 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -644,10 +644,18 @@ int nfs4_inode_return_delegation(struct inode *inode) */ int nfs4_inode_make_writeable(struct inode *inode) { - if (!nfs4_has_session(NFS_SERVER(inode)->nfs_client) || - !nfs4_check_delegation(inode, FMODE_WRITE)) - return nfs4_inode_return_delegation(inode); - return 0; + struct nfs_delegation *delegation; + + rcu_read_lock(); + delegation = nfs4_get_valid_delegation(inode); + if (delegation == NULL || + (nfs4_has_session(NFS_SERVER(inode)->nfs_client) && + (delegation->type & FMODE_WRITE))) { + rcu_read_unlock(); + return 0; + } + rcu_read_unlock(); + return nfs4_inode_return_delegation(inode); } static void nfs_mark_return_if_closed_delegation(struct nfs_server *server, From patchwork Thu Oct 31 22:40: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: 11221989 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 8CBA313BD for ; Thu, 31 Oct 2019 22:43:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 66B422087F for ; Thu, 31 Oct 2019 22:43:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XIyZw/iW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728079AbfJaWna (ORCPT ); Thu, 31 Oct 2019 18:43:30 -0400 Received: from mail-yw1-f68.google.com ([209.85.161.68]:46168 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728076AbfJaWn3 (ORCPT ); Thu, 31 Oct 2019 18:43:29 -0400 Received: by mail-yw1-f68.google.com with SMTP id i2so2772947ywg.13 for ; Thu, 31 Oct 2019 15:43:27 -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=Vf/ZxAx5Dtp9saPC/f/GAFEOjUKA7pZQZ1SUKquX5bI=; b=XIyZw/iWiqNviYT/1J19/BvfSUlwIPT5l7XrcuRWNSBMG/UOkeDwJn7j/hi7S819h0 9TntILhvQJhOZx4axw9QWDL457a7zkIm1436ZY8JmghnKkpe39QwF5wSSKM4pGdYGp2c njWZyewDggdLYqGlFinJlv0GPqnZe0IUW1KIeM+qHLhqttLLppdGQLSJyB6b+bhKmnuQ ATHyE1pFOtvnUyZJUZ54994TXRYiEhcul/s8tX70CtywPrQLmkyf+auBk8DpMALvLI9x UXFlBE6geVOZ+Pibwkg7P4S1Wym2pOf7OCOsSJNoYV6Gj6/DNNLcXEf+OiU9cXvDqCJP zCyw== 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=Vf/ZxAx5Dtp9saPC/f/GAFEOjUKA7pZQZ1SUKquX5bI=; b=dvHgezIKhmf6dU8gIcPztwJfSChPNVjWZHKCIuAcoygZXDiZSftJgK1fX3hFQBuKif MatN9vrAM85Bm/c/MX0FfXqbXkqEKhq5IMozC9SvjxvTpvcuU5E0XNcw7r0sB16z4tJE YljFZMG0rvKALHjg9CQoDrdMQP4GX3zJSEXl4xjAdiA3i0Zzb2NlSmvHRrnizFU07cu+ yADZRAznUuHUYBpB0qJ7ht/5qYn4pCgqPgnkCL9DWvt3leirLo42U0PHVbOwW88Q06ID lGLSSrEzm6ovQqoq2HCQceUBDbivhWwI3CO3VLngM75OpOzaWFCyj7LeHN06J4JoAhxV Vuiw== X-Gm-Message-State: APjAAAUnlgeejZ8zDT1WnGOxuyFkKfgJtkgZyW1eedEsnBR9SQSsO27p x/Kx1pWPNHNeqo6ZQW+dEbTNA8s= X-Google-Smtp-Source: APXvYqyZ9yrXgyOMcwcQYStny3WzM7jh6nPGjwqYPFzbYS33Rgmw5BWJrZwwo4Zbd+3vf7JTUufGGQ== X-Received: by 2002:a0d:ebd0:: with SMTP id u199mr6180913ywe.449.1572561806693; Thu, 31 Oct 2019 15:43:26 -0700 (PDT) Received: from localhost.localdomain ([50.105.87.1]) by smtp.gmail.com with ESMTPSA id d192sm1720287ywb.3.2019.10.31.15.43.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 15:43:25 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 17/20] NFS: nfs_inode_find_state_and_recover() fix stateid matching Date: Thu, 31 Oct 2019 18:40:48 -0400 Message-Id: <20191031224051.8923-18-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191031224051.8923-17-trond.myklebust@hammerspace.com> References: <20191031224051.8923-1-trond.myklebust@hammerspace.com> <20191031224051.8923-2-trond.myklebust@hammerspace.com> <20191031224051.8923-3-trond.myklebust@hammerspace.com> <20191031224051.8923-4-trond.myklebust@hammerspace.com> <20191031224051.8923-5-trond.myklebust@hammerspace.com> <20191031224051.8923-6-trond.myklebust@hammerspace.com> <20191031224051.8923-7-trond.myklebust@hammerspace.com> <20191031224051.8923-8-trond.myklebust@hammerspace.com> <20191031224051.8923-9-trond.myklebust@hammerspace.com> <20191031224051.8923-10-trond.myklebust@hammerspace.com> <20191031224051.8923-11-trond.myklebust@hammerspace.com> <20191031224051.8923-12-trond.myklebust@hammerspace.com> <20191031224051.8923-13-trond.myklebust@hammerspace.com> <20191031224051.8923-14-trond.myklebust@hammerspace.com> <20191031224051.8923-15-trond.myklebust@hammerspace.com> <20191031224051.8923-16-trond.myklebust@hammerspace.com> <20191031224051.8923-17-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 In nfs_inode_find_state_and_recover() we want to mark for recovery only those stateids that match or are older than the supplied stateid parameter. Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 3 ++- fs/nfs/nfs4_fs.h | 6 ++++++ fs/nfs/nfs4state.c | 7 ++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index e3d8055f0c6d..902baea1ecc6 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -1207,7 +1207,8 @@ void nfs_inode_find_delegation_state_and_recover(struct inode *inode, rcu_read_lock(); delegation = rcu_dereference(NFS_I(inode)->delegation); if (delegation && - nfs4_stateid_match_other(&delegation->stateid, stateid)) { + nfs4_stateid_match_or_older(&delegation->stateid, stateid) && + !test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) { nfs_mark_test_expired_delegation(NFS_SERVER(inode), delegation); found = true; } diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 16b2e5cc3e94..40ab5540c2ae 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -572,6 +572,12 @@ static inline bool nfs4_stateid_is_newer(const nfs4_stateid *s1, const nfs4_stat return (s32)(be32_to_cpu(s1->seqid) - be32_to_cpu(s2->seqid)) > 0; } +static inline bool nfs4_stateid_match_or_older(const nfs4_stateid *dst, const nfs4_stateid *src) +{ + return nfs4_stateid_match_other(dst, src) && + !(src->seqid && nfs4_stateid_is_newer(dst, src)); +} + static inline void nfs4_stateid_seqid_inc(nfs4_stateid *s1) { u32 seqid = be32_to_cpu(s1->seqid); diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 0c6d53dc3672..a66acb6573d4 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -1407,7 +1407,7 @@ nfs_state_find_lock_state_by_stateid(struct nfs4_state *state, list_for_each_entry(pos, &state->lock_states, ls_locks) { if (!test_bit(NFS_LOCK_INITIALIZED, &pos->ls_flags)) continue; - if (nfs4_stateid_match_other(&pos->ls_stateid, stateid)) + if (nfs4_stateid_match_or_older(&pos->ls_stateid, stateid)) return pos; } return NULL; @@ -1441,12 +1441,13 @@ void nfs_inode_find_state_and_recover(struct inode *inode, state = ctx->state; if (state == NULL) continue; - if (nfs4_stateid_match_other(&state->stateid, stateid) && + if (nfs4_stateid_match_or_older(&state->stateid, stateid) && nfs4_state_mark_reclaim_nograce(clp, state)) { found = true; continue; } - if (nfs4_stateid_match_other(&state->open_stateid, stateid) && + if (test_bit(NFS_OPEN_STATE, &state->flags) && + nfs4_stateid_match_or_older(&state->open_stateid, stateid) && nfs4_state_mark_reclaim_nograce(clp, state)) { found = true; continue; From patchwork Thu Oct 31 22:40: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: 11221991 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 B908315AB for ; Thu, 31 Oct 2019 22:43:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 962C320873 for ; Thu, 31 Oct 2019 22:43:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Y1kWcyG/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728076AbfJaWna (ORCPT ); Thu, 31 Oct 2019 18:43:30 -0400 Received: from mail-yw1-f67.google.com ([209.85.161.67]:34747 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728073AbfJaWn3 (ORCPT ); Thu, 31 Oct 2019 18:43:29 -0400 Received: by mail-yw1-f67.google.com with SMTP id z144so1171198ywd.1 for ; Thu, 31 Oct 2019 15:43:29 -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=0w1x19jgGRQLmFP5d0KNhM8Dd0dSbZyA49/LiXX5964=; b=Y1kWcyG/vHBOnOcTUrM0lq15Pv86FnZZL1sEVRRm/KQzo5lG4t7HaBk6H8yP/FMAqY ElQE9yho2qwDjXf/bgmSPc33yBk1uWMyCIs5mjp1spQ9cfM5Olp1yvuwgXLLk9rlUCl/ rGKo6qdcXUWwfj26wbZSVz6cX6lkpWqSuUIqq/oPva8Tx6GfKAofavvUvz46gFejxOH5 elkiUaSBYb6FKdF0LcECMkUPLx5vX0wV0vtX2jO7p3hqtFgPWdnegrxZaQTnRVAlvtqS NqaQAVDMCmRfKKMmURgfLVZHPyrmtw7Qa6LTIERLaC7tP6p2wHzKU8L5b34JkjEUVsRz PhHQ== 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=0w1x19jgGRQLmFP5d0KNhM8Dd0dSbZyA49/LiXX5964=; b=BN4octkSzetnRZrEYFUiH8Ud1EJRa0k7L+Fm26jrsiMhO+b74phfGGXvaCQKL7mBpP ULR779IJubAOnqnnEWxL/4SA0ufSpkjnatus/nPSygHEK/u5d4eM0Tv8h96MJRvSoK0u AKw7kooHgZJ6Apa9td/XPiVWxe95J7TKyCNavuGmsigf2eFaW7nINILjTKZ8Ustcja2D ruqYL5yS4xG7BASK2ZrFWeDtScQ0TlDOkfDMJ+MXObNgjS45u8lImYZxml7jgpfbcpBN ahwDCzt/YE65cdJkPzAXoc5QCJix7wK0/1zWG7+ObYvFOH2UxdQ44Lv1UvwG9hMTefKV //yQ== X-Gm-Message-State: APjAAAUx+KAZngRMg5l052BWHg8rERPW7aiU4NhhMNZn3oE5+sTYm41w Ais1gAmUx55qRAn8gQgVunxn+Ds= X-Google-Smtp-Source: APXvYqypPeIcROQh49Q2lkbScU2+Rvs0Dde3VZsbwMQbsKLrZLfYpYQC68tTanOs+DHtVHT5IGBovw== X-Received: by 2002:a81:49c1:: with SMTP id w184mr6285788ywa.264.1572561808172; Thu, 31 Oct 2019 15:43:28 -0700 (PDT) Received: from localhost.localdomain ([50.105.87.1]) by smtp.gmail.com with ESMTPSA id d192sm1720287ywb.3.2019.10.31.15.43.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 15:43:27 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 18/20] NFSv4: Fix races between open and delegreturn Date: Thu, 31 Oct 2019 18:40:49 -0400 Message-Id: <20191031224051.8923-19-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191031224051.8923-18-trond.myklebust@hammerspace.com> References: <20191031224051.8923-1-trond.myklebust@hammerspace.com> <20191031224051.8923-2-trond.myklebust@hammerspace.com> <20191031224051.8923-3-trond.myklebust@hammerspace.com> <20191031224051.8923-4-trond.myklebust@hammerspace.com> <20191031224051.8923-5-trond.myklebust@hammerspace.com> <20191031224051.8923-6-trond.myklebust@hammerspace.com> <20191031224051.8923-7-trond.myklebust@hammerspace.com> <20191031224051.8923-8-trond.myklebust@hammerspace.com> <20191031224051.8923-9-trond.myklebust@hammerspace.com> <20191031224051.8923-10-trond.myklebust@hammerspace.com> <20191031224051.8923-11-trond.myklebust@hammerspace.com> <20191031224051.8923-12-trond.myklebust@hammerspace.com> <20191031224051.8923-13-trond.myklebust@hammerspace.com> <20191031224051.8923-14-trond.myklebust@hammerspace.com> <20191031224051.8923-15-trond.myklebust@hammerspace.com> <20191031224051.8923-16-trond.myklebust@hammerspace.com> <20191031224051.8923-17-trond.myklebust@hammerspace.com> <20191031224051.8923-18-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 | 64 ++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 902baea1ecc6..48f3c6c9672f 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -229,7 +229,6 @@ static int nfs_do_return_delegation(struct inode *inode, struct nfs_delegation * delegation->cred, &delegation->stateid, issync); - nfs_free_delegation(delegation); return res; } @@ -302,7 +301,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); @@ -329,10 +327,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 @@ -384,16 +384,18 @@ int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred, spin_lock(&clp->cl_lock); old_delegation = rcu_dereference_protected(nfsi->delegation, lockdep_is_held(&clp->cl_lock)); - if (old_delegation != NULL) { - /* 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; - } + if (old_delegation == NULL) + goto add_new; + /* 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; + } + if (!test_bit(NFS_DELEGATION_REVOKED, &old_delegation->flags)) { /* * Deal with broken servers that hand out two * delegations for the same file. @@ -412,11 +414,11 @@ int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred, if (test_and_set_bit(NFS_DELEGATION_RETURNING, &old_delegation->flags)) goto out; - freeme = nfs_detach_delegation_locked(nfsi, - old_delegation, clp); - if (freeme == NULL) - goto out; } + freeme = nfs_detach_delegation_locked(nfsi, old_delegation, clp); + if (freeme == NULL) + goto out; +add_new: list_add_tail_rcu(&delegation->super_list, &server->delegations); rcu_assign_pointer(nfsi->delegation, delegation); delegation = NULL; @@ -431,8 +433,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; } @@ -442,7 +446,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) @@ -464,8 +467,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: @@ -608,6 +609,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); } } @@ -763,10 +765,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; @@ -799,19 +800,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); @@ -839,7 +833,7 @@ void nfs_delegation_mark_returned(struct inode *inode, delegation->stateid.seqid = stateid->seqid; } - 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); From patchwork Thu Oct 31 22:40: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: 11221993 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 2084013BD for ; Thu, 31 Oct 2019 22:43:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F33E62087F for ; Thu, 31 Oct 2019 22:43:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rxRrcLte" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729527AbfJaWnb (ORCPT ); Thu, 31 Oct 2019 18:43:31 -0400 Received: from mail-yb1-f194.google.com ([209.85.219.194]:42391 "EHLO mail-yb1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728182AbfJaWnb (ORCPT ); Thu, 31 Oct 2019 18:43:31 -0400 Received: by mail-yb1-f194.google.com with SMTP id 4so3103968ybq.9 for ; Thu, 31 Oct 2019 15:43:30 -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=EwYPYULTeO/0uNpMARXXa2UdlMr9jw2KBzS6WN4/c2U=; b=rxRrcLteyOLYpNV+SLZdaLTViFe8qQqT2w3QwmdUq++Pq20SK8Xh0glbGQkcEXX+9z ARnQXshOAlhOBNWMKmpwpt0KvXQGUeAjvsvG/AH5WL+neSLCwWdVhelDt74pOq86ytKs HfeZEfx2GzkGcSpvs6Jcem0mJE5CYSn83ouLSKBgV2RpZuaDSUNAAg4btSX8MPaRXM6d FtD/i/JXviuMbg2RhJdPrqOx3W/XKuYBvGvAMnsRJ57L12nl2dijb0BNgpTdN434XY9g YYJW80rgjavRV3x4/teqtIltmtlslyzzmxp5AdvPheGdZ+ZKAGpgLM9QjQmcMhDQOjXD Assw== 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=EwYPYULTeO/0uNpMARXXa2UdlMr9jw2KBzS6WN4/c2U=; b=DMQaM1MKgzfg92q1BPx4olwJOrIgeaoXs4DkJijY7ZPmaTLEFSNZRUHXYcs6G3g+6V 17xKuyJEUQ0/STc6BkNx9bHFJsDEWsAdeXHU2FzoxG1xpUMFh4bEDYfgwiGAMY2SE/Cr bpCkPSKbVeBr/r/z+0gv/BAWoO61OidtOgie3JsiHsPN05L3s63FxAu+P2DFQpND9xUt ZLt6F0D/8TJ4vR1FPSTHClcF0Q2dPEctKUUm74UTpRnx/Kf2k/0Up1q1llQpuabyBeA6 9Fd8IdYjw7ZuXqCSmsppk31YuQUyAZYAe69ebgksRnuKOTblZhzK6F5lQr4Kz9f7Wk5x tJfA== X-Gm-Message-State: APjAAAWulgfwJHgfgVDXt8gp+qyvTdpy+kOtlpBe4xFy0g0BGNuDDo20 08B3L0bWz0d6zFB1c8QH5npE8Aw= X-Google-Smtp-Source: APXvYqy7Euvi7qtHPnZLQ9IvYMA/ZAGQ0WVcgbT2OJuXs9QX/1bIxUsq4gLqcn1nfHwJZU5mVoLKvA== X-Received: by 2002:a25:c586:: with SMTP id v128mr6691614ybe.387.1572561809473; Thu, 31 Oct 2019 15:43:29 -0700 (PDT) Received: from localhost.localdomain ([50.105.87.1]) by smtp.gmail.com with ESMTPSA id d192sm1720287ywb.3.2019.10.31.15.43.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 15:43:28 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 19/20] NFSv4: Handle NFS4ERR_OLD_STATEID in delegreturn Date: Thu, 31 Oct 2019 18:40:50 -0400 Message-Id: <20191031224051.8923-20-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191031224051.8923-19-trond.myklebust@hammerspace.com> References: <20191031224051.8923-1-trond.myklebust@hammerspace.com> <20191031224051.8923-2-trond.myklebust@hammerspace.com> <20191031224051.8923-3-trond.myklebust@hammerspace.com> <20191031224051.8923-4-trond.myklebust@hammerspace.com> <20191031224051.8923-5-trond.myklebust@hammerspace.com> <20191031224051.8923-6-trond.myklebust@hammerspace.com> <20191031224051.8923-7-trond.myklebust@hammerspace.com> <20191031224051.8923-8-trond.myklebust@hammerspace.com> <20191031224051.8923-9-trond.myklebust@hammerspace.com> <20191031224051.8923-10-trond.myklebust@hammerspace.com> <20191031224051.8923-11-trond.myklebust@hammerspace.com> <20191031224051.8923-12-trond.myklebust@hammerspace.com> <20191031224051.8923-13-trond.myklebust@hammerspace.com> <20191031224051.8923-14-trond.myklebust@hammerspace.com> <20191031224051.8923-15-trond.myklebust@hammerspace.com> <20191031224051.8923-16-trond.myklebust@hammerspace.com> <20191031224051.8923-17-trond.myklebust@hammerspace.com> <20191031224051.8923-18-trond.myklebust@hammerspace.com> <20191031224051.8923-19-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 NFS4ERR_OLD_STATEID in response to our delegreturn, we want to sync to the most recent seqid for the delegation stateid. However if we are already at the most recent, we have two possibilities: - an OPEN reply is still outstanding and will return a new seqid - an earlier OPEN reply was dropped on the floor due to a timeout. In the latter case, we may end up unable to complete the delegreturn, so we want to bump the seqid to a value greater than the cached value. While this may cause us to lose the delegation in the former case, it should now be safe to assume that the client will replay the OPEN if necessary in order to get a new valid stateid. Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 1 + fs/nfs/nfs4proc.c | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 48f3c6c9672f..fe57b2b5314a 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -1252,6 +1252,7 @@ bool nfs4_refresh_delegation_stateid(nfs4_stateid *dst, struct inode *inode) delegation = rcu_dereference(NFS_I(inode)->delegation); if (delegation != NULL && nfs4_stateid_match_other(dst, &delegation->stateid) && + nfs4_stateid_is_newer(&delegation->stateid, dst) && !test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) { dst->seqid = delegation->stateid.seqid; ret = true; diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index c7e4a9ba8420..33a8e53e976c 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -6196,10 +6196,9 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata) task->tk_status = 0; break; case -NFS4ERR_OLD_STATEID: - if (nfs4_refresh_delegation_stateid(&data->stateid, data->inode)) - goto out_restart; - task->tk_status = 0; - break; + if (!nfs4_refresh_delegation_stateid(&data->stateid, data->inode)) + nfs4_stateid_seqid_inc(&data->stateid); + goto out_restart; case -NFS4ERR_ACCESS: if (data->args.bitmask) { data->args.bitmask = NULL; From patchwork Thu Oct 31 22:40: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: 11221995 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 4AA9D15AB for ; Thu, 31 Oct 2019 22:43:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2965520873 for ; Thu, 31 Oct 2019 22:43:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B3xdmvw0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729552AbfJaWnc (ORCPT ); Thu, 31 Oct 2019 18:43:32 -0400 Received: from mail-yb1-f196.google.com ([209.85.219.196]:39806 "EHLO mail-yb1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727922AbfJaWnc (ORCPT ); Thu, 31 Oct 2019 18:43:32 -0400 Received: by mail-yb1-f196.google.com with SMTP id q18so2640998ybq.6 for ; Thu, 31 Oct 2019 15:43:32 -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=TvuonOVBM9ZQFTtoGztRGRv+Vmenki0IRgaTsWfruHI=; b=B3xdmvw0MI7UxYogU+X4K710M480Lbk6obfnBGimijyROGb6mxheirD6GBWwR6xtHo MQWr/N/ITisZvRPCy7Vxwm8lV4loJkIMSd8p4WpRKSCv/aPy72p5lOSqZEGv7QcobLhn AeVZTBuZK3n+ayZKsQLj+o5LOxhFXA51008pg4U0yDsElKAvgMj8qym1qUBEHM7+fuod 2+Q+PIL+hyhHVKKFs7AKhfY461r6svnE2gMde1tOWPV8Qs5zdXn7rbny2zBt06PFM6MI iUzX04AIeFurlnyvXzyfjSPXBCsqpCyW1R79iID1V3R+VRHIGNhvHb2ErkS/RFEnhHar UYvQ== 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=TvuonOVBM9ZQFTtoGztRGRv+Vmenki0IRgaTsWfruHI=; b=ZRMWdO84k/OlRG1dB+YfFYxRe3wYHWJfTusiCLD+yDQRnBAW7SKnbwiX293vi8ZzFk 7d5+CYVJPFASaLheh+xA1hmL/oMvcTezAN7u3eY8MJGmo2sL4ooSo5D9ozTl/jmxYIX2 aVQbxZDlLH2Ip6dKNCBchDbJvtlkh/SWIdWlgmawWSRiHdPVGXJzsxzbK0CfLmJacwdU mDuOc6l9nZvqbsCAzKHZGK69cpk/8/BK1SjsLJecF2VuXTAoDy/ob/sKdg26em/I4BHb Vncjsm7bFxTHBZzEKVZja+cOmgw7DvVW61fyuMkSCj2P/g+YH8dUMfti4EmEA5yKZULE yB0w== X-Gm-Message-State: APjAAAWMCBbIrks+AUfmYfNWGFb1E5jYenmH4YP7/8USzomYphtKh90n IDKwjHY1KsAqAXBGHF9KgJSloFM= X-Google-Smtp-Source: APXvYqyC53Tm6+2yT0qVrzV0h93aGM6RZ+uRCp1uCnUeO+BITsEygKkZAP8iZ0OXbvQcG9K5WAbklA== X-Received: by 2002:a25:778d:: with SMTP id s135mr6843778ybc.20.1572561810867; Thu, 31 Oct 2019 15:43:30 -0700 (PDT) Received: from localhost.localdomain ([50.105.87.1]) by smtp.gmail.com with ESMTPSA id d192sm1720287ywb.3.2019.10.31.15.43.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 15:43:30 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 20/20] NFSv4: Don't retry the GETATTR on old stateid in nfs4_delegreturn_done() Date: Thu, 31 Oct 2019 18:40:51 -0400 Message-Id: <20191031224051.8923-21-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191031224051.8923-20-trond.myklebust@hammerspace.com> References: <20191031224051.8923-1-trond.myklebust@hammerspace.com> <20191031224051.8923-2-trond.myklebust@hammerspace.com> <20191031224051.8923-3-trond.myklebust@hammerspace.com> <20191031224051.8923-4-trond.myklebust@hammerspace.com> <20191031224051.8923-5-trond.myklebust@hammerspace.com> <20191031224051.8923-6-trond.myklebust@hammerspace.com> <20191031224051.8923-7-trond.myklebust@hammerspace.com> <20191031224051.8923-8-trond.myklebust@hammerspace.com> <20191031224051.8923-9-trond.myklebust@hammerspace.com> <20191031224051.8923-10-trond.myklebust@hammerspace.com> <20191031224051.8923-11-trond.myklebust@hammerspace.com> <20191031224051.8923-12-trond.myklebust@hammerspace.com> <20191031224051.8923-13-trond.myklebust@hammerspace.com> <20191031224051.8923-14-trond.myklebust@hammerspace.com> <20191031224051.8923-15-trond.myklebust@hammerspace.com> <20191031224051.8923-16-trond.myklebust@hammerspace.com> <20191031224051.8923-17-trond.myklebust@hammerspace.com> <20191031224051.8923-18-trond.myklebust@hammerspace.com> <20191031224051.8923-19-trond.myklebust@hammerspace.com> <20191031224051.8923-20-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 NFS4ERR_OLD_STATEID, then just skip retrying the GETATTR when replaying the delegreturn compound. We know nothing will have changed on the server. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 33a8e53e976c..a64ce9518776 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -6198,6 +6198,10 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata) case -NFS4ERR_OLD_STATEID: if (!nfs4_refresh_delegation_stateid(&data->stateid, data->inode)) nfs4_stateid_seqid_inc(&data->stateid); + if (data->args.bitmask) { + data->args.bitmask = NULL; + data->res.fattr = NULL; + } goto out_restart; case -NFS4ERR_ACCESS: if (data->args.bitmask) {