Skip to contentSkip to conversation

remove incorrect "Lock reclaim failed" warning when delegation is in force.

PATCH/RFC NeilBrown 2 participants 3 messages Aug 8, 2013 – Aug 12, 2013

Subsystems (2)
lore
Share & tools
lore

NeilBrown

author
#0 lore raw

Hi,
I'm trying to track down a strange problem with state ids going bad (possibly linked to ntp changing the system time on the non-Linux server) and am still learning about how the state management works.

But I've come across an error where I don't think there should be one.

For whatever reason the client gets a BAD_STATEID on a file that it has a lock on. The open gets a write delegation so that when it runs nfs4_reclaim_locks(), nfs4_lock_reclaim aborts early without doing anything (it doesn't need to because there is a delegation).
But the code below then checks that NFS_LOCK_INITIALIZED is set on all lock states. But it isn't because nfs4_clear_open_state cleared it and nfs4_lock_reclaim didn't bother setting it.

So I think the error should only be printed if there is no delegated state, hence this patch.

Does it look right, or have I misunderstood something?

Thanks,
NeilBrown

fs/nfs/nfs4state.c +9 -7
index 1fab140..1876ee7 100644
@@ -1444,14 +1444,16 @@ restart:
 		if (status >= 0) {
 			status = nfs4_reclaim_locks(state, ops);
 			if (status >= 0) {
-				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__);
+				if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0) {
+					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);
 				}
-				spin_unlock(&state->state_lock);
 				nfs4_put_open_state(state);
 				spin_lock(&sp->so_lock);
 				goto restart;
#1 lore raw

T24gVGh1LCAyMDEzLTA4LTA4IGF0IDEyOjU5ICsxMDAwLCBOZWlsQnJvd24gd3JvdGU6DQo+IEhp LA0KPiAgSSd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5r IHRoZSBlcnJvciBzaG91bGQgb25seSBiZSBwcmludGVkIGlmIHRoZXJlIGlzIG5vIGRlbGVnYXRl ZCBzdGF0ZSwNCj4gIGhlbmNlIHRoaXMgcGF0Y2guDQo+IA0KPiAgRG9lcyBpdCBsb29rIHJpZ2h0 LCBvciBoYXZlIEkgbWlzdW5kZXJzdG9vZCBzb21ldGhpbmc/DQo+IA0KDQpIaSBOZWlsLA0KDQpU aGF0IGFuYWx5c2lzIGxvb2tzIGNvcnJlY3QuIENhbiB5b3UgcmVzZW5kIHRoZSBwYXRjaCB3aXRo IGFuDQphcHByb3ByaWF0ZSBzaWduZWQtb2ZmLWJ5IGFuZCBjaGFuZ2Vsb2cgZW50cnk/DQoNClRo YW5rcyENCiAgVHJvbmQNCi0tIA0KVHJvbmQgTXlrbGVidXN0DQpMaW51eCBORlMgY2xpZW50IG1h aW50YWluZXINCg0KTmV0QXBwDQpUcm9uZC5NeWtsZWJ1c3RAbmV0YXBwLmNvbQ0Kd3d3Lm5ldGFw cC5jb20NCg==

author
#2 lore raw
Quoted 19 lines · Trond
Quoted 18 lines · NeilBrown

Hi,
I'm trying to track down a strange problem with state ids going bad (possibly linked to ntp changing the system time on the non-Linux server) and am still learning about how the state management works.

But I've come across an error where I don't think there should be one.

For whatever reason the client gets a BAD_STATEID on a file that it has a lock on. The open gets a write delegation so that when it runs nfs4_reclaim_locks(), nfs4_lock_reclaim aborts early without doing anything (it doesn't need to because there is a delegation).
But the code below then checks that NFS_LOCK_INITIALIZED is set on all lock states. But it isn't because nfs4_clear_open_state cleared it and nfs4_lock_reclaim didn't bother setting it.

So I think the error should only be printed if there is no delegated state, hence this patch.

Quoted 7 lines
Quoted 2 lines

Does it look right, or have I misunderstood something?

Hi Neil,

That analysis looks correct. Can you resend the patch with an appropriate signed-off-by and changelog entry?

Thanks. I've resent separately.

NeilBrown