From: "J. Bruce Fields" <bfields@fieldses.org>
To: Kinglong Mee <kinglongmee@gmail.com>
Cc: "linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH 02/14] nfsd: Add missing gen_confirm in nfsd4_setclientid()
Date: Fri, 17 Jul 2015 11:58:46 -0400 [thread overview]
Message-ID: <20150717155846.GC6263@fieldses.org> (raw)
In-Reply-To: <55A72A1F.7060507@gmail.com>
On Thu, Jul 16, 2015 at 11:50:55AM +0800, Kinglong Mee wrote:
> On 7/16/2015 11:36, Kinglong Mee wrote:
> > On 7/16/2015 04:49, J. Bruce Fields wrote:
> >> On Wed, Jul 15, 2015 at 04:47:48PM -0400, J. Bruce Fields wrote:
> >>> On Mon, Jul 13, 2015 at 05:29:41PM +0800, Kinglong Mee wrote:
> >>>> Commit 294ac32e99 "nfsd: protect clid and verifier generation with client_lock"
> >>>> have moved gen_confirm() to gen_clid().
> >>>
> >>> This means the statement in that earlier commit is wrong:
> >>>
> >>>
> >>> With this, there's no need to keep two counters as they'd always
> >>> be in sync anyway, so just use the clientid_counter for both.
> >>>
> >>> Looks to me like this may need a separate counter to eliminate the
> >>> possibibility of returning the same confirm twice for a one clientid?
> >
> > Yes, nfsd will generate same confirm for one clientid in one second.
> >
> > verf[0] = (__force __be32)jiffies;
> > verf[1] = (__force __be32)nn->clientid_counter;
> >
> > for case 1: probable callback update, the new unconf client needs
> > a different confirm.
>
> Ignore this patch, and just revert commit 294ac32e99
> "nfsd: protect clid and verifier generation with client_lock"
> is a better solve.
We can't revert that completely, it does fix a real locking bug at
least, I think.
I'd agree to reinstating a separate counter for the verifier. That
verifier probably also needs to be per-network namespace to make the
per-network-namespace locking correct.
--b.
>
> thanks,
> Kinglong Mee
>
> >
> > Rereading rfc7530,
> > x be the value of the client.id subfield of the SETCLIENTID4args
> > structure.
> >
> > v be the value of the client.verifier subfield of the
> > SETCLIENTID4args structure.
> >
> > c be the value of the client ID field returned in the
> > SETCLIENTID4resok structure.
> >
> > k represent the value combination of the callback and callback_ident
> > fields of the SETCLIENTID4args structure.
> >
> > s be the setclientid_confirm value returned in the SETCLIENTID4resok
> > structure.
> >
> > { v, x, c, k, s } be a quintuple for a client record. A client
> > record is confirmed if there has been a SETCLIENTID_CONFIRM
> > operation to confirm it. Otherwise, it is unconfirmed. An
> > unconfirmed record is established by a SETCLIENTID call.
> >
> > ... /* case 1: probable callback update */ ...
> >
> > o The server checks if it has recorded a confirmed record for { v,
> > x, c, l, s }, where l may or may not equal k. If so, and since
> > the id verifier v of the request matches that which is confirmed
> > and recorded, the server treats this as a probable callback
> > information update and records an unconfirmed { v, x, c, k, t }
> > and leaves the confirmed { v, x, c, l, s } in place, such that
> > t != s. It does not matter whether k equals l or not. Any
> > pre-existing unconfirmed { v, x, c, *, * } is removed.
> >
> > The server returns { c, t }. It is indeed returning the old
> > clientid4 value c, because the client apparently only wants to
> > update callback value k to value l. It's possible this request is
> > one from the Byzantine router that has stale callback information,
> > but this is not a problem. The callback information update is
> > only confirmed if followed up by a SETCLIENTID_CONFIRM { c, t }.
> >
> > The server awaits confirmation of k via SETCLIENTID_CONFIRM
> > { c, t }.
> >
> > The server does NOT remove client (lock/share/delegation) state
> > for x.
> >
> >>
> >> (but frankly I can never completely review changes to the
> >> setclientid/setclientid_confirm behavior without rereading RFC 7530
> >> 16.33.5 every time, which is a slog. Might help to contrive a pynfs
> >> test derived from that text which tests for this particular behavior.)
> >>
> >
> > Make sense.
> > I will make it later.
> >
> > thanks,
> > Kinglong Mee
> >
> >
> >>>
> >>> --b.
> >>>
> >>>>
> >>>> After it, setclientid will return a bad reply with all zero confirms
> >>>> after copy_clid().
> >>>>
> >>>> Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
> >>>> ---
> >>>> fs/nfsd/nfs4state.c | 5 +++--
> >>>> 1 file changed, 3 insertions(+), 2 deletions(-)
> >>>>
> >>>> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> >>>> index e0a4556..b1f84fc 100644
> >>>> --- a/fs/nfsd/nfs4state.c
> >>>> +++ b/fs/nfsd/nfs4state.c
> >>>> @@ -3042,10 +3042,11 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
> >>>> unconf = find_unconfirmed_client_by_name(&clname, nn);
> >>>> if (unconf)
> >>>> unhash_client_locked(unconf);
> >>>> - if (conf && same_verf(&conf->cl_verifier, &clverifier))
> >>>> + if (conf && same_verf(&conf->cl_verifier, &clverifier)) {
> >>>> /* case 1: probable callback update */
> >>>> copy_clid(new, conf);
> >>>> - else /* case 4 (new client) or cases 2, 3 (client reboot): */
> >>>> + gen_confirm(new, nn);
> >>>> + } else /* case 4 (new client) or cases 2, 3 (client reboot): */
> >>>> gen_clid(new, nn);
> >>>> new->cl_minorversion = 0;
> >>>> gen_callback(new, setclid, rqstp);
> >>>> --
> >>>> 2.4.3
> >>
> >
next prev parent reply other threads:[~2015-07-17 15:58 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-13 9:28 [PATCH 00/14] nfsd: some updates and cleanups Kinglong Mee
2015-07-13 9:29 ` [PATCH 01/14] nfsd: Add layouts checking for state resources Kinglong Mee
2015-07-15 15:03 ` J. Bruce Fields
2015-07-16 2:30 ` Kinglong Mee
2015-07-16 2:33 ` [PATCH v2] nfsd: Add layouts checking in client_has_state() Kinglong Mee
2015-07-17 15:54 ` [PATCH 01/14] nfsd: Add layouts checking for state resources J. Bruce Fields
2015-07-13 9:29 ` [PATCH 02/14] nfsd: Add missing gen_confirm in nfsd4_setclientid() Kinglong Mee
2015-07-15 20:47 ` J. Bruce Fields
2015-07-15 20:49 ` J. Bruce Fields
2015-07-16 3:36 ` Kinglong Mee
2015-07-16 3:50 ` Kinglong Mee
2015-07-17 15:58 ` J. Bruce Fields [this message]
2015-07-17 17:42 ` Jeff Layton
2015-07-17 23:33 ` [PATCH] nfsd: New counter for generating client confirm verifier Kinglong Mee
2015-07-18 12:16 ` Jeff Layton
2015-07-20 20:44 ` J. Bruce Fields
2015-07-23 1:16 ` [PATCH 02/14] nfsd: Add missing gen_confirm in nfsd4_setclientid() Kinglong Mee
2015-07-23 15:53 ` J. Bruce Fields
2015-07-13 9:30 ` [PATCH 03/14] nfsd: Fix memory leak of so_owner.data in nfs4_stateowner Kinglong Mee
2015-07-15 20:57 ` J. Bruce Fields
2015-07-16 4:05 ` [PATCH v2] " Kinglong Mee
2015-07-17 15:59 ` J. Bruce Fields
2015-07-13 9:30 ` [PATCH 04/14] nfsd: Fix a memory leak of struct file_lock Kinglong Mee
2015-07-15 20:59 ` J. Bruce Fields
2015-07-13 9:31 ` [PATCH 05/14] nfsd: Use check_stateid_generation() for generation checking Kinglong Mee
2015-07-22 18:22 ` J. Bruce Fields
2015-07-23 1:09 ` Kinglong Mee
2015-07-13 9:31 ` [PATCH 06/14] nfsd: Drop duplicate locks_init_lock() Kinglong Mee
2015-07-22 18:24 ` J. Bruce Fields
2015-07-13 9:32 ` [PATCH 07/14] nfsd: Remove unneeded values in nfsd4_open() Kinglong Mee
2015-07-13 9:32 ` [PATCH 08/14] nfsd: Drop duplicate checking of seqid in nfsd4_create_session() Kinglong Mee
2015-07-13 9:32 ` [PATCH 09/14] nfsd: Remove nfs4_set_claim_prev() Kinglong Mee
2015-07-13 9:33 ` [PATCH 10/14] nfsd: Remove unused values in nfs4_setlease() Kinglong Mee
2015-07-13 9:33 ` [PATCH 11/14] nfsd: Remove duplicate checking of nfsd_net in nfs4_laundromat() Kinglong Mee
2015-07-13 9:34 ` [PATCH 12/14] nfsd: Remove macro LOFF_OVERFLOW Kinglong Mee
2015-07-13 9:35 ` [PATCH 13/14] nfsd: Use lk_new_xxx instead of v.new.xxx for nfs4_lockowner Kinglong Mee
2015-07-13 9:35 ` [PATCH 14/14] nfsd: Remove unused clientid arguments from, find_lockowner_str{_locked} Kinglong Mee
2015-07-22 19:22 ` 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=20150717155846.GC6263@fieldses.org \
--to=bfields@fieldses.org \
--cc=kinglongmee@gmail.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