From: "J. Bruce Fields" <bfields@redhat.com>
To: NeilBrown <neilb@suse.com>
Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Trond Myklebust <trond.myklebust@primarydata.com>
Subject: Re: [PATCH 3/3] nfsd: clients don't need to break their own delegations
Date: Tue, 29 Aug 2017 17:49:07 -0400 [thread overview]
Message-ID: <20170829214907.GJ8822@parsley.fieldses.org> (raw)
In-Reply-To: <87bmn0ia6i.fsf@notabene.neil.brown.name>
Now we get to harder questions....
On Mon, Aug 28, 2017 at 02:32:53PM +1000, NeilBrown wrote:
> On Fri, Aug 25 2017, J. Bruce Fields wrote:
>
> > From: "J. Bruce Fields" <bfields@redhat.com>
> >
> > We currently revoke read delegations on any write open or any operation
> > that modifies file data or metadata (including rename, link, and
> > unlink). But if the delegation in question is the only read delegation
> > and is held by the client performing the operation, that's not really
> > necessary.
> >
> > It's not always possible to prevent this in the NFSv4.0 case, because
> > there's not always a way to determine which client an NFSv4.0 delegation
> > came from. (In theory we could try to guess this from the transport
> > layer, e.g., by assuming all traffic on a given TCP connection comes
> > from the same client. But that's not really correct.)
> >
> > In the NFSv4.1 case the session layer always tells us the client.
> >
> > This patch should remove such self-conflicts in all cases where we can
> > reliably determine the client from the compound.
>
> I don't see any mention of the new DELEG_NO_WAIT, either here or where
> the value is defined. That means I have to figure it out for myself?
That's a fair complaint.
> When I saw this, I thought: "Shouldn't 'who' be 'fl_owner_t' rather that
> 'void*'".
> Then I saw
>
> /* legacy typedef, should eventually be removed */
> typedef void *fl_owner_t;
>
>
> Maybe you could do the world a favor and remove fl_owner_t in a
> preliminary patch :-)
I remember trying that before and getting frustrated for some reason.
OK, I'll take another look.
> And it is kind-a weird that the "who" you pass to break_lease() is
> different from the owner passed to vfs_setlease().
>
> >
> > /* typically we will check that ctx is non-NULL before calling */
> > ctx = smp_load_acquire(&inode->i_flctx);
> > diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> > index 0c04f81aa63b..fb15efcc4e08 100644
> > --- a/fs/nfsd/nfs4state.c
> > +++ b/fs/nfsd/nfs4state.c
> > @@ -3825,6 +3825,45 @@ nfsd_break_deleg_cb(struct file_lock *fl)
> > return ret;
> > }
> >
> > +static struct nfs4_client *nfsd4_client_from_rqst(struct svc_rqst *rqst)
> > +{
> > + struct nfsd4_compoundres *resp;
> > +
> > + /*
> > + * In case it's possible we could be called from NLM or ACL
> > + * code?:
> > + */
> > + if (rqst->rq_prog != NFS_PROGRAM)
> > + return NULL;
> > + if (rqst->rq_vers != 4)
> > + return NULL;
> > + resp = rqst->rq_resp;
> > + return resp->cstate.clp;
> > +}
> > +
> > +static bool nfsd_breaker_owns_lease(void *who, struct file_lock *fl)
> > +{
> > + struct svc_rqst *rqst = who;
> > + struct nfs4_client *cl;
> > + struct nfs4_delegation *dl;
> > + struct nfs4_file *fi = (struct nfs4_file *)fl->fl_owner;
> > + bool ret = true;
> > +
> > + cl = nfsd4_client_from_rqst(rqst);
> > + if (!cl)
> > + return false;
> > +
> > + spin_lock(&fi->fi_lock);
> > + list_for_each_entry(dl, &fi->fi_delegations, dl_perfile) {
> > + if (dl->dl_stid.sc_client != cl) {
> > + ret = false;
> > + break;
> > + }
> > + }
> > + spin_unlock(&fi->fi_lock);
> > + return ret;
> > +}
>
> You haven't provided any documentation telling me what the
> "lm_breaker_owns_lease" callback is meant to do.
> So I look at this one piece of sample code -- it seems to compute:
> not (an other client owns lease)
> rather than
> (this client owns lease)
> which is what I would have expected.
>
> Given that any_leases_conflict() already loops over all leases, does
> nfsd_breaker_owns_lease() need to loop as well?
> Or does nfsd only take a single lease to cover all the delegations to
> all the clients?
> ... hmmm, yes that does seem to be how nfsd works.
>
> Would this all turn out to be easier if nfsd took a separate lease for
> each client? What would be the cost of that?
I'll have to remind myself.
I think it might have been forced by the decision to consolidate NFSv4
opens in a similar way.
Both decisions I regret since they've been a source of overly
complicated code that's had lots of bugs. But I may just be forgetting
the drawbacks of the alternative.
Anyway, I'll review that code. But I think the answer will be that we
need to live with it for now.
But, yes, this needs some comments and better variable names at a
minimum.
--b.
next prev parent reply other threads:[~2017-08-29 21:49 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-25 21:52 [PATCH 0/3] Eliminate delegation self-conflicts J. Bruce Fields
2017-08-25 21:52 ` [PATCH 1/3] fs: cleanup to hide some details of delegation logic J. Bruce Fields
2017-08-28 3:54 ` NeilBrown
2017-08-29 21:37 ` J. Bruce Fields
2017-08-30 19:50 ` Jeff Layton
2017-08-31 21:10 ` J. Bruce Fields
2017-08-31 23:13 ` Jeff Layton
2017-08-25 21:52 ` [PATCH 2/3] fs: hide another detail " J. Bruce Fields
2017-08-28 4:43 ` NeilBrown
2017-08-29 21:40 ` J. Bruce Fields
2017-08-30 0:43 ` NeilBrown
2017-08-30 17:09 ` J. Bruce Fields
2017-08-30 23:26 ` NeilBrown
2017-08-31 19:05 ` J. Bruce Fields
2017-08-31 23:27 ` NeilBrown
2017-09-01 16:18 ` J. Bruce Fields
2017-09-04 4:52 ` NeilBrown
2017-09-05 19:56 ` J. Bruce Fields
2017-09-05 21:35 ` NeilBrown
2017-09-06 16:03 ` J. Bruce Fields
2017-09-07 0:43 ` NeilBrown
2017-09-08 15:06 ` J. Bruce Fields
2018-03-16 14:42 ` J. Bruce Fields
2017-08-25 21:52 ` [PATCH 3/3] nfsd: clients don't need to break their own delegations J. Bruce Fields
2017-08-28 4:32 ` NeilBrown
2017-08-29 21:49 ` J. Bruce Fields [this message]
2018-03-16 14:43 ` J. Bruce Fields
2017-09-07 22:01 ` J. Bruce Fields
2017-09-08 5:06 ` NeilBrown
2017-09-08 15:05 ` J. Bruce Fields
2017-08-26 18:06 ` [PATCH 0/3] Eliminate delegation self-conflicts Chuck Lever
2017-08-29 21:52 ` J. Bruce Fields
2017-08-29 23:39 ` Chuck Lever
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=20170829214907.GJ8822@parsley.fieldses.org \
--to=bfields@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neilb@suse.com \
--cc=trond.myklebust@primarydata.com \
/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).