btrfs: return accurate error code on open failure in open_fs_devices()
authorAnand Jain <anand.jain@oracle.com>
Tue, 19 Mar 2024 02:58:18 +0000 (08:28 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 May 2024 09:50:53 +0000 (11:50 +0200)
commit8943a256b06e13961c2682452a567d1b211671b1
treebf4d42c9575ca5370ff22951835ada23dea81c4e
parent93aa5ccc44781bdfef1bf0bc4c2c292d45251312
btrfs: return accurate error code on open failure in open_fs_devices()

[ Upstream commit 2f1aeab9fca1a5f583be1add175d1ee95c213cfa ]

When attempting to exclusive open a device which has no exclusive open
permission, such as a physical device associated with the flakey dm
device, the open operation will fail, resulting in a mount failure.

In this particular scenario, we erroneously return -EINVAL instead of the
correct error code provided by the bdev_open_by_path() function, which is
-EBUSY.

Fix this, by returning error code from the bdev_open_by_path() function.
With this correction, the mount error message will align with that of
ext4 and xfs.

Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/btrfs/volumes.c