FS/XFS testing framework
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: David Sterba <dsterba@suse.com>, fstests@vger.kernel.org
Cc: josef@toxicpanda.com
Subject: Re: [PATCH 1/6] common: udev settle before _scratch_pool_mkfs
Date: Sat, 18 May 2024 05:57:12 +0800	[thread overview]
Message-ID: <30c274a6-adc1-42a7-91cf-8a386884106f@oracle.com> (raw)
In-Reply-To: <b8e39744f98bde6484d222c6e90240f074df1eaf.1715896529.git.dsterba@suse.com>

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()

Thanks, Anand

>       *)


  reply	other threads:[~2024-05-17 21:57 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 [this message]
2024-05-20 19:21     ` David Sterba
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=30c274a6-adc1-42a7-91cf-8a386884106f@oracle.com \
    --to=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