From patchwork Tue Sep 11 20:23:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 10596265 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 76626112B for ; Tue, 11 Sep 2018 20:23:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61E9A29A2B for ; Tue, 11 Sep 2018 20:23:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 55F9529E2B; Tue, 11 Sep 2018 20:23:53 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,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 BA17329A2B for ; Tue, 11 Sep 2018 20:23:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726786AbeILBYs (ORCPT ); Tue, 11 Sep 2018 21:24:48 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:38585 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726762AbeILBYs (ORCPT ); Tue, 11 Sep 2018 21:24:48 -0400 Received: by mail-qt0-f196.google.com with SMTP id x7-v6so29691452qtk.5 for ; Tue, 11 Sep 2018 13:23:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id; bh=ovc+9kXgh36nSA1UkdgT7YSHkgj/CU1U2wObjVo22tY=; b=UodsBKJq03+7v1e4YteBI/FgQ3mCF4XDZ67Ha2bIgZPBrWP4ad8StkN3nARLcKqLBE hDUZiPhr9jOx9awnQUHqPIECqxDZ3rDRIfA8j8yPXyDhhlzeb4NPNZWCA/fvZ80ijb/Z SoewDB9rihIEWSIopzZSW69EvT9NmLFebfPKjh/00dEKt3BNM6Qqc4+vTk1enWuxv1cL UtRbVWPVKL96qq5xyiZSldBdcIomQZOTb5DSQEZ3kWvtj1+ngtRTqbE0Y/DAM6HdQiUV bgr3dK8ugXL/UmzEcTjmr1CWJ42cyQDczdj22U5iEhwCoMbGUZ4KxydUCbf9LXck+KXu vJxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id; bh=ovc+9kXgh36nSA1UkdgT7YSHkgj/CU1U2wObjVo22tY=; b=QePT5+PLL1hX66crX5IqWnANQCgyrTArIABOTs8ftGd49ar8NbJe1vDc1jvewxD1Yg g5Kyhd18r1ImwaComLeD25nxZ2nDy3H3UuRqL3cQeAaUTfS0bU8y+kn2kMFDhSllwkNW UcKKkpwKf8W1eGem8i0lLUYDiFl3wmlnpuoVyfy63QAokuattB1SJFJkqbZ1uLmD052w 1MOuwEbxWtKlMQ4DJBGKOJy4QphbmhtT+D8BNxp/OOJFsU6xOfu+yMnL6aC86akwV6fb 81m6+FTSBqsrgf+5oc89/R/M3Z6j1P0QCDXh+h8IRS4ZN1UHVO6aGqwzINWoYCuDZo31 P4Xg== X-Gm-Message-State: APzg51DSJV1FJy2nIvk+OxNxod8TD5nKcn4U4sSodQH2f6mr5ynRAOYW zkoX+fEh86y/Ed9vLMaVyuxZQphtj4M= X-Google-Smtp-Source: ANB0VdaLtdszdccJ6Di6POX0SPIkEGl7yiCcf0pJJBaX2M/Wciw12thXn1u/w/WSibij4/YjcdibTA== X-Received: by 2002:a0c:9a0f:: with SMTP id p15-v6mr19030850qvd.126.1536697430497; Tue, 11 Sep 2018 13:23:50 -0700 (PDT) Received: from gouda.nowheycreamery.com.local (c-68-40-188-1.hsd1.mi.comcast.net. [68.40.188.1]) by smtp.gmail.com with ESMTPSA id u129-v6sm11015517qkd.45.2018.09.11.13.23.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Sep 2018 13:23:49 -0700 (PDT) From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: Trond.Myklebust@hammerspace.com, linux-nfs@vger.kernel.org Subject: [PATCH 1/3] NFS: Split out the body of nfs4_reclaim_open_state() Date: Tue, 11 Sep 2018 16:23:46 -0400 Message-Id: <20180911202348.23160-1-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.18.0 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 From: Anna Schumaker Moving all of this into a new function removes the need for cramped indentation, making the code overall easier to look at. I also take this chance to switch copy recovery over to using nfs4_stateid_match_other() Signed-off-by: Anna Schumaker --- fs/nfs/nfs4state.c | 83 ++++++++++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 36 deletions(-) diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 3df0eb52da1c..aa46a3216d60 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -1547,10 +1547,51 @@ static int nfs4_reclaim_locks(struct nfs4_state *state, const struct nfs4_state_ return status; } +static int __nfs4_reclaim_open_state(struct nfs4_state_owner *sp, struct nfs4_state *state, + const struct nfs4_state_recovery_ops *ops) +{ + struct nfs4_lock_state *lock; + int status; + + status = ops->recover_open(sp, state); + if (status < 0) + return status; + + status = nfs4_reclaim_locks(state, ops); + if (status < 0) + return status; + + if (!test_bit(NFS_DELEGATED_STATE, &state->flags)) { + spin_lock(&state->state_lock); + list_for_each_entry(lock, &state->lock_states, ls_locks) { + if (!test_bit(NFS_LOCK_INITIALIZED, &lock->ls_flags)) + pr_warn_ratelimited("NFS: %s: Lock reclaim failed!\n", __func__); + } + spin_unlock(&state->state_lock); + } + +#ifdef CONFIG_NFS_V4_2 + if (test_bit(NFS_CLNT_DST_SSC_COPY_STATE, &state->flags)) { + struct nfs4_copy_state *copy; + spin_lock(&sp->so_server->nfs_client->cl_lock); + list_for_each_entry(copy, &sp->so_server->ss_copies, copies) { + if (nfs4_stateid_match_other(&state->stateid, ©->parent_state->stateid)) + continue; + copy->flags = 1; + complete(©->completion); + break; + } + spin_unlock(&sp->so_server->nfs_client->cl_lock); + } +#endif /* CONFIG_NFS_V4_2 */ + + clear_bit(NFS_STATE_RECLAIM_NOGRACE, &state->flags); + return status; +} + static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs4_state_recovery_ops *ops) { struct nfs4_state *state; - struct nfs4_lock_state *lock; int status = 0; /* Note: we rely on the sp->so_states list being ordered @@ -1573,43 +1614,13 @@ static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs continue; atomic_inc(&state->count); spin_unlock(&sp->so_lock); - status = ops->recover_open(sp, state); + status = __nfs4_reclaim_open_state(sp, state, ops); if (status >= 0) { - status = nfs4_reclaim_locks(state, ops); - if (status >= 0) { - if (!test_bit(NFS_DELEGATED_STATE, &state->flags)) { - spin_lock(&state->state_lock); - list_for_each_entry(lock, &state->lock_states, ls_locks) { - if (!test_bit(NFS_LOCK_INITIALIZED, &lock->ls_flags)) - pr_warn_ratelimited("NFS: " - "%s: Lock reclaim " - "failed!\n", __func__); - } - spin_unlock(&state->state_lock); - } - clear_bit(NFS_STATE_RECLAIM_NOGRACE, - &state->flags); -#ifdef CONFIG_NFS_V4_2 - if (test_bit(NFS_CLNT_DST_SSC_COPY_STATE, &state->flags)) { - struct nfs4_copy_state *copy; - - spin_lock(&sp->so_server->nfs_client->cl_lock); - list_for_each_entry(copy, &sp->so_server->ss_copies, copies) { - if (memcmp(&state->stateid.other, ©->parent_state->stateid.other, NFS4_STATEID_SIZE)) - continue; - copy->flags = 1; - complete(©->completion); - printk("AGLO: server rebooted waking up the copy\n"); - break; - } - spin_unlock(&sp->so_server->nfs_client->cl_lock); - } -#endif /* CONFIG_NFS_V4_2 */ - nfs4_put_open_state(state); - spin_lock(&sp->so_lock); - goto restart; - } + nfs4_put_open_state(state); + spin_lock(&sp->so_lock); + goto restart; } + switch (status) { default: printk(KERN_ERR "NFS: %s: unhandled error %d\n",