public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@citi.umich.edu>
To: Benny Halevy <bhalevy@panasas.com>
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATCH 1/2] nfsd4: complete enforcement of 4.1 op ordering
Date: Tue, 27 Apr 2010 12:36:29 -0400	[thread overview]
Message-ID: <20100427163629.GI30729@fieldses.org> (raw)
In-Reply-To: <4BD70673.6040102@panasas.com>

On Tue, Apr 27, 2010 at 06:44:51PM +0300, Benny Halevy wrote:
> On Apr. 27, 2010, 18:01 +0300, "J. Bruce Fields" <bfields@citi.umich.edu> wrote:
> > I think what we actually want is a mechanism with semantics like yours,
> > but with multiple RENEW values so we can track how many users there are
> > and have only the last one do the renew.
> > 
> > One possibility: 
> > 
> > 	- add a cl_users field, with:
> > 		cl_user>0 meaning: somebody's using this client right
> > 			now, don't expire it.  (Your RENEW state.)
> > 		cl_user<0 meaning: this client is already being expired,
> > 			don't try to use it (or any sessionid or other
> > 			state associated with it). (Your EXPIRED state.)
> > 		cl_user==0: fair game to either use or (if expiry time
> > 			has passed) to expire. (Your NORMAL state.)
> > 
> > 	- add a cl_renewme boolean, meaning: last user of this client
> > 	  (user to decrement to 0) should renew the client (reset the
> > 	  expiry time and move it to the back of the lru).
> > 
> > So:
> > 
> > 	- in laundromat: 
> > 		- atomically check whether cl_users is 0, and, if so,
> > 		  decrement to -1.  (If positive, skip expiring this
> > 		  client.)
> > 
> > 	- on looking up a sessionid (or, eventually, any state object
> > 	  associated with a client), call get_client(), which:
> > 		- atomically checks whether cl_users is >=0, and, if so,
> > 		  increments it.  If <0, fail to find the object and
> > 		  return an appropriate error (STALE?).
> > 	- on renew:
> > 		- BUG_ON(cl_user<=0)
> > 		- set cl_renewme
> > 	- on dropping reference to a sessionid (or, eventually, any
> > 	  state object associated with a client), call put_client(),
> > 	  which:
> > 		- atomically decrements cl_users, checks whether it hits
> > 		  zero, and (if so, and if cl_renewme set), renews the
> > 		  client.
> > 
> > One possible implementation: make cl_users atomic, add a per-client
> > spinlock, make the put_client() do an atomic_dec_and_lock(), etc.
> > 
> > --b.
> 
> Sounds good. I'll take a stab at it right away.

Great, thanks; let me know what I can do.

> (Funny that my original implementation uses a counter but IIRC
> I decided at the time it was too complicated but I agree it's much better)

You might also look at get_write_access/deny_write_access and friends as
an implementation of something similar.

--b.

  reply	other threads:[~2010-04-27 16:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-22 14:32 [PATCH 1/2] nfsd4: complete enforcement of 4.1 op ordering J. Bruce Fields
2010-04-22 14:32 ` [PATCH 2/2] nfsd4: implement reclaim_complete J. Bruce Fields
2010-04-22 14:48 ` [PATCH 1/2] nfsd4: complete enforcement of 4.1 op ordering J. Bruce Fields
2010-04-22 15:03   ` J. Bruce Fields
2010-04-23 21:24   ` J. Bruce Fields
2010-04-23 23:13     ` J. Bruce Fields
2010-04-24  0:10       ` J. Bruce Fields
2010-04-27 15:03         ` Benny Halevy
2010-04-27 14:40     ` Benny Halevy
2010-04-27 15:01       ` J. Bruce Fields
2010-04-27 15:44         ` Benny Halevy
2010-04-27 16:36           ` J. Bruce Fields [this message]
2010-04-27 15:46         ` Benny Halevy
2010-04-27 16:12           ` J. Bruce Fields
2010-04-27 16:22             ` Benny Halevy
2010-04-27 16:34               ` J. Bruce Fields
2010-04-27 16:44                 ` Benny Halevy
2010-04-27 18:10                   ` J. Bruce Fields

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100427163629.GI30729@fieldses.org \
    --to=bfields@citi.umich.edu \
    --cc=bhalevy@panasas.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox