diff mbox series

[v2] btrfs: output an error message if btrfs failed to find the seed fsid

Message ID 82088d8a206ac6187b994a4f9f21876773cf036b.1739831055.git.wqu@suse.com (mailing list archive)
State New
Headers show
Series [v2] btrfs: output an error message if btrfs failed to find the seed fsid | expand

Commit Message

Qu Wenruo Feb. 17, 2025, 10:25 p.m. UTC
[BUG]
If btrfs failed to locate the seed device for whatever reason, mounting
the sprouted device will fail without any meaningful 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>
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
Changelog:
v2:
- Enhance the error message to show a little more details
- Remove the dmesg timestamp from commit message
---
 fs/btrfs/volumes.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Filipe Manana Feb. 18, 2025, 11:06 a.m. UTC | #1
On Mon, Feb 17, 2025 at 10:26 PM Qu Wenruo <wqu@suse.com> wrote:
>
> [BUG]
> If btrfs failed to locate the seed device for whatever reason, mounting
> the sprouted device will fail without any meaningful 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>
> Signed-off-by: Qu Wenruo <wqu@suse.com>

Reviewed-by: Filipe Manana <fdmanana@suse.com>

Looks good, thanks.

> ---
> Changelog:
> v2:
> - Enhance the error message to show a little more details
> - Remove the dmesg timestamp from commit message
> ---
>  fs/btrfs/volumes.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 0a0776489055..fb22d4425cb0 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -7200,8 +7200,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))
> --
> 2.48.1
>
>
diff mbox series

Patch

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 0a0776489055..fb22d4425cb0 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -7200,8 +7200,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))