aboutsummaryrefslogtreecommitdiffstats
path: root/disk-io.c
diff options
context:
space:
mode:
authorAnand Jain <anand.jain@oracle.com>2014-10-15 08:46:14 +0800
committerDavid Sterba <dsterba@suse.cz>2014-10-16 12:02:00 +0200
commit38cfeef1033e254c0a1446fe6f4bbe6f30e1f5db (patch)
tree404b772310abf1360446aa4b431669e06f5756bb /disk-io.c
parent6345bbd5b4f41cd5f4bf090b9f17e6c9c9afcf62 (diff)
downloadbtrfs-progs-38cfeef1033e254c0a1446fe6f4bbe6f30e1f5db.tar.gz
btrfs-progs-38cfeef1033e254c0a1446fe6f4bbe6f30e1f5db.tar.xz
btrfs-progs-38cfeef1033e254c0a1446fe6f4bbe6f30e1f5db.zip
btrfs-progs: introduce a proper structure on which cli will call register-device ioctl
As of now commands mentioned below (with in [..]) are calling call register-device ioctl BTRFS_IOC_SCAN_DEV for all the devices in the system. Some issues with it: BTRFS_IOC_SCAN_DEV: ioctl is a write operation, we don't want command like btrfs-debug-tree threads to do that.. eg: ---- $ cat /proc/fs/btrfs/devlist | egrep fsid | wc -l 0 $ btrfs-debug-tree /dev/sde (num_device > 1) $ cat /proc/fs/btrfs/devlist | egrep fsid | wc -l 5 ---- btrfs_scan_fs_devices() ends up calling this ioctl only when num_device > 1. That's inconsistency with in feature/bug. We don't have to register _all_ the btrfs devices (again) in the system without user consent. Why its inconsistent: function btrfs_scan_fs_devices() calls btrfs_scan_lblkid only when num_devices is > 1, which in turn calls BTRFS_IOC_SCAN_DEV ioctl, if conditions are met. But main issue is we have too many consumers of btrfs_scan_fs_devices() the names below with in [] is the cli leading to this function. open_ctree_broken() [btrfs-find-root] recover_prepare() [btrfs rescue super-recover] __open_ctree_fd (updates always except when flag OPEN_CTREE_RECOVER_SUPER is set and flag OPEN_CTREE_RECOVER_SUPER is set only by 'btrfs rescue super- recover' but still this thread sneaks through the open_ctree function to call register-device-ioctl as show below). open_ctree_fs_info [btrfs-debug-tree] [btrfs-image -r] [btrfs check] open_fs [btrfs restore] open_ctree [calc-size] [btrfs-corrupt-block] [btrfs-image] (create) [btrfs-map-logical] [btrfs-select-super] [btrfstune] [btrfs-zero-log] [tester] [mkfs] [quick-test.c] [btrfs label set unmounted] [btrfs get label unmounted] [btrfs rescue super-recover] open_ctree_fd [btrfs-convert] Fix: In an effort to make register-device consistent, all calls to btrfs_scan_fs_devices() will have 5th parameter set to 0. that means we don't need 5th parameter at all. And with this function not calling the register ioctl at all, finally we will have following two cli to call the ioctl BTRFS_IOC_SCAN_DEV. btrfs dev scan and mkfs.btrfs Threads needing to update kernel about a device would have to use btrfs_register_one_device() separately. Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'disk-io.c')
-rw-r--r--disk-io.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/disk-io.c b/disk-io.c
index 0c4cb4a..02b6d42 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -995,7 +995,7 @@ void btrfs_cleanup_all_caches(struct btrfs_fs_info *fs_info)
int btrfs_scan_fs_devices(int fd, const char *path,
struct btrfs_fs_devices **fs_devices,
- u64 sb_bytenr, int run_ioctl, int super_recover)
+ u64 sb_bytenr, int super_recover)
{
u64 total_devs;
int ret;
@@ -1010,7 +1010,7 @@ int btrfs_scan_fs_devices(int fd, const char *path,
}
if (total_devs != 1) {
- ret = btrfs_scan_lblkid(run_ioctl);
+ ret = btrfs_scan_lblkid(!BTRFS_UPDATE_KERNEL);
if (ret)
return ret;
}
@@ -1091,7 +1091,6 @@ static struct btrfs_fs_info *__open_ctree_fd(int fp, const char *path,
fs_info->on_restoring = 1;
ret = btrfs_scan_fs_devices(fp, path, &fs_devices, sb_bytenr,
- !(flags & OPEN_CTREE_RECOVER_SUPER),
(flags & OPEN_CTREE_RECOVER_SUPER));
if (ret)
goto out;