From: Dave Chinner <david@fromorbit.com>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: Andreas Dilger <adilger@dilger.ca>, NeilBrown <neilb@suse.de>,
Al Viro <viro@zeniv.linux.org.uk>,
Linux NFS Mailing List <linux-nfs@vger.kernel.org>,
linux-fsdevel@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>, Daire Byrne <daire@dneg.com>,
Andreas Dilger <adilger.kernel@dilger.ca>
Subject: Re: [PATCH/RFC] VFS: support parallel updates in the one directory.
Date: Sat, 26 Feb 2022 10:16:18 +1100 [thread overview]
Message-ID: <20220225231618.GQ3061737@dread.disaster.area> (raw)
In-Reply-To: <20220224233848.GC8269@magnolia>
On Thu, Feb 24, 2022 at 03:38:48PM -0800, Darrick J. Wong wrote:
> On Thu, Feb 24, 2022 at 09:31:28AM -0700, Andreas Dilger wrote:
> > On Feb 23, 2022, at 22:57, NeilBrown <neilb@suse.de> wrote:
> > >
> > >
> > > I added this:
> > > --- a/fs/xfs/xfs_icache.c
> > > +++ b/fs/xfs/xfs_icache.c
> > > @@ -87,6 +87,7 @@ xfs_inode_alloc(
> > > /* VFS doesn't initialise i_mode or i_state! */
> > > VFS_I(ip)->i_mode = 0;
> > > VFS_I(ip)->i_state = 0;
> > > + VFS_I(ip)->i_flags |= S_PAR_UPDATE;
> > > mapping_set_large_folios(VFS_I(ip)->i_mapping);
> > >
> > > XFS_STATS_INC(mp, vn_active);
> > >
> > > and ran my highly sophisticated test in an XFS directory:
> > >
> > > for i in {1..70}; do ( for j in {1000..8000}; do touch $j; rm -f $j ; done ) & done
>
> I think you want something faster here, like ln to hardlink an existing
> file into the directory.
>
> > > This doesn't crash - which is a good sign.
> > > While that was going I tried
> > > while : ; do ls -l ; done
> > >
> > > it sometimes reports garbage for the stat info:
> > >
> > > total 0
> > > -????????? ? ? ? ? ? 1749
> > > -????????? ? ? ? ? ? 1764
> > > -????????? ? ? ? ? ? 1765
> > > -rw-r--r-- 1 root root 0 Feb 24 16:47 1768
> > > -rw-r--r-- 1 root root 0 Feb 24 16:47 1770
> > > -rw-r--r-- 1 root root 0 Feb 24 16:47 1772
> > > ....
> > >
> > > I *think* that is bad - probably the "garbage" that you referred to?
> > >
> > > Obviously I gets lots of
> > > ls: cannot access '1764': No such file or directory
> > > ls: cannot access '1749': No such file or directory
> > > ls: cannot access '1780': No such file or directory
> > > ls: cannot access '1765': No such file or directory
> > >
> > > but that is normal and expected when you are creating and deleting
> > > files during the ls.
> >
> > The "ls -l" output with "???" is exactly the case where the filename is
> > in readdir() but stat() on a file fails due to an unavoidable userspace
> > race between the two syscalls and the concurrent unlink(). This is
> > probably visible even without the concurrent dirops patch.
> >
> > The list of affected filenames even correlates with the reported errors:
> > 1764, 1765, 1769
> >
> > It looks like everything is working as expected.
>
> Here, yes.
>
> A problem that I saw a week or two ago with online fsck is that an evil
> thread repeatedly link()ing and unlink()ing a file into an otherwise
> empty directory while racing a thread calling readdir() in a loop will
> eventually trigger a corruption report on the directory namecheck
> because the loop in xfs_dir2_sf_getdents that uses sfp->count as a loop
> counter will race with the unlink decrementing sfp->count and run off
> the end of the inline directory data buffer.
Ah, shortform dirs might need the readdir moved inside the
lock_mode = xfs_ilock_data_map_shared(dp);
section so that the ILOCK is held while readdir is pulling the
dirents out of the inode - there's no buffer lock to serialise that
against concurrent modifications like there are for block/leaf/node
formats.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2022-02-25 23:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-22 2:24 [PATCH/RFC] VFS: support parallel updates in the one directory NeilBrown
2022-02-22 19:07 ` J. Bruce Fields
2022-02-22 21:11 ` J. Bruce Fields
2022-02-24 5:08 ` NeilBrown
2022-02-24 21:23 ` J. Bruce Fields
2022-02-22 22:45 ` Dave Chinner
2022-02-24 4:43 ` Darrick J. Wong
2022-02-24 5:56 ` NeilBrown
2022-02-24 16:31 ` Andreas Dilger
2022-02-24 23:38 ` Darrick J. Wong
2022-02-25 23:16 ` Dave Chinner [this message]
2022-02-28 0:55 ` NeilBrown
2022-03-10 11:10 ` Daire Byrne
2022-02-25 23:07 ` Dave Chinner
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=20220225231618.GQ3061737@dread.disaster.area \
--to=david@fromorbit.com \
--cc=adilger.kernel@dilger.ca \
--cc=adilger@dilger.ca \
--cc=daire@dneg.com \
--cc=djwong@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neilb@suse.de \
--cc=viro@zeniv.linux.org.uk \
/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