diff mbox series

btrfs-progs: register device after successfully changing the fsid

Message ID 4b7b4c651700247046a32fce3148e510877ccdc6.1690448585.git.anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: register device after successfully changing the fsid | expand

Commit Message

Anand Jain July 27, 2023, 9:06 a.m. UTC
Testing with the fstests config option POST_MKFS_CMD="btrfstune -m"
reported failure, as shown below:

  ./check btrfs/003

  [111.635618] BTRFS: device fsid a6599a65-8b6d-4156-bb55-0a3a2f0eae9d devid 1 transid 6 /dev/sdb2 scanned by systemd-udevd (1117)
  [111.642199] BTRFS: device fsid a6599a65-8b6d-4156-bb55-0a3a2f0eae9d devid 2 transid 6 /dev/sdb3 scanned by systemd-udevd (1114)
  [111.660882] BTRFS: device fsid a6599a65-8b6d-4156-bb55-0a3a2f0eae9d devid 3 transid 6 /dev/sdb5 scanned by systemd-udevd (1116)
  [111.672623] BTRFS: device fsid a6599a65-8b6d-4156-bb55-0a3a2f0eae9d devid 4 transid 6 /dev/sdb6 scanned by systemd-udevd (993)
  [111.701301] BTRFS: device fsid a6599a65-8b6d-4156-bb55-0a3a2f0eae9d devid 6 transid 6 /dev/sdb8 scanned by systemd-udevd (1080)
  [111.706513] BTRFS: device fsid a6599a65-8b6d-4156-bb55-0a3a2f0eae9d devid 5 transid 6 /dev/sdb7 scanned by systemd-udevd (1117)
  [111.716532] BTRFS: device fsid a6599a65-8b6d-4156-bb55-0a3a2f0eae9d devid 7 transid 6 /dev/sdb9 scanned by systemd-udevd (1114)
  [111.721253] BTRFS: device fsid a6599a65-8b6d-4156-bb55-0a3a2f0eae9d devid 8 transid 6 /dev/sdb10 scanned by mkfs.btrfs (1504)
  [112.405186] BTRFS: device fsid 1b3bacbf-14db-49c9-a3ef-547998aacc4e devid 4 transid 8 /dev/sdb6 scanned by systemd-udevd (1117)
  [112.422104] BTRFS: device fsid 1b3bacbf-14db-49c9-a3ef-547998aacc4e devid 6 transid 8 /dev/sdb8 scanned by systemd-udevd (1523)
  [112.448355] BTRFS: device fsid 1b3bacbf-14db-49c9-a3ef-547998aacc4e devid 1 transid 8 /dev/sdb2 scanned by systemd-udevd (1115)
  [112.456126] BTRFS error: device /dev/sdb3 belongs to fsid 1b3bacbf-14db-49c9-a3ef-547998aacc4e, and the fs is already mounted
  [112.461299] BTRFS error: device /dev/sdb7 belongs to fsid 1b3bacbf-14db-49c9-a3ef-547998aacc4e, and the fs is already mounted
  [112.465690] BTRFS info (device sdb2): using crc32c (crc32c-generic) checksum algorithm
  [112.468758] BTRFS info (device sdb2): using free space tree
  [112.471318] BTRFS error: device /dev/sdb9 belongs to fsid 1b3bacbf-14db-49c9-a3ef-547998aacc4e, and the fs is already mounted
  [112.475962] BTRFS error: device /dev/sdb10 belongs to fsid 1b3bacbf-14db-49c9-a3ef-547998aacc4e, and the fs is already mounted
  [112.481934] BTRFS error: device /dev/sdb5 belongs to fsid 1b3bacbf-14db-49c9-a3ef-547998aacc4e, and the fs is already mounted
  [112.494614] BTRFS error (device sdb2): devid 2 uuid 99a57db7-2ef6-4240-a700-07ee7e64fb36 is missing
  [112.497834] BTRFS error (device sdb2): failed to read chunk tree: -2
  [112.507705] BTRFS error (device sdb2): open_ctree failed

The original fsid created by mkfs was a6599a65-8b6d-4156-bb55-0a3a2f0eae9d,
and the fsid created by the btrfstune -m option was
1b3bacbf-14db-49c9-a3ef-547998aacc4e.

During mount (after btrfstune -m), only 3 out of 8 devices were scanned
by systemd, while the rest were still being discovered. Consequently, the
mount command raced to find the missing devices. Since the mount command
in the kernel sets the flag fsdevices::opened, any further new alloc_device()
were blocked, resulting in the error "the fs is already mounted."

It is a good idea to register all devices after changing the fsid.
The previous registrations are already stale after changing the fsid.
---
 tune/main.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Anand Jain July 27, 2023, 2:15 p.m. UTC | #1
