From patchwork Thu Sep 22 17:39:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 9346055 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3221960B16 for ; Thu, 22 Sep 2016 17:40:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2BD9D28580 for ; Thu, 22 Sep 2016 17:40:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 217622ABF8; Thu, 22 Sep 2016 17:40:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E5EF2ABF1 for ; Thu, 22 Sep 2016 17:40:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965694AbcIVRkb (ORCPT ); Thu, 22 Sep 2016 13:40:31 -0400 Received: from mail-io0-f193.google.com ([209.85.223.193]:34285 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965881AbcIVRjw (ORCPT ); Thu, 22 Sep 2016 13:39:52 -0400 Received: by mail-io0-f193.google.com with SMTP id y139so5621286ioy.1 for ; Thu, 22 Sep 2016 10:39:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=X+0YvsNgmSjeVDeoUu19X0bXwOPySblDQPnBICh8b0g=; b=c+Y78wtp3ykt7EsCNr+it9+9Z3D9fQQnZ+UM3Pzc8DZ8Kcn5NEIxzzVJQBVlBGd5xM miHuCRqZcBKUdJOKN/p4CPM5OSQKXmhs2GTHkoXChvlygSd1P3RoX/zjnP3SQgPYHWnR OM3IQ2C73OhBZjmZl4TZmocHtj9wv5dGZwR9nWO18OiJq6ufM0c06DXjvZ2pVQntbjb4 uHZ2JwsXxvCtd5qtsAs5Qns3ESfXZQRG6kqOxqvIdfDWYCuLYmc0eGN2DEs6qW2b0Rwp M44aQNq3mTFZOElm5Mk5G8OZoO1w03MgUzt2sdEP/ku5IlHu+AECo5eMyEGAofvvX+XM 459w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=X+0YvsNgmSjeVDeoUu19X0bXwOPySblDQPnBICh8b0g=; b=QX2mSeabAr4Oswfjb/NHmGSmI1ucskebi2LLfdBNEesnIF7aMGabJz6G6X0DWz8eWh C1i+Ln47YBEpNO1no9qfzdDIJ+UD1hz+hSXcp251nKx2oiMp66rT5Zh7EUgfLi1OHBfw FNIsHQG/Ow1qafYxSac4oUne6iScv1FYKNax8GNc5oLqJuGjLb0d+jo6kJouvbsWWgbp PCT3qBGuHZdEvD6eFJk3NhHKHxXycTDN7GGczcAdW6sMl1ax983DRloE2RZEMlrybkfz /2lZxlwrbC+U5cye0xFhnEmwnQWZiJM5Y4AoV+d12y9XL/cWOW6O7+l2e6BgbAIGE33l Ml2Q== X-Gm-Message-State: AE9vXwMBkpU+Am36l2CV8CBf1Zv4ePxUwMzNH9qoOY4rmNG7YBdXwWHOfM4Syl+fHky1fQ== X-Received: by 10.107.58.8 with SMTP id h8mr4706552ioa.124.1474565992062; Thu, 22 Sep 2016 10:39:52 -0700 (PDT) Received: from leira.trondhjem.org.localdomain (50-108-86-94.adr01.mskg.mi.frontiernet.net. [50.108.86.94]) by smtp.gmail.com with ESMTPSA id e66sm1194267itd.22.2016.09.22.10.39.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Sep 2016 10:39:51 -0700 (PDT) From: Trond Myklebust To: anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org, Oleg Drokin Subject: [PATCH v7 17/31] NFSv4: nfs_inode_find_state_and_recover() should check all stateids Date: Thu, 22 Sep 2016 13:39:07 -0400 Message-Id: <1474565961-21303-18-git-send-email-trond.myklebust@primarydata.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1474565961-21303-17-git-send-email-trond.myklebust@primarydata.com> References: <1474565961-21303-1-git-send-email-trond.myklebust@primarydata.com> <1474565961-21303-2-git-send-email-trond.myklebust@primarydata.com> <1474565961-21303-3-git-send-email-trond.myklebust@primarydata.com> <1474565961-21303-4-git-send-email-trond.myklebust@primarydata.com> <1474565961-21303-5-git-send-email-trond.myklebust@primarydata.com> <1474565961-21303-6-git-send-email-trond.myklebust@primarydata.com> <1474565961-21303-7-git-send-email-trond.myklebust@primarydata.com> <1474565961-21303-8-git-send-email-trond.myklebust@primarydata.com> <1474565961-21303-9-git-send-email-trond.myklebust@primarydata.com> <1474565961-21303-10-git-send-email-trond.myklebust@primarydata.com> <1474565961-21303-11-git-send-email-trond.myklebust@primarydata.com> <1474565961-21303-12-git-send-email-trond.myklebust@primarydata.com> <1474565961-21303-13-git-send-email-trond.myklebust@primarydata.com> <1474565961-21303-14-git-send-email-trond.myklebust@primarydata.com> <1474565961-21303-15-git-send-email-trond.myklebust@primarydata.com> <1474565961-21303-16-git-send-email-trond.myklebust@primarydata.com> <1474565961-21303-17-git-send-email-trond.myklebust@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Modify the helper nfs_inode_find_state_and_recover() so that it can check all open/lock/delegation state trackers on that inode for whether or not they need are affected by a revoked stateid error. Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 19 +++++++++++++++++++ fs/nfs/delegation.h | 2 ++ fs/nfs/nfs4state.c | 44 +++++++++++++++++++++++++++++++++++++++----- 3 files changed, 60 insertions(+), 5 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 484f14700108..5de4cfb2ab07 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -1001,6 +1001,25 @@ restart: rcu_read_unlock(); } +void nfs_inode_find_delegation_state_and_recover(struct inode *inode, + const nfs4_stateid *stateid) +{ + struct nfs_client *clp = NFS_SERVER(inode)->nfs_client; + struct nfs_delegation *delegation; + bool found = false; + + rcu_read_lock(); + delegation = rcu_dereference(NFS_I(inode)->delegation); + if (delegation && + nfs4_stateid_match_other(&delegation->stateid, stateid)) { + nfs_mark_test_expired_delegation(NFS_SERVER(inode), delegation); + found = true; + } + rcu_read_unlock(); + if (found) + nfs4_schedule_state_manager(clp); +} + /** * nfs_delegations_present - check for existence of delegations * @clp: client state handle diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h index 1442e3b1521d..e9d555796873 100644 --- a/fs/nfs/delegation.h +++ b/fs/nfs/delegation.h @@ -66,6 +66,8 @@ 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); bool nfs4_delegation_flush_on_close(const struct inode *inode); +void nfs_inode_find_delegation_state_and_recover(struct inode *inode, + const nfs4_stateid *stateid); #endif diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 63da0411e2af..4b538bb194f8 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -1337,6 +1337,35 @@ int nfs4_schedule_stateid_recovery(const struct nfs_server *server, struct nfs4_ } EXPORT_SYMBOL_GPL(nfs4_schedule_stateid_recovery); +static struct nfs4_lock_state * +nfs_state_find_lock_state_by_stateid(struct nfs4_state *state, + const nfs4_stateid *stateid) +{ + struct nfs4_lock_state *pos; + + 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)) + return pos; + } + return NULL; +} + +static bool nfs_state_lock_state_matches_stateid(struct nfs4_state *state, + const nfs4_stateid *stateid) +{ + bool found = false; + + if (test_bit(LK_STATE_IN_USE, &state->flags)) { + spin_lock(&state->state_lock); + if (nfs_state_find_lock_state_by_stateid(state, stateid)) + found = true; + spin_unlock(&state->state_lock); + } + return found; +} + void nfs_inode_find_state_and_recover(struct inode *inode, const nfs4_stateid *stateid) { @@ -1351,14 +1380,19 @@ void nfs_inode_find_state_and_recover(struct inode *inode, state = ctx->state; if (state == NULL) continue; - if (!test_bit(NFS_DELEGATED_STATE, &state->flags)) - continue; - if (!nfs4_stateid_match(&state->stateid, stateid)) + if (nfs4_stateid_match_other(&state->stateid, stateid)) { + nfs4_state_mark_reclaim_nograce(clp, state); + found = true; continue; - nfs4_state_mark_reclaim_nograce(clp, state); - found = true; + } + if (nfs_state_lock_state_matches_stateid(state, stateid)) { + nfs4_state_mark_reclaim_nograce(clp, state); + found = true; + } } spin_unlock(&inode->i_lock); + + nfs_inode_find_delegation_state_and_recover(inode, stateid); if (found) nfs4_schedule_state_manager(clp); }