All of lore.kernel.org
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: aglo@citi.umich.edu, kwc@citi.umich.edu, linux-nfs@vger.kernel.org
Subject: Re: [PATCH 4/9] rpc: add an rpc_pipe_open method
Date: Mon, 10 Nov 2008 15:37:57 -0500	[thread overview]
Message-ID: <20081110203757.GI19053@fieldses.org> (raw)
In-Reply-To: <1226349322.7599.59.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>

On Mon, Nov 10, 2008 at 03:35:22PM -0500, Trond Myklebust wrote:
> On Sun, 2008-11-09 at 16:04 -0500, J. Bruce Fields wrote:
> > We want to transition to a new gssd upcall which is text-based and more
> > easily extensible.
> > 
> > To simplify upgrades, as well as testing and debugging, it will help if
> > we can upgrade gssd (to a version which understands the new upcall)
> > without having to choose at boot (or module-load) time whether we want
> > the new or the old upcall.
> > 
> > We will do this by providing two different pipes: one named, as
> > currently, after the mechanism (normally "krb5"), and supporting the
> > old upcall.  One named "gssd" and supporting the new upcall version.
> > 
> > We allow gssd to indicate which version it supports by its choice of
> > which pipe to open.
> > 
> > As we have no interest in supporting *simultaneous* use of both
> > versions, we'll forbid opening both pipes at the same time.
> > 
> > So, add a new pipe_open callback to the rpc_pipefs api, which the gss
> > code can use to track which pipes have been open, and to refuse opens of
> > incompatible pipes.
> > 
> > We only need this to be called on the first open of a given pipe.
> > 
> > Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
> > ---
> >  include/linux/sunrpc/rpc_pipe_fs.h |    1 +
> >  net/sunrpc/rpc_pipe.c              |   21 ++++++++++++++-------
> >  2 files changed, 15 insertions(+), 7 deletions(-)
> > 
> > diff --git a/include/linux/sunrpc/rpc_pipe_fs.h b/include/linux/sunrpc/rpc_pipe_fs.h
> > index 51b977a..cea764c 100644
> > --- a/include/linux/sunrpc/rpc_pipe_fs.h
> > +++ b/include/linux/sunrpc/rpc_pipe_fs.h
> > @@ -15,6 +15,7 @@ struct rpc_pipe_ops {
> >  	ssize_t (*upcall)(struct file *, struct rpc_pipe_msg *, char __user *, size_t);
> >  	ssize_t (*downcall)(struct file *, const char __user *, size_t);
> >  	void (*release_pipe)(struct inode *);
> > +	int (*open_pipe)(struct inode *);
> >  	void (*destroy_msg)(struct rpc_pipe_msg *);
> >  };
> >  
> > diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
> > index 23a2b8f..4171ab7 100644
> > --- a/net/sunrpc/rpc_pipe.c
> > +++ b/net/sunrpc/rpc_pipe.c
> > @@ -169,16 +169,23 @@ static int
> >  rpc_pipe_open(struct inode *inode, struct file *filp)
> >  {
> >  	struct rpc_inode *rpci = RPC_I(inode);
> > +	int first_open = rpci->nreaders == 0 && rpci->nwriters == 0;
> >  	int res = -ENXIO;
> >  
> >  	mutex_lock(&inode->i_mutex);
> > -	if (rpci->ops != NULL) {
> > -		if (filp->f_mode & FMODE_READ)
> > -			rpci->nreaders ++;
> > -		if (filp->f_mode & FMODE_WRITE)
> > -			rpci->nwriters ++;
> > -		res = 0;
> > +	if (rpci->ops == NULL)
> > +		goto out;
> > +	if (first_open && rpci->ops->open_pipe) {
> > +		res = rpci->ops->open_pipe(inode);
> > +		if (res)
> > +			goto out;
> >  	}
> > +	if (filp->f_mode & FMODE_READ)
> > +		rpci->nreaders++;
> > +	if (filp->f_mode & FMODE_WRITE)
> > +		rpci->nwriters++;
> > +	res = 0;
> > +out:
> 
> BTW: This is racy. You have to set first_open _after_ you take the
> inode->i_mutex.

Whoops!  Good catch, thanks--fixed.

--b.

> 
> >  	mutex_unlock(&inode->i_mutex);
> >  	return res;
> >  }
> > @@ -748,7 +755,7 @@ rpc_rmdir(struct dentry *dentry)
> >   * @name: name of pipe
> >   * @private: private data to associate with the pipe, for the caller's use
> >   * @ops: operations defining the behavior of the pipe: upcall, downcall,
> > - *	release_pipe, and destroy_msg.
> > + *	release_pipe, open_pipe, and destroy_msg.
> >   * @flags: rpc_inode flags
> >   *
> >   * Data is made available for userspace to read by calls to
> -- 
> Trond Myklebust
> Linux NFS client maintainer
> 
> NetApp
> Trond.Myklebust@netapp.com
> www.netapp.com

  parent reply	other threads:[~2008-11-10 20:37 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-13 22:50 [RFC] new client gssd upcall J. Bruce Fields
2008-06-13 22:50 ` [PATCH 1/5] rpc: remove unnecessary assignment J. Bruce Fields
2008-06-13 22:50   ` [PATCH 2/5] rpc: Use separate spinlock for cred locking in auth_gss.c J. Bruce Fields
2008-06-13 22:50     ` [PATCH 3/5] rpc: move in_downcall list to gss code J. Bruce Fields
2008-06-13 22:50       ` [PATCH 4/5] rpc: add an rpc_pipe_open method J. Bruce Fields
2008-06-13 22:50         ` [PATCH 5/5] rpc: add new gssd upcall pipe J. Bruce Fields
2008-06-14 16:07           ` Trond Myklebust
2008-06-14 17:36             ` J. Bruce Fields
2008-11-09 20:46             ` J. Bruce Fields
2008-06-14 16:01       ` [PATCH 3/5] rpc: move in_downcall list to gss code Trond Myklebust
2008-06-14 15:58     ` [PATCH 2/5] rpc: Use separate spinlock for cred locking in auth_gss.c Trond Myklebust
2008-06-14 17:45       ` J. Bruce Fields
2008-06-14 18:16         ` Trond Myklebust
2008-06-17 20:51           ` J. Bruce Fields
2008-06-17 21:34             ` Trond Myklebust
2008-06-17 22:06               ` J. Bruce Fields
2008-11-09 20:46               ` J. Bruce Fields
2008-11-09 21:04                 ` text-based gss upcall J. Bruce Fields
2008-11-09 21:04                   ` [PATCH 1/9] rpc: remove unnecessary assignment J. Bruce Fields
2008-11-09 21:04                     ` [PATCH 2/9] rpc: factor out warning code from gss_pipe_destroy_msg J. Bruce Fields
2008-11-09 21:04                       ` [PATCH 3/9] rpc: minor gss_alloc_msg cleanup J. Bruce Fields
2008-11-09 21:04                         ` [PATCH 4/9] rpc: add an rpc_pipe_open method J. Bruce Fields
2008-11-09 21:04                           ` [PATCH 5/9] rpc: call release_pipe only on last close J. Bruce Fields
2008-11-09 21:04                             ` [PATCH 6/9] rpc: track number of users of the gss upcall pipe J. Bruce Fields
2008-11-09 21:04                               ` [PATCH 7/9] rpc: use count of pipe openers to wait for first open J. Bruce Fields
2008-11-09 21:04                                 ` [PATCH 8/9] rpc: store pointer to pipe inode in gss upcall message J. Bruce Fields
2008-11-09 21:04                                   ` [PATCH 9/9] rpc: implement new upcall J. Bruce Fields
2008-11-10 19:11                             ` [PATCH 5/9] rpc: call release_pipe only on last close Trond Myklebust
     [not found]                               ` <1226344297.7599.41.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2008-11-10 19:49                                 ` J. Bruce Fields
2008-11-10 20:01                                   ` Trond Myklebust
     [not found]                                     ` <1226347279.7599.47.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2008-11-10 20:07                                       ` J. Bruce Fields
2008-11-10 20:11                                         ` Trond Myklebust
     [not found]                                           ` <1226347898.7599.49.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2008-11-10 20:17                                             ` J. Bruce Fields
2008-11-10 20:21                                               ` Trond Myklebust
     [not found]                                                 ` <1226348515.7599.52.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2008-11-10 20:26                                                   ` J. Bruce Fields
2008-11-10 20:37                                                     ` J. Bruce Fields
2008-11-10 21:18                                                     ` Trond Myklebust
     [not found]                                                       ` <1226351883.7599.103.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2008-11-10 21:27                                                         ` J. Bruce Fields
2008-11-10 20:35                           ` [PATCH 4/9] rpc: add an rpc_pipe_open method Trond Myklebust
     [not found]                             ` <1226349322.7599.59.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2008-11-10 20:37                               ` J. Bruce Fields [this message]
2008-11-10 21:18                                 ` J. Bruce Fields
2008-11-10 21:48                                   ` Trond Myklebust
     [not found]                                     ` <1226353722.7599.105.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2008-11-10 21:56                                       ` J. Bruce Fields
2008-06-16 14:28 ` [RFC] new client gssd upcall Jeff Layton
     [not found]   ` <20080616102859.66fa6a34-RtJpwOs3+0O+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2008-06-17 21:36     ` J. Bruce Fields
2008-06-17 21:59       ` Trond Myklebust
2008-06-17 22:09         ` J. Bruce Fields
2008-06-18 11:51           ` Jeff Layton
2008-06-19 15:37         ` Olga Kornievskaia
2008-06-19 15:49           ` Jeff Layton
     [not found]             ` <20080619114929.5c211ec9-RtJpwOs3+0O+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2008-06-19 17:06               ` Trond Myklebust
2008-06-19 17:27                 ` Jeff Layton
     [not found]                   ` <20080619132720.6bce2bb9-RtJpwOs3+0O+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2008-06-19 18:13                     ` Trond Myklebust
2008-06-19 19:11                       ` Jeff Layton

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=20081110203757.GI19053@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=Trond.Myklebust@netapp.com \
    --cc=aglo@citi.umich.edu \
    --cc=kwc@citi.umich.edu \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.