[PATCH 1/1] NFSv4: fix "Lock reclaim failed" false positives

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux