[1/2] btrfs: fix the bug of device scan/ready for mounted, filesystem
diff mbox

Message ID 923e5500-d6d8-b4b5-eb0b-30b80760a3f1@jp.fujitsu.com
State New
Headers show

Commit Message

Misono Tomohiro Jan. 17, 2018, 8:37 a.m. UTC
commit ae3acc5fc0bf ("btrfs: cleanup btrfs_mount() using
btrfs_mount_root()") introduces a bug that "btrfs device scan/ready" for
mounted filesystem fails.

This is because fs_info->bdev_holder has been changed to hold
btrfs_root_fs_type instead of btrfs_fs_type by this commit, but ioctl
for device scan/ready still uses btrfs_fs_type to call
btrfs_scan_one_device(). This leads to failiure of blkdev_get_by_path()
for mounted filesystem because of different holder type.

Fix this by specifying btrfs_root_fs_type for btrfs_scan_one_device() in
the path of device ready/scan ioctl.

Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
---
 fs/btrfs/super.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Anand Jain Jan. 18, 2018, 6:57 a.m. UTC | #1
On 01/17/2018 04:37 PM, Misono, Tomohiro wrote:
> commit ae3acc5fc0bf ("btrfs: cleanup btrfs_mount() using
> btrfs_mount_root()") introduces a bug that "btrfs device scan/ready" for
> mounted filesystem fails.
> 
> This is because fs_info->bdev_holder has been changed to hold
> btrfs_root_fs_type instead of btrfs_fs_type by this commit, but ioctl
> for device scan/ready still uses btrfs_fs_type to call
> btrfs_scan_one_device(). This leads to failiure of blkdev_get_by_path()
> for mounted filesystem because of different holder type.
> 
> Fix this by specifying btrfs_root_fs_type for btrfs_scan_one_device() in
> the path of device ready/scan ioctl.


   Reviewed-by: Anand Jain <Anand.Jain@oracle.com>

Thanks, Anand

> Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
> ---
>   fs/btrfs/super.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index 9438d32c4267..6ff13948b655 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -2231,11 +2231,11 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
>   	switch (cmd) {
>   	case BTRFS_IOC_SCAN_DEV:
>   		ret = btrfs_scan_one_device(vol->name, FMODE_READ,
> -					    &btrfs_fs_type, &fs_devices);
> +					    &btrfs_root_fs_type, &fs_devices);
>   		break;
>   	case BTRFS_IOC_DEVICES_READY:
>   		ret = btrfs_scan_one_device(vol->name, FMODE_READ,
> -					    &btrfs_fs_type, &fs_devices);
> +					    &btrfs_root_fs_type, &fs_devices);
>   		if (ret)
>   			break;
>   		ret = !(fs_devices->num_devices == fs_devices->total_devices);
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Sterba Jan. 18, 2018, 3:09 p.m. UTC | #2
On Wed, Jan 17, 2018 at 05:37:39PM +0900, Misono, Tomohiro wrote:
> commit ae3acc5fc0bf ("btrfs: cleanup btrfs_mount() using
> btrfs_mount_root()") introduces a bug that "btrfs device scan/ready" for
> mounted filesystem fails.
> 
> This is because fs_info->bdev_holder has been changed to hold
> btrfs_root_fs_type instead of btrfs_fs_type by this commit, but ioctl
> for device scan/ready still uses btrfs_fs_type to call
> btrfs_scan_one_device(). This leads to failiure of blkdev_get_by_path()
> for mounted filesystem because of different holder type.
> 
> Fix this by specifying btrfs_root_fs_type for btrfs_scan_one_device() in
> the path of device ready/scan ioctl.
> 
> Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>

Thanks. I'd rather fold that in to "btrfs: cleanup btrfs_mount() using
btrfs_mount_root()" where the semantics of holder actually changes.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 9438d32c4267..6ff13948b655 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -2231,11 +2231,11 @@  static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
 	switch (cmd) {
 	case BTRFS_IOC_SCAN_DEV:
 		ret = btrfs_scan_one_device(vol->name, FMODE_READ,
-					    &btrfs_fs_type, &fs_devices);
+					    &btrfs_root_fs_type, &fs_devices);
 		break;
 	case BTRFS_IOC_DEVICES_READY:
 		ret = btrfs_scan_one_device(vol->name, FMODE_READ,
-					    &btrfs_fs_type, &fs_devices);
+					    &btrfs_root_fs_type, &fs_devices);
 		if (ret)
 			break;
 		ret = !(fs_devices->num_devices == fs_devices->total_devices);