From: Mike Snitzer <snitzer@kernel.org>
To: Anna Schumaker <anna@kernel.org>
Cc: Trond Myklebust <trondmy@kernel.org>,
linux-nfs@vger.kernel.org,
Jonathan Flynn <jonathan.flynn@hammerspace.com>
Subject: Re: [PATCH 04/11] NFSv4/flexfiles: make dss_info->start_time write-once
Date: Thu, 5 Nov 2026 16:27:38 -0500 [thread overview]
Message-ID: <auz0yhZstrpx2O4l@kernel.org> (raw)
In-Reply-To: <2e7ab5bd-11dc-4b02-827f-7a4983f755c0@app.fastmail.com>
On Thu, Nov 05, 2026 at 11:14:10AM -0500, Anna Schumaker wrote:
> Hi MIke,
>
> On Mon, Nov 2, 2026, at 2:11 PM, Mike Snitzer wrote:
> > From: Mike Snitzer <snitzer@hammerspace.com>
> >
> > start_time was written under the stripe lock in
> > nfs4_ff_layoutstat_start_io() and read outside it in
> > ff_layout_encode_ff_layoutupdate(). Pre-existing -- mirror->lock had the
> > same shape -- and benign, since it is a single naturally aligned 8 byte
> > value, but it is an unannotated race either way.
>
> We can probably drop this last sentence.
>
> >
> > The lock is the wrong tool for it. ffl_duration is measured from this
> > stripe's first I/O, so the field is written once and read-only for the
> > rest of the stripe's life. Say that instead: publish it with
>
> This portion needs editing too. My brain tripped over "Say that instead"
> while reading.
>
> > try_cmpxchg64() and let the first I/O win, and read it with READ_ONCE().
> > Only the first I/O to a stripe pays the read-modify-write; every one
> > after it short circuits on the READ_ONCE().
>
> This sentence is just rewording the previous sentence.
Sorry, I will review all commit headers and code comments.
> >
> > ffl->last_report_time two lines away is already published this way, so
> > the pattern is not new to this file.
> >
> > This also stops start_time depending on there being exactly one lock per
> > stripe, which a later patch changes.
> >
> > Signed-off-by: Mike Snitzer <snitzer@hammerspace.com>
> > ---
> > fs/nfs/flexfilelayout/flexfilelayout.c | 21 ++++++++++++++++++---
> > fs/nfs/flexfilelayout/flexfilelayout.h | 3 ++-
> > 2 files changed, 20 insertions(+), 4 deletions(-)
> >
> > diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c
> > b/fs/nfs/flexfilelayout/flexfilelayout.c
> > index 7fc1369df8439..7c328f2ec900d 100644
> > --- a/fs/nfs/flexfilelayout/flexfilelayout.c
> > +++ b/fs/nfs/flexfilelayout/flexfilelayout.c
> > @@ -729,6 +729,22 @@ nfs4_ff_end_busy_timer(struct nfs4_ff_busy_timer
> > *timer, ktime_t now)
> > return ktime_sub(now, start);
> > }
> >
> > +/*
> > + * ffl_duration is measured from this stripe's first I/O, so
> > start_time is
> > + * written once and read-only for the rest of the stripe's life.
> > Publish it
> > + * with a cmpxchg and let the first I/O win, rather than depending on
> > a lock
> > + * that every reader would then have to take.
> > + */
> > +static void
> > +nfs4_ff_layoutstat_set_start_time(struct nfs4_ff_layout_ds_stripe
> > *dss_info,
> > + ktime_t now)
> > +{
> > + ktime_t unset = 0;
> > +
> > + if (!READ_ONCE(dss_info->start_time))
> > + try_cmpxchg64(&dss_info->start_time, &unset, now);
>
> I have the same atomic64_try_cmpxchg() question as in patch 1 here.
Right, I noted that in my reply to patch 1. I don't think its
something to be overly concerned about. Given the use of ktime_t
(s64) it really is the more appropriate interface AFAICT.
Happy to take instruction from others on this though!
Thanks,
Mike
next prev parent reply other threads:[~2026-11-05 21:27 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 19:10 [PATCH 00/11] NFSv4/flexfiles: scale layoutstats for striped layouts Mike Snitzer
2026-11-02 19:10 ` [PATCH 01/11] NFSv4/flexfiles: move layoutstats accounting to a per-stripe lock Mike Snitzer
2026-11-05 16:12 ` Anna Schumaker
2026-11-05 21:19 ` Mike Snitzer
2026-11-02 19:11 ` [PATCH 02/11] NFSv4/flexfiles: drop the now-unused per-mirror lock Mike Snitzer
2026-11-02 19:11 ` [PATCH 03/11] NFSv4/flexfiles: cacheline align the per-stripe layoutstats Mike Snitzer
2026-11-05 15:34 ` Anna Schumaker
2026-11-05 21:23 ` Mike Snitzer
2026-11-02 19:11 ` [PATCH 04/11] NFSv4/flexfiles: make dss_info->start_time write-once Mike Snitzer
2026-11-05 16:14 ` Anna Schumaker
2026-11-05 21:27 ` Mike Snitzer [this message]
2026-11-02 19:11 ` [PATCH 05/11] NFSv4/flexfiles: drop the redundant atomic from the busy timer Mike Snitzer
2026-11-05 16:46 ` Anna Schumaker
2026-11-02 19:11 ` [PATCH 06/11] NFSv4/flexfiles: pair the in-flight count with the layoutstats updates Mike Snitzer
2026-11-05 17:44 ` Anna Schumaker
2026-11-02 19:11 ` [PATCH 07/11] NFSv4/flexfiles: derive ffil_ops_requested rather than storing it Mike Snitzer
2026-11-05 18:01 ` Anna Schumaker
2026-11-02 19:11 ` [PATCH 08/11] NFSv4/flexfiles: give each direction its own lock and cacheline Mike Snitzer
2026-11-05 19:58 ` Anna Schumaker
2026-11-02 19:11 ` [PATCH 09/11] NFSv4/flexfiles: drop NFS4_FF_MIRROR_STAT_AVAIL Mike Snitzer
2026-11-05 20:17 ` Anna Schumaker
2026-11-02 19:11 ` [PATCH 10/11] NFSv4/flexfiles: rotate LAYOUTSTATS reporting across a mirror's stripes Mike Snitzer
2026-11-05 21:41 ` Anna Schumaker
2026-11-02 19:11 ` [PATCH 11/11] NFSv4/flexfiles: take the report decision out of the critical section Mike Snitzer
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=auz0yhZstrpx2O4l@kernel.org \
--to=snitzer@kernel.org \
--cc=anna@kernel.org \
--cc=jonathan.flynn@hammerspace.com \
--cc=linux-nfs@vger.kernel.org \
--cc=trondmy@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