From: NeilBrown <neilb@suse.de>
Subject: NFS: don't try to use lock state when we hold a delegation
Patch-mainline: no - code has changed a lot
References: bnc#831029

When state is recoverred, we might get a delegation where before we
didn't and so go explicit lock states.

So it is possible that we hold a delegation and also have some lock
state ids that are no longer valid.

In this case it is important to use the delegation stateid, not the
old lock stateids.

Signed-off-by: Neil Brown <neilb@suse.de>

---
 fs/nfs/nfs4state.c |    2 ++
 1 file changed, 2 insertions(+)

--- linux-3.0-SLE11-SP2.orig/fs/nfs/nfs4state.c
+++ linux-3.0-SLE11-SP2/fs/nfs/nfs4state.c
@@ -881,6 +881,8 @@ void nfs4_copy_stateid(nfs4_stateid *dst
 	} while (read_seqretry(&state->seqlock, seq));
 	if (test_bit(LK_STATE_IN_USE, &state->flags) == 0)
 		return;
+	if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0)
+		return;
 
 	spin_lock(&state->state_lock);
 	lsp = __nfs4_find_lock_state(state, fl_owner, fl_pid, NFS4_ANY_LOCK_TYPE);