On 27/07/2023 17:06, Anand Jain wrote:
> Testing with the fstests config option POST_MKFS_CMD="btrfstune -m"
> reported failure, as shown below:
> 
>    ./check btrfs/003
> 
>    [111.635618] BTRFS: device fsid a6599a65-8b6d-4156-bb55-0a3a2f0eae9d devid 1 transid 6 /dev/sdb2 scanned by systemd-udevd (1117)
>    [111.642199] BTRFS: device fsid a6599a65-8b6d-4156-bb55-0a3a2f0eae9d devid 2 transid 6 /dev/sdb3 scanned by systemd-udevd (1114)
>    [111.660882] BTRFS: device fsid a6599a65-8b6d-4156-bb55-0a3a2f0eae9d devid 3 transid 6 /dev/sdb5 scanned by systemd-udevd (1116)
>    [111.672623] BTRFS: device fsid a6599a65-8b6d-4156-bb55-0a3a2f0eae9d devid 4 transid 6 /dev/sdb6 scanned by systemd-udevd (993)
>    [111.701301] BTRFS: device fsid a6599a65-8b6d-4156-bb55-0a3a2f0eae9d devid 6 transid 6 /dev/sdb8 scanned by systemd-udevd (1080)
>    [111.706513] BTRFS: device fsid a6599a65-8b6d-4156-bb55-0a3a2f0eae9d devid 5 transid 6 /dev/sdb7 scanned by systemd-udevd (1117)
>    [111.716532] BTRFS: device fsid a6599a65-8b6d-4156-bb55-0a3a2f0eae9d devid 7 transid 6 /dev/sdb9 scanned by systemd-udevd (1114)
>    [111.721253] BTRFS: device fsid a6599a65-8b6d-4156-bb55-0a3a2f0eae9d devid 8 transid 6 /dev/sdb10 scanned by mkfs.btrfs (1504)
>    [112.405186] BTRFS: device fsid 1b3bacbf-14db-49c9-a3ef-547998aacc4e devid 4 transid 8 /dev/sdb6 scanned by systemd-udevd (1117)
>    [112.422104] BTRFS: device fsid 1b3bacbf-14db-49c9-a3ef-547998aacc4e devid 6 transid 8 /dev/sdb8 scanned by systemd-udevd (1523)
>    [112.448355] BTRFS: device fsid 1b3bacbf-14db-49c9-a3ef-547998aacc4e devid 1 transid 8 /dev/sdb2 scanned by systemd-udevd (1115)
>    [112.456126] BTRFS error: device /dev/sdb3 belongs to fsid 1b3bacbf-14db-49c9-a3ef-547998aacc4e, and the fs is already mounted
>    [112.461299] BTRFS error: device /dev/sdb7 belongs to fsid 1b3bacbf-14db-49c9-a3ef-547998aacc4e, and the fs is already mounted
>    [112.465690] BTRFS info (device sdb2): using crc32c (crc32c-generic) checksum algorithm
>    [112.468758] BTRFS info (device sdb2): using free space tree
>    [112.471318] BTRFS error: device /dev/sdb9 belongs to fsid 1b3bacbf-14db-49c9-a3ef-547998aacc4e, and the fs is already mounted
>    [112.475962] BTRFS error: device /dev/sdb10 belongs to fsid 1b3bacbf-14db-49c9-a3ef-547998aacc4e, and the fs is already mounted
>    [112.481934] BTRFS error: device /dev/sdb5 belongs to fsid 1b3bacbf-14db-49c9-a3ef-547998aacc4e, and the fs is already mounted
>    [112.494614] BTRFS error (device sdb2): devid 2 uuid 99a57db7-2ef6-4240-a700-07ee7e64fb36 is missing
>    [112.497834] BTRFS error (device sdb2): failed to read chunk tree: -2
>    [112.507705] BTRFS error (device sdb2): open_ctree failed
> 
> The original fsid created by mkfs was a6599a65-8b6d-4156-bb55-0a3a2f0eae9d,
> and the fsid created by the btrfstune -m option was
> 1b3bacbf-14db-49c9-a3ef-547998aacc4e.
> 
> During mount (after btrfstune -m), only 3 out of 8 devices were scanned
> by systemd, while the rest were still being discovered. Consequently, the
> mount command raced to find the missing devices. Since the mount command
> in the kernel sets the flag fsdevices::opened, any further new alloc_device()
> were blocked, resulting in the error "the fs is already mounted."
> 
> It is a good idea to register all devices after changing the fsid.
> The previous registrations are already stale after changing the fsid.

Signed-off-by: Anand Jain <anand.jain@oracle.com>

> ---
>   tune/main.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/tune/main.c b/tune/main.c
> index 82ae5a0ac2d1..4fdc2a0acce0 100644
> --- a/tune/main.c
> +++ b/tune/main.c
> @@ -446,6 +446,7 @@ int BOX_MAIN(btrfstune)(int argc, char *argv[])
>   		if (!ret)
>   			success++;
>   		total++;
> +		btrfs_register_all_devices();
>   	}
>   
>   	if (random_fsid || (new_fsid_str && !change_metadata_uuid)) {
Anand Jain July 28, 2023, 9:15 a.m. UTC | #2
My SOB is missing in the devel branch. Should I resend?
Thx.
David Sterba Aug. 11, 2023, 6:01 p.m. UTC | #3
On Fri, Jul 28, 2023 at 05:15:32PM +0800, Anand Jain wrote:
> 
>    My SOB is missing in the devel branch. Should I resend?

No need to resend unless you have something more to update in the patch,
otherwise for such fixups to changelog or code it's sufficient to reply
to mails, I'll get to it eventually.
diff mbox series

Patch

diff --git a/tune/main.c b/tune/main.c
index 82ae5a0ac2d1..4fdc2a0acce0 100644
--- a/tune/main.c
+++ b/tune/main.c
@@ -446,6 +446,7 @@  int BOX_MAIN(btrfstune)(int argc, char *argv[])
 		if (!ret)
 			success++;
 		total++;
+		btrfs_register_all_devices();
 	}
 
 	if (random_fsid || (new_fsid_str && !change_metadata_uuid)) {