public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] nfsd41: renew_client() needs to be called with the client_mutex held
@ 2009-06-18  1:50 Ricardo Labiaga
  2009-06-18 17:31 ` J. Bruce Fields
  0 siblings, 1 reply; 5+ messages in thread
From: Ricardo Labiaga @ 2009-06-18  1:50 UTC (permalink / raw)
  To: bfields; +Cc: bhalevy, pnfs, linux-nfs, Ricardo Labiaga

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

Signed-off-by: Ricardo Labiaga <Ricardo.Labiaga@netapp.com>
---
 fs/nfsd/nfs4state.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 4cb5d1d..18258d7 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -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);
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] nfsd41: renew_client() needs to be called with the client_mutex held
  2009-06-18  1:50 [PATCH 1/1] nfsd41: renew_client() needs to be called with the client_mutex held Ricardo Labiaga
@ 2009-06-18 17:31 ` J. Bruce Fields
  2009-06-18 17:39   ` Labiaga, Ricardo
  0 siblings, 1 reply; 5+ messages in thread
From: J. Bruce Fields @ 2009-06-18 17:31 UTC (permalink / raw)
  To: Ricardo Labiaga; +Cc: bhalevy, pnfs, linux-nfs

On Wed, Jun 17, 2009 at 06:50:45PM -0700, Ricardo Labiaga wrote:
> renew_client() manipulates the client queue for lease renewal.  Need to
> obtain the client_mutex before manipulating it.
> 
> Signed-off-by: Ricardo Labiaga <Ricardo.Labiaga@netapp.com>
> ---
>  fs/nfsd/nfs4state.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index 4cb5d1d..18258d7 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] nfsd41: renew_client() needs to be called with the client_mutex held
  2009-06-18 17:31 ` J. Bruce Fields
@ 2009-06-18 17:39   ` Labiaga, Ricardo
  2009-06-18 17:48     ` J. Bruce Fields
  0 siblings, 1 reply; 5+ messages in thread
From: Labiaga, Ricardo @ 2009-06-18 17:39 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: bhalevy, pnfs, linux-nfs

On 6/18/09 10:31 AM, "J. Bruce Fields" <bfields@fieldses.org> wrote:

> On Wed, Jun 17, 2009 at 06:50:45PM -0700, Ricardo Labiaga wrote:
>> renew_client() manipulates the client queue for lease renewal.  Need to
>> obtain the client_mutex before manipulating it.
>> 
>> Signed-off-by: Ricardo Labiaga <Ricardo.Labiaga@netapp.com>
>> ---
>>  fs/nfsd/nfs4state.c |    2 ++
>>  1 files changed, 2 insertions(+), 0 deletions(-)
>> 
>> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
>> index 4cb5d1d..18258d7 100644
>> --- a/fs/nfsd/nfs4state.c
>> +++ b/fs/nfsd/nfs4state.c
>> @@ -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.)
> 

Ah, OK.  I didn't know that.

> 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

> 
> --b.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] nfsd41: renew_client() needs to be called with the client_mutex held
  2009-06-18 17:39   ` Labiaga, Ricardo
@ 2009-06-18 17:48     ` J. Bruce Fields
  2009-06-18 17:51       ` Labiaga, Ricardo
  0 siblings, 1 reply; 5+ messages in thread
From: J. Bruce Fields @ 2009-06-18 17:48 UTC (permalink / raw)
  To: Labiaga, Ricardo; +Cc: bhalevy, pnfs, linux-nfs

On Thu, Jun 18, 2009 at 10:39:10AM -0700, Labiaga, Ricardo wrote:
> On 6/18/09 10:31 AM, "J. Bruce Fields" <bfields@fieldses.org> wrote:
> 
> > On Wed, Jun 17, 2009 at 06:50:45PM -0700, Ricardo Labiaga wrote:
> >> renew_client() manipulates the client queue for lease renewal.  Need to
> >> obtain the client_mutex before manipulating it.
> >> 
> >> Signed-off-by: Ricardo Labiaga <Ricardo.Labiaga@netapp.com>
> >> ---
> >>  fs/nfsd/nfs4state.c |    2 ++
> >>  1 files changed, 2 insertions(+), 0 deletions(-)
> >> 
> >> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> >> index 4cb5d1d..18258d7 100644
> >> --- a/fs/nfsd/nfs4state.c
> >> +++ b/fs/nfsd/nfs4state.c
> >> @@ -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.)
> > 
> 
> 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.

> > 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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] nfsd41: renew_client() needs to be called with the client_mutex held
  2009-06-18 17:48     ` J. Bruce Fields
@ 2009-06-18 17:51       ` Labiaga, Ricardo
  0 siblings, 0 replies; 5+ messages in thread
From: Labiaga, Ricardo @ 2009-06-18 17:51 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: bhalevy, pnfs, linux-nfs

On 6/18/09 10:48 AM, "J. Bruce Fields" <bfields@fieldses.org> wrote:

> On Thu, Jun 18, 2009 at 10:39:10AM -0700, Labiaga, Ricardo wrote:
>> On 6/18/09 10:31 AM, "J. Bruce Fields" <bfields@fieldses.org> wrote:
>> 
>>> On Wed, Jun 17, 2009 at 06:50:45PM -0700, Ricardo Labiaga wrote:
>>>> renew_client() manipulates the client queue for lease renewal.  Need to
>>>> obtain the client_mutex before manipulating it.
>>>> 
>>>> Signed-off-by: Ricardo Labiaga <Ricardo.Labiaga@netapp.com>
>>>> ---
>>>>  fs/nfsd/nfs4state.c |    2 ++
>>>>  1 files changed, 2 insertions(+), 0 deletions(-)
>>>> 
>>>> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
>>>> index 4cb5d1d..18258d7 100644
>>>> --- a/fs/nfsd/nfs4state.c
>>>> +++ b/fs/nfsd/nfs4state.c
>>>> @@ -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.)
>>> 
>> 
>> 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.

Right, thanks.

- ricardo

> 
>>> 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.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-06-18 17:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-18  1:50 [PATCH 1/1] nfsd41: renew_client() needs to be called with the client_mutex held Ricardo Labiaga
2009-06-18 17:31 ` J. Bruce Fields
2009-06-18 17:39   ` Labiaga, Ricardo
2009-06-18 17:48     ` J. Bruce Fields
2009-06-18 17:51       ` Labiaga, Ricardo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox