From: "P.B.Shelley" <shelleypt@gmail.com>
To: Benny Halevy <bhalevy@panasas.com>
Cc: Fred Isaman <iisaman@netapp.com>, linux-nfs@vger.kernel.org
Subject: Re: [PATCH 2/4] pnfs_submit: Only update stateid if it is more recent than current
Date: Fri, 8 Oct 2010 22:13:33 +0800 [thread overview]
Message-ID: <AANLkTimUeQGrFXzZfgkkiE834MvMYz3uxobHHAdzE79p@mail.gmail.com> (raw)
In-Reply-To: <4CADD3E9.7040307@panasas.com>
On Thu, Oct 7, 2010 at 10:06 PM, Benny Halevy <bhalevy@panasas.com> wrote:
> On 2010-10-07 10:01, Fred Isaman wrote:
>> On Thu, Oct 7, 2010 at 9:34 AM, Benny Halevy <bhalevy@panasas.com> wrote:
>>> On 2010-10-06 16:35, Fred Isaman wrote:
>>>> Right now, when we set the stateid, we blindly overwrite the current
>>>> one, allowing the seqid to incorrectly roll backward.
>>>>
>>>> Signed-off-by: Fred Isaman <iisaman@netapp.com>
>>>> ---
>>>> fs/nfs/pnfs.c | 38 ++++++++++++++++++++++++++++++++------
>>>> 1 files changed, 32 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
>>>> index 39bce9b..555955b 100644
>>>> --- a/fs/nfs/pnfs.c
>>>> +++ b/fs/nfs/pnfs.c
>>>> @@ -459,16 +459,42 @@ pnfs_destroy_all_layouts(struct nfs_client *clp)
>>>> }
>>>> }
>>>>
>>>> +/* update lo->stateid with new if is more recent
>>>> + *
>>>> + * lo->stateid could be the open stateid, in which case we just use what given.
>>>> + */
>>>> static void
>>>> pnfs_set_layout_stateid(struct pnfs_layout_hdr *lo,
>>>> - const nfs4_stateid *stateid)
>>>> + const nfs4_stateid *new)
>>>> {
>>>> - /* TODO - should enforce that embedded seqid, in the case
>>>> - * that the two stateid.others are equal, only increases.
>>>> - * Complicated by wrap-around.
>>>> - */
>>>> + nfs4_stateid *old = &lo->stateid;
>>>> + bool overwrite = false;
>>>> +
>>>> write_seqlock(&lo->seqlock);
>>>> - memcpy(lo->stateid.data, stateid->data, sizeof(lo->stateid.data));
>>>> + if (!test_bit(NFS_LAYOUT_STATEID_SET, &lo->state) ||
>>>> + memcmp(old->stateid.other, new->stateid.other, sizeof(new->stateid.other)))
>>>> + overwrite = true;
>>>> + else {
>>>> + u32 oldseq, newseq, limit;
>>>> +
>>>> + oldseq = be32_to_cpu(old->stateid.seqid);
>>>> + newseq = be32_to_cpu(new->stateid.seqid);
>>>> + /* There are no good bounds on window size, so just
>>>> + * use a ridiculously large window of 2^31.
>>>> + */
>>>> + limit = oldseq + (1 << 31);
>>>> + if (oldseq < limit) {
>>>> + /* The easy, non-wraparound case */
>>>> + if (oldseq < newseq && newseq < limit)
>>>> + overwrite = true;
>>>> + } else {
>>>> + /* Near wraparound edge */
>>>> + if (oldseq < newseq || newseq < limit)
>>>> + overwrite = true;
>>>> + }
>>>
>>> Wouldn't it be simpler to just look at (int32_t)(newseq - oldseq)?
>>>
>>
>> Why yes it would. I'll send a new version of this patch shortly.
>>
>
> No need :)
> I'll just change this as follows:
>
> + else {
> + u32 oldseq, newseq, limit;
> +
> + oldseq = be32_to_cpu(old->stateid.seqid);
> + newseq = be32_to_cpu(new->stateid.seqid);
> + if ((int)(newseq - oldseq) > 0)
> + overwrite = true;
Do we also need to verify the other field of the stateid? Will there
be situations that server change the other field and reset the seqid?
Thanks,
Shelley
next prev parent reply other threads:[~2010-10-08 14:13 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-06 20:35 [PATCH 0/4] pnfs-submit: misc fixes in CB_LAYOUTRECALL and layout stateid code Fred Isaman
2010-10-06 20:35 ` [PATCH 1/4] pnfs_submit: Remove nonsensical check Fred Isaman
2010-10-06 20:35 ` [PATCH 2/4] pnfs_submit: Only update stateid if it is more recent than current Fred Isaman
2010-10-07 13:34 ` Benny Halevy
2010-10-07 14:01 ` Fred Isaman
2010-10-07 14:06 ` Benny Halevy
2010-10-08 14:13 ` P.B.Shelley [this message]
2010-10-08 14:16 ` Benny Halevy
2010-10-08 14:35 ` Fred Isaman
2010-10-08 15:36 ` P.B.Shelley
2010-10-08 15:52 ` Fred Isaman
2010-10-06 20:35 ` [PATCH 3/4] pnfs_submit: simplify nfs4_callback_layoutrecall Fred Isaman
2010-10-06 20:35 ` [PATCH 4/4] pnfs_submit: Fix clp refcounting in layout recalls Fred Isaman
2010-10-07 15:32 ` [PATCH 0/4] pnfs-submit: misc fixes in CB_LAYOUTRECALL and layout stateid code Benny Halevy
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=AANLkTimUeQGrFXzZfgkkiE834MvMYz3uxobHHAdzE79p@mail.gmail.com \
--to=shelleypt@gmail.com \
--cc=bhalevy@panasas.com \
--cc=iisaman@netapp.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;
as well as URLs for NNTP newsgroup(s).