From: Christoph Hellwig <hch@infradead.org>
To: Dave Chinner <david@fromorbit.com>
Cc: "Darrick J. Wong" <djwong@kernel.org>,
linux-xfs@vger.kernel.org, Christoph Hellwig <hch@infradead.org>
Subject: Re: [PATCH] xfs: _{attr,data}_map_shared should take ILOCK_EXCL until iread_extents is completely done
Date: Mon, 10 Apr 2023 22:11:41 -0700 [thread overview]
Message-ID: <ZDTsDUVX7c/7ReiL@infradead.org> (raw)
In-Reply-To: <20230411032035.GZ3223426@dread.disaster.area>
On Tue, Apr 11, 2023 at 01:20:35PM +1000, Dave Chinner wrote:
> > ASSERT(ir.loaded == xfs_iext_count(ifp));
> > + smp_mb();
> > + ifp->if_needextents = 0;
>
> Hmmm - if this is to ensure that everything above is completed
> before the clearing of this flag is visible everywhere else, then we
> should be able to use load_acquire/store_release semantics? i.e. the
> above is
>
> smp_store_release(ifp->if_needextents, 0);
>
> and we use
>
> smp_load_acquire(ifp->if_needextents)
Yeah, that's probably better than my READ_ONCE/WRITE_ONCE suggestions
as it also orders vs the previous assignments.
> > ifp = xfs_ifork_ptr(ip, whichfork);
> > + ifp->if_needextents = 1;
>
> Hmmm - what's the guarantee that the reader will see ifp->if_format
> set correctly if they if_needextents = 1?
>
> Wouldn't it be better to set this at the same time we set the
> ifp->if_format value? We clear it unconditionally above in
> xfs_iread_extents(), so why not set it unconditionally there, too,
> before we start. i.e.
>
> /*
> * Set the format before we set needsextents with release
> * semantics. This ensures that we can use acquire semantics
> * on needextents in xfs_need_iread_extents() and be
> * guaranteed to see a valid format value after that load.
> */
> ifp->if_format = dip->di_format;
> smp_store_release(ifp->if_needextents, 1);
>
> That then means xfs_need_iread_extents() is guaranteed to see a
> valid ifp->if_format if ifp->if_needextents is set if we do:
I'd just drop the if_format check in xfs_need_iread_extents,
which together with the memory barriers should fix all this.
next prev parent reply other threads:[~2023-04-11 5:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-11 1:06 [PATCH] xfs: _{attr,data}_map_shared should take ILOCK_EXCL until iread_extents is completely done Darrick J. Wong
2023-04-11 3:20 ` Dave Chinner
2023-04-11 4:18 ` Darrick J. Wong
2023-04-11 21:58 ` Dave Chinner
2023-04-11 5:11 ` Christoph Hellwig [this message]
2023-04-11 5:06 ` Christoph Hellwig
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=ZDTsDUVX7c/7ReiL@infradead.org \
--to=hch@infradead.org \
--cc=david@fromorbit.com \
--cc=djwong@kernel.org \
--cc=linux-xfs@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