linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATH v6 2/9] nfsd41: handle current stateid in open and close
Date: Tue, 17 Jan 2012 15:45:10 -0500	[thread overview]
Message-ID: <20120117204510.GD16118@fieldses.org> (raw)
In-Reply-To: <CAGue13oDaGn3DbyVDmAZhxqZ1+bwd53X0o-a+Hix-nHgwZ4wBw@mail.gmail.com>

On Tue, Jan 17, 2012 at 09:14:47PM +0100, Tigran Mkrtchyan wrote:
> On Tue, Jan 17, 2012 at 8:40 PM, J. Bruce Fields <bfields@fieldses.org> wrote:
> > On Sun, Jan 15, 2012 at 05:20:03PM +0100, Tigran Mkrtchyan wrote:
> >> +static void
> >> +put_stateid(struct nfsd4_compound_state *cstate, stateid_t *stateid)
> >> +{
> >> +     if (cstate->minorversion)
> >> +             cstate->current_stateid = stateid;
> >> +}
> > ...
> >> @@ -54,6 +54,7 @@ struct nfsd4_compound_state {
> >>       size_t                  iovlen;
> >>       u32                     minorversion;
> >>       u32                     status;
> >> +     const stateid_t *current_stateid;
> >>  };
> >
> > I'd be more comfortable with passing stateid's by value rather than by
> > reference.
> >
> > Presumably you're only ever pointing into one of the argument or result
> > structures which are currently guaranteed to be around for as long as
> > the compound is processed.
> >
> > But it'd seem safer not to have to worry about the lifetime of the
> > pointed-to data at all, and just copy the stateid--it's only 16 bytes.
> 
> Sure, it's only 16 bytes. Nevertheless, there are no allocation or
> de-allocation of it. It just pointing to an existing stateid.

Well, it's conceivable some day that we could for example take more of a
one-op-at-a-time approach to compound processing and free the arguments
and results from the previous op once we're done processing and xdr
encoding it, in which case continuing to refer to a stateid from the
previous op would be unsafe.

Or maybe some day there will be an operation that sets the current
stateid without also returning it in an argument, in which case we could
be tempted to take a pointer to a field in an object without being
assured how long that object will be around.

Likely?  Maybe not.  I'd still feel safer not having to think about it.

> Should be safe to use pointer. And yes, it's just 16 bytes, but if we can
> avoid to
> copy them why not?
> 
> Of course I can change it if you want to.

I'd prefer that.

--b.

  reply	other threads:[~2012-01-17 20:45 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-15 16:20 [PATH v6 0/9] handle curruent stateid Tigran Mkrtchyan
2012-01-15 16:20 ` [PATH v6 1/9] nfsd4: initialize current stateid at compile time Tigran Mkrtchyan
2012-01-15 16:20 ` [PATH v6 2/9] nfsd41: handle current stateid in open and close Tigran Mkrtchyan
2012-01-17 19:40   ` J. Bruce Fields
2012-01-17 19:43     ` J. Bruce Fields
2012-01-17 20:14     ` Tigran Mkrtchyan
2012-01-17 20:45       ` J. Bruce Fields [this message]
2012-01-17 21:17         ` Tiramisu Mokka
2012-01-15 16:20 ` [PATH v6 3/9] nfsd41: handle current stateid on lock and locku Tigran Mkrtchyan
2012-01-15 16:20 ` [PATH v6 4/9] nfsd41: consume current stateid on read and write Tigran Mkrtchyan
2012-01-15 16:20 ` [PATH v6 5/9] nfsd41: mark PUTFH, PUTPUBFH and PUTROOTFH to clear current stateid Tigran Mkrtchyan
2012-01-15 16:20 ` [PATH v6 6/9] nfsd41: save and restore current stateid with current fh Tigran Mkrtchyan
2012-01-15 16:20 ` [PATH v6 7/9] nfsd41: mark LOOKUP, LOOKUPP and CREATE to invalidate current stateid Tigran Mkrtchyan
2012-01-15 16:20 ` [PATH v6 8/9] nfsd41: handle current stateid in SETATTR and FREE_STATEID Tigran Mkrtchyan
2012-01-15 16:20 ` [PATH v6 9/9] nfsd41: consume current stateid on DELEGRETURN and OPENDOWNGRADE Tigran Mkrtchyan

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=20120117204510.GD16118@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=tigran.mkrtchyan@desy.de \
    /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;
as well as URLs for NNTP newsgroup(s).