FS/XFS testing framework
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Anand Jain <anand.jain@oracle.com>
Cc: David Sterba <dsterba@suse.com>,
	fstests@vger.kernel.org, josef@toxicpanda.com
Subject: Re: [PATCH 1/6] common: udev settle before _scratch_pool_mkfs
Date: Mon, 20 May 2024 21:21:10 +0200	[thread overview]
Message-ID: <20240520192110.GH17126@twin.jikos.cz> (raw)
In-Reply-To: <30c274a6-adc1-42a7-91cf-8a386884106f@oracle.com>

On Sat, May 18, 2024 at 05:57:12AM +0800, Anand Jain wrote:
> On 5/17/24 06:12, David Sterba wrote:
> > From: Josef Bacik <josef@toxicpanda.com>
> > 
> > There are some btrfs tests that do _scratch_pool_mkfs in a loop.
> > Sometimes this fails with EBUSY.  Tracing revealed that udevd will
> > sometimes write to /sys/block/device/uevent to make sure an event
> > triggers to rules get written.  However these events will not get sent
> > to user space until after an O_EXCL open as been closed.  The general
> > flow is something like
> > 
> > mkfs.btrfs /dev/sda /dev/sdb /dev/sdc /dev/sdd
> > mount /dev/sda /mnt/test
> > <things>
> > umount /mnt/test
> > 
> > in a loop.  The problem is udevd will add uevents for the devices and
> > they won't get delivered until after the umount.  If we're doing the
> > above sequence in a loop the next mkfs.btrfs will fail because udev is
> > touching the devices to consume the KOBJ_CHANGE event.
> > 
> > Fix this by doing a udev settle before _scratch_pool_mkfs.
> > 
> 
> 
> 
> > Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> > Signed-off-by: David Sterba <dsterba@suse.com>
> > ---
> >   common/rc | 6 ++++++
> >   1 file changed, 6 insertions(+)
> > 
> > diff --git a/common/rc b/common/rc
> > index 0fe56382a6a497..5d38571ffe87eb 100644
> > --- a/common/rc
> > +++ b/common/rc
> > @@ -903,6 +903,12 @@ _scratch_pool_mkfs()
> >   {
> >       case $FSTYP in
> >       btrfs)
> > +	# For multi-disk file systems udev can queue up events on the device
> > +	# when we mkfs the device, and thus tie up the device after we've
> > +	# unmounted.  Tests that _scratch_pool_mkfs() in a loop can sometimes
> > +	# trip over udev trying to do the updates after the umount, so make sure
> > +	# we settle before we try mkfs'ing so we don't get an EBUSY
> > +	$UDEV_SETTLE_PROG >/dev/null 2>&1
> >           $MKFS_BTRFS_PROG $MKFS_OPTIONS $* $SCRATCH_DEV_POOL > /dev/null
> >           ;;
> 
> 
> Just curious: have we seen this issue even after the btrfs-progs commit 
> below?
> 
>    e54514aaeab6 btrfs-progs: fix stray fd close in open_ctree_fs_info()

That's a good question, I don't know but I can revert the change and see
if things break. This may take time as triggering the udev/mkfs race is
not reliable.

  reply	other threads:[~2024-05-20 19:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-16 22:12 [PATCH 0/6] Btrfs test updates and fixups David Sterba
2024-05-16 22:12 ` [PATCH 1/6] common: udev settle before _scratch_pool_mkfs David Sterba
2024-05-17 21:57   ` Anand Jain
2024-05-20 19:21     ` David Sterba [this message]
2024-05-20 23:48       ` Anand Jain
2024-05-16 22:12 ` [PATCH 2/6] generic/352: require no compression David Sterba
2024-05-21  0:04   ` Anand Jain
2024-05-16 22:12 ` [PATCH 3/6] generic/027: " David Sterba
2024-05-21  0:09   ` Anand Jain
2024-05-16 22:12 ` [PATCH 4/6] generic/269: " David Sterba
2024-05-21  0:37   ` Anand Jain
2024-05-21 18:29     ` David Sterba
2024-05-16 22:12 ` [PATCH 5/6] btrfs/011: mkfs the scratch dev before exiting David Sterba
2024-05-17 15:37   ` Darrick J. Wong
2024-05-20 19:18     ` David Sterba
2024-05-16 22:12 ` [PATCH 6/6] btrfs/{140,141}: verify read-repair test data by md5sum David Sterba
2024-05-23 15:31   ` Anand Jain
2024-05-23 15:35 ` [PATCH 0/6] Btrfs test updates and fixups Anand Jain

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=20240520192110.GH17126@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=anand.jain@oracle.com \
    --cc=dsterba@suse.com \
    --cc=fstests@vger.kernel.org \
    --cc=josef@toxicpanda.com \
    /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