Skip to contentSkip to conversation

nfsd41: renew_client() needs to be called with the client_mutex held

PATCH In review Ricardo Labiaga 2 participants 5 messages Jun 18, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfsd41: renew_client() needs to be called with the client_mutex held

renew_client() manipulates the client queue for lease renewal. Need to obtain the client_mutex before manipulating it.

---
 fs/nfsd/nfs4state.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/nfsd/nfs4state.c +2 -0
index 4cb5d1d..18258d7 100644
@@ -1537,7 +1537,9 @@ replay_cache:
 	 * Hold a session reference until done processing the compound:
 	 * nfsd4_put_session called only if the cstate slot is set.
 	 */
+	nfs4_lock_state();
 	renew_client(session->se_client);
+	nfs4_unlock_state();
 	nfsd4_get_session(session);
 out:
 	spin_unlock(&sessionid_lock);
Signature · 1 line
1.5.4.3
#1 lore raw
Quoted 13 lines · Ricardo Labiaga

renew_client() manipulates the client queue for lease renewal. Need to obtain the client_mutex before manipulating it.

---
 fs/nfsd/nfs4state.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/nfsd/nfs4state.c +0 -0
index 4cb5d1d..18258d7 100644

fs/nfsd/nfs4state.c replay_cache: · line 1545

Quoted 9 lines
fs/nfsd/nfs4state.c +2 -0
@@ -1537,7 +1537,9 @@ replay_cache:
 	 * Hold a session reference until done processing the compound:
 	 * nfsd4_put_session called only if the cstate slot is set.
 	 */
+	nfs4_lock_state();
 	renew_client(session->se_client);
+	nfs4_unlock_state();
 	nfsd4_get_session(session);
 out:
 	spin_unlock(&sessionid_lock);

We can't take a mutex while handling a spinlock. (And you should have gotten warnings about this--not sure what kernel hacking config options you may need turned on for that.)

Possible hack: add a spinlock that for now will just cover the client lru?

--b.

#2 lore raw
Quoted 19 lines · J. Bruce Fields
Quoted 18 lines · Ricardo Labiaga

renew_client() manipulates the client queue for lease renewal. Need to obtain the client_mutex before manipulating it.

---
 fs/nfsd/nfs4state.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/nfsd/nfs4state.c +1 -0
index 4cb5d1d..18258d7 100644
@@ -1537,7 +1537,9 @@ replay_cache:
 * Hold a session reference until done processing the compound:
 * nfsd4_put_session called only if the cstate slot is set.
 */
+ nfs4_lock_state();
 renew_client(session->se_client);
Quoted 9 lines

fs/nfsd/nfs4state.c replay_cache: · line 1545

Quoted 4 lines
fs/nfsd/nfs4state.c +1 -0
+ nfs4_unlock_state();
 nfsd4_get_session(session);
 out:
 spin_unlock(&sessionid_lock);

We can't take a mutex while handling a spinlock. (And you should have gotten warnings about this--not sure what kernel hacking config options you may need turned on for that.)

Ah, OK. I didn't know that.

Quoted 2 lines

Possible hack: add a spinlock that for now will just cover the client lru?

Let me study this some more and see if I can simply drop the sessionid spinlock before renewing the state.

- ricardo

Quoted 2 lines

--b.

#3 lore raw
Quoted 31 lines · Ricardo
Quoted 19 lines · J. Bruce Fields
Quoted 18 lines · Ricardo Labiaga

renew_client() manipulates the client queue for lease renewal. Need to obtain the client_mutex before manipulating it.

---
 fs/nfsd/nfs4state.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/nfsd/nfs4state.c +1 -0
index 4cb5d1d..18258d7 100644
@@ -1537,7 +1537,9 @@ replay_cache:
 * Hold a session reference until done processing the compound:
 * nfsd4_put_session called only if the cstate slot is set.
 */
+ nfs4_lock_state();
 renew_client(session->se_client);
Quoted 9 lines

fs/nfsd/nfs4state.c replay_cache: · line 1545

Quoted 4 lines
fs/nfsd/nfs4state.c +1 -0
+ nfs4_unlock_state();
 nfsd4_get_session(session);
 out:
 spin_unlock(&sessionid_lock);

We can't take a mutex while handling a spinlock. (And you should have gotten warnings about this--not sure what kernel hacking config options you may need turned on for that.)

Quoted 1 line

Ah, OK. I didn't know that.

The deadlock:

Task 1 takes a spinlock.
Task 1 sleeps on the mutex.
Task 2 is scheduled in.
Task 2 requests the same spinlock, spins.

Now Task 2 is spinning waiting for the spinlock, keeping task 1 from getting the cpu back and releaseing the spinlock. So, no sleeping under spinlocks.

Quoted 5 lines
Quoted 2 lines

Possible hack: add a spinlock that for now will just cover the client lru?

Let me study this some more and see if I can simply drop the sessionid spinlock before renewing the state.

OK.

--b.

#4 lore raw
Quoted 36 lines · J. Bruce Fields
Quoted 31 lines · Ricardo
Quoted 19 lines · J. Bruce Fields
Quoted 18 lines · Ricardo Labiaga

renew_client() manipulates the client queue for lease renewal. Need to obtain the client_mutex before manipulating it.

---
 fs/nfsd/nfs4state.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/nfsd/nfs4state.c +1 -0
index 4cb5d1d..18258d7 100644
@@ -1537,7 +1537,9 @@ replay_cache:
 * Hold a session reference until done processing the compound:
 * nfsd4_put_session called only if the cstate slot is set.
 */
+ nfs4_lock_state();
 renew_client(session->se_client);
Quoted 9 lines

fs/nfsd/nfs4state.c replay_cache: · line 1545

Quoted 4 lines
fs/nfsd/nfs4state.c +1 -0
+ nfs4_unlock_state();
 nfsd4_get_session(session);
 out:
 spin_unlock(&sessionid_lock);

We can't take a mutex while handling a spinlock. (And you should have gotten warnings about this--not sure what kernel hacking config options you may need turned on for that.)

Quoted 1 line

Ah, OK. I didn't know that.

The deadlock:

Quoted 8 lines

Task 1 takes a spinlock.
Task 1 sleeps on the mutex.
Task 2 is scheduled in.
Task 2 requests the same spinlock, spins.

Now Task 2 is spinning waiting for the spinlock, keeping task 1 from getting the cpu back and releaseing the spinlock. So, no sleeping under spinlocks.

Right, thanks.

- ricardo

Quoted 10 lines
Quoted 6 lines
Quoted 3 lines

Possible hack: add a spinlock that for now will just cover the client lru?

Let me study this some more and see if I can simply drop the sessionid spinlock before renewing the state.

OK.

--b.