From: Scott Mayhew <smayhew@redhat.com>
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 [thread overview]
Message-ID: <20181130144403.31621-2-smayhew@redhat.com> (raw)
In-Reply-To: <20181130144403.31621-1-smayhew@redhat.com>
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 <smayhew@redhat.com>
---
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);
}
--
2.17.1
prev parent reply other threads:[~2018-11-30 14:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-30 14:44 [PATCH 0/1] NFSv4: fix "Lock reclaim failed" false positives Scott Mayhew
2018-11-30 14:44 ` Scott Mayhew [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181130144403.31621-2-smayhew@redhat.com \
--to=smayhew@redhat.com \
--cc=anna.schumaker@netapp.com \
--cc=linux-nfs@vger.kernel.org \
--cc=trond.myklebust@hammerspace.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox