]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
btrfs: output an error message if btrfs failed to find the seed fsid
authorQu Wenruo <wqu@suse.com>
Mon, 17 Feb 2025 09:46:39 +0000 (20:16 +1030)
committerDavid Sterba <dsterba@suse.com>
Fri, 21 Feb 2025 08:32:16 +0000 (09:32 +0100)
[BUG]
If btrfs failed to locate the seed device for whatever reason, mounting
the sprouted device will fail without any meaning error message:

  # mkfs.btrfs -f /dev/test/scratch1
  # btrfstune -S1 /dev/test/scratch1
  # mount /dev/test/scratch1 /mnt/btrfs
  # btrfs dev add -f /dev/test/scratch2 /mnt/btrfs
  # umount /mnt/btrfs
  # btrfs dev scan -u
  # btrfs mount /dev/test/scratch2 /mnt/btrfs
  mount: /mnt/btrfs: fsconfig system call failed: No such file or directory.
        dmesg(1) may have more information after failed mount system call.
  # dmesg -t | tail -n6
  BTRFS info (device dm-5): first mount of filesystem 64252ded-5953-4868-b962-cea48f7ac4ea
  BTRFS info (device dm-5): using crc32c (crc32c-generic) checksum algorithm
  BTRFS info (device dm-5): using free-space-tree
  BTRFS error (device dm-5): failed to read chunk tree: -2
  BTRFS error (device dm-5): open_ctree failed: -2

[CAUSE]
The failure to mount is pretty straight forward, just unable to find the
seed device and its fsid, caused by `btrfs dev scan -u`.

But the lack of any useful info is a problem.

[FIX]
Just add an extra error message in open_seed_devices() to indicate the
error.

Now the error message would look like this:

 BTRFS info (device dm-4): first mount of filesystem 7769223d-4db1-4e4c-ac29-0a96f53576ab
 BTRFS info (device dm-4): using crc32c (crc32c-generic) checksum algorithm
 BTRFS info (device dm-4): using free-space-tree
 BTRFS error (device dm-4): failed to find fsid e87c12e6-584b-4e98-8b88-962c33a619ff when attempting to open seed devices
 BTRFS error (device dm-4): failed to read chunk tree: -2
 BTRFS error (device dm-4): open_ctree failed: -2

Link: https://github.com/kdave/btrfs-progs/issues/959
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/volumes.c

index a594f66daedf0a162f04899c2ffe4160aca279fc..f6ae76815e4b568e172048f0cd2ddc93abd8a2c2 100644 (file)
@@ -7196,8 +7196,12 @@ static struct btrfs_fs_devices *open_seed_devices(struct btrfs_fs_info *fs_info,
 
        fs_devices = find_fsid(fsid, NULL);
        if (!fs_devices) {
-               if (!btrfs_test_opt(fs_info, DEGRADED))
+               if (!btrfs_test_opt(fs_info, DEGRADED)) {
+                       btrfs_err(fs_info,
+               "failed to find fsid %pU when attempting to open seed devices",
+                                 fsid);
                        return ERR_PTR(-ENOENT);
+               }
 
                fs_devices = alloc_fs_devices(fsid);
                if (IS_ERR(fs_devices))