From patchwork Fri Nov 30 14:44:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Mayhew X-Patchwork-Id: 10706433 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 C947413BB for ; Fri, 30 Nov 2018 14:44:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB4B53018B for ; Fri, 30 Nov 2018 14:44:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AFF3730190; Fri, 30 Nov 2018 14:44:05 +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.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 5648E3018B for ; Fri, 30 Nov 2018 14:44:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726803AbeLABxg (ORCPT ); Fri, 30 Nov 2018 20:53:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53008 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726615AbeLABxg (ORCPT ); Fri, 30 Nov 2018 20:53:36 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 096B63082E23; Fri, 30 Nov 2018 14:44:04 +0000 (UTC) Received: from coeurl.usersys.redhat.com (ovpn-120-28.rdu2.redhat.com [10.10.120.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF3C8649DD; Fri, 30 Nov 2018 14:44:03 +0000 (UTC) Received: by coeurl.usersys.redhat.com (Postfix, from userid 1000) id 35A9E20272; Fri, 30 Nov 2018 09:44:03 -0500 (EST) From: Scott Mayhew To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 1/1] NFSv4: fix "Lock reclaim failed" false positives Date: Fri, 30 Nov 2018 09:44:03 -0500 Message-Id: <20181130144403.31621-2-smayhew@redhat.com> In-Reply-To: <20181130144403.31621-1-smayhew@redhat.com> References: <20181130144403.31621-1-smayhew@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 30 Nov 2018 14:44:04 +0000 (UTC) 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 During NFSv4 state recovery, the client attempts to reclaim locks that are on the flc_posix and flc_flock lists of the file_lock_context of the inode associated with an nfs4_state. Then the client walks the nfs4_state's lock_states list, looking for nfs4_lock_state's that do not have NFS_LOCK_INITIALIZED set in their ls_flags. If any are found, a "Lock reclaim failed!" warning is issued. Since nfs4_lock_state's are created before the corresponding file_lock is in place at the vfs layer and removed after the file_lock is released at the vfs layer, there is the possibility of false-positive warnings if the client was in the process of acquiring or releasing locks when state recovery was started. Add a new nfs4_lock_state->ls_flag called "NFS_LOCK_TRY_RECLAIM" to indicate the states that the client actually tried to reclaim, and ignore nfs4_lock_states that do not have that flag when deciding whether or not to log the "Lock reclaim failed!" warning. Signed-off-by: Scott Mayhew --- fs/nfs/nfs4_fs.h | 1 + fs/nfs/nfs4state.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 1b994b527518..6ed04e8f8953 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -144,6 +144,7 @@ struct nfs4_lock_state { struct nfs4_state * ls_state; /* Pointer to open state */ #define NFS_LOCK_INITIALIZED 0 #define NFS_LOCK_LOST 1 +#define NFS_LOCK_TRY_RECLAIM 2 unsigned long ls_flags; struct nfs_seqid_counter ls_seqid; nfs4_stateid ls_stateid; diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index d8decf2ec48f..bd7a07641bd7 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -1509,6 +1509,9 @@ static int nfs4_reclaim_locks(struct nfs4_state *state, const struct nfs4_state_ if (nfs_file_open_context(fl->fl_file)->state != state) continue; spin_unlock(&flctx->flc_lock); + lsp = fl->fl_u.nfs4_fl.owner; + if (lsp) + set_bit(NFS_LOCK_TRY_RECLAIM, &lsp->ls_flags); status = ops->recover_lock(state, fl); switch (status) { case 0: @@ -1592,7 +1595,8 @@ static int __nfs4_reclaim_open_state(struct nfs4_state_owner *sp, struct nfs4_st 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)) + if (test_bit(NFS_LOCK_TRY_RECLAIM, &lock->ls_flags) && + !test_bit(NFS_LOCK_INITIALIZED, &lock->ls_flags)) pr_warn_ratelimited("NFS: %s: Lock reclaim failed!\n", __func__); } spin_unlock(&state->state_lock); @@ -1693,6 +1697,7 @@ static void nfs4_clear_open_state(struct nfs4_state *state) list_for_each_entry(lock, &state->lock_states, ls_locks) { lock->ls_seqid.flags = 0; clear_bit(NFS_LOCK_INITIALIZED, &lock->ls_flags); + clear_bit(NFS_LOCK_TRY_RECLAIM, &lock->ls_flags); } spin_unlock(&state->state_lock); }