diff mbox series

[V2] btrfs: print warning message if bdev_file_open_by_path function fails during mount.

Message ID 1721147081-4813-1-git-send-email-zhanglikernel@gmail.com (mailing list archive)
State New, archived
Headers show
Series [V2] btrfs: print warning message if bdev_file_open_by_path function fails during mount. | expand

Commit Message

Li Zhang July 16, 2024, 4:24 p.m. UTC
[ENHANCEMENT]
When mounting a btrfs filesystem, the filesystem opens the
block device, and if this fails, there is no message about
it. Print a message about it to help debugging.

[IMPLEMENTATION]
Print warning message if bdev_file_open_by_path fails.

[TEST]
I have a btrfs filesystem on three block devices,
one of which is write-protected, so regular mounts fail,
but there is no message in dmesg.

/dev/vdb normal
/dev/vdc write protected
/dev/vdd normal

Before patch:
$ sudo mount /dev/vdb /mnt/
mount: mount(2) failed: no such file or directory
$ sudo dmesg # Show only messages about missing block devices
....
[ 352.947196] BTRFS error (device vdb): devid 2 uuid 4ee2c625-a3b2-4fe0-b411-756b23e08533 missing
....

After patch:
$ sudo mount /dev/vdb /mnt/
mount: mount(2) failed: no such file or directory
$ sudo dmesg # Show bdev_file_open_by_path failed.
....
[ 352.944328] BTRFS error: faled to open device for path /dev/vdc with flags 0x3: -13
[ 352.947196] BTRFS error (device vdb): missing devid 2 uuid 4ee2c625-a3b2-4fe0-b411-756b23e08533
....

V1:
  Use printk to print messages

V2:
  Use btrfs_err to print messages and format output

Signed-off-by: Li Zhang <zhanglikernel@gmail.com>
---
 fs/btrfs/volumes.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Filipe Manana July 16, 2024, 4:30 p.m. UTC | #1
On Tue, Jul 16, 2024 at 5:25 PM Li Zhang <zhanglikernel@gmail.com> wrote:
>
> [ENHANCEMENT]
> When mounting a btrfs filesystem, the filesystem opens the
> block device, and if this fails, there is no message about
> it. Print a message about it to help debugging.
>
> [IMPLEMENTATION]
> Print warning message if bdev_file_open_by_path fails.

It's no longer a warning message (it's an error message now), plus
this section/phrase is redundant - you have already said the same
right above.

>
> [TEST]
> I have a btrfs filesystem on three block devices,
> one of which is write-protected, so regular mounts fail,
> but there is no message in dmesg.
>
> /dev/vdb normal
> /dev/vdc write protected
> /dev/vdd normal
>
> Before patch:
> $ sudo mount /dev/vdb /mnt/
> mount: mount(2) failed: no such file or directory
> $ sudo dmesg # Show only messages about missing block devices
> ....
> [ 352.947196] BTRFS error (device vdb): devid 2 uuid 4ee2c625-a3b2-4fe0-b411-756b23e08533 missing
> ....
>
> After patch:
> $ sudo mount /dev/vdb /mnt/
> mount: mount(2) failed: no such file or directory
> $ sudo dmesg # Show bdev_file_open_by_path failed.
> ....
> [ 352.944328] BTRFS error: faled to open device for path /dev/vdc with flags 0x3: -13

typo:  faled -> failed

> [ 352.947196] BTRFS error (device vdb): missing devid 2 uuid 4ee2c625-a3b2-4fe0-b411-756b23e08533
> ....
>
> V1:
>   Use printk to print messages
>
> V2:
>   Use btrfs_err to print messages and format output

Details about what changed between patch versions goes under the line
"---" below, so that it doesn't show up in the commit message after it
gets committed.

>
> Signed-off-by: Li Zhang <zhanglikernel@gmail.com>
> ---

Here.

>  fs/btrfs/volumes.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index c39145e..179419f 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -476,6 +476,7 @@ static noinline struct btrfs_fs_devices *find_fsid(
>
>         if (IS_ERR(*bdev_file)) {
>                 ret = PTR_ERR(*bdev_file);
> +               btrfs_err(NULL, "faled to open device for path %s with flags 0x%x: %d", device_path, flags, ret);

typo: faled -> failed

Thanks.

>                 goto error;
>         }
>         bdev = file_bdev(*bdev_file);
> --
> 1.8.3.1
>
>
diff mbox series

Patch

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index c39145e..179419f 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -476,6 +476,7 @@  static noinline struct btrfs_fs_devices *find_fsid(
 
 	if (IS_ERR(*bdev_file)) {
 		ret = PTR_ERR(*bdev_file);
+		btrfs_err(NULL, "faled to open device for path %s with flags 0x%x: %d", device_path, flags, ret);
 		goto error;
 	}
 	bdev = file_bdev(*bdev_file);