btrfs-progs: rename btrfs_scan_lblkid() to btrfs_scan_devices()
Subsystems (2)
PATCH 1/2 btrfs-progs: rename btrfs_scan_lblkid() to btrfs_scan_devices()
It seems like bad idea to use a library name (lblkid) within generic function name. The currently used scanning library is implementation detail and this detail should be hidden for rest of the code.
--- cmds-device.c | 2 +- cmds-filesystem.c | 2 +- disk-io.c | 2 +- utils.c | 6 +++--- utils.h | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-)
cmds-device.c +1 -1
@@ -235,7 +235,7 @@ static int cmd_scan_dev(int argc, char **argv)if (all || argc ==1 ) {printf ("Scanning for Btrfs filesystems\n" ); - ret =btrfs_scan_lblkid (); + ret =btrfs_scan_devices ();if (ret)fprintf (stderr,"ERROR: error %d while scanning\n" , ret); ret =btrfs_register_all_devices ();
cmds-filesystem.c +1 -1
@@ -948,7 +948,7 @@ static int cmd_show(int argc, char **argv) goto out; devs_only: - ret =btrfs_scan_lblkid (); + ret =btrfs_scan_devices ();if (ret) {fprintf (stderr,"ERROR: %d while scanning\n" , ret);
disk-io.c +1 -1
@@ -1019,7 +1019,7 @@ int btrfs_scan_fs_devices(int fd, const char *path, }if (total_devs !=1 ) { - ret =btrfs_scan_lblkid (); + ret =btrfs_scan_devices ();if (ret)return ret; }
utils.c +3 -3
@@ -1188,7 +1188,7 @@ int check_mounted_where(int fd, const char *file, char *where, int size,/* scan other devices */ if (is_btrfs && total_devs >1 ) { - ret =btrfs_scan_lblkid (); + ret =btrfs_scan_devices ();if (ret)return ret; }
@@ -1270,7 +1270,7 @@ int btrfs_register_one_device(const char *fname)/* * Register all devices in the fs_uuid list created in the user -* space. Ensure btrfs_scan_lblkid() is called before this func. +* space. Ensure btrfs_scan_devices() is called before this func. */ int btrfs_register_all_devices (void ) {
@@ -2181,7 +2181,7 @@ int test_dev_for_mkfs(char *file, int force_overwrite, char *estr)return 0 ; } -int btrfs_scan_lblkid () +int btrfs_scan_devices () {int fd =-1 ;int ret;
utils.h +1 -1
@@ -128,7 +128,7 @@ int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf, int verify);int ask_user (char *question);int lookup_ino_rootid (int fd,u64 *rootid); -int btrfs_scan_lblkid (void ); +int btrfs_scan_devices (void );int get_btrfs_mount (const char *dev,char *mp,size_t mp_size);int find_mount_root (const char *path,char **mount_root); int get_device_info(int fd, u64 devid,
Signature · 1 line
1.9.3
PATCH 2/2 btrfs-progs: use udev to scan for devices
Currently btrfs uses libblkid to scan for block devices with BTRFS. The disadvantage is that this method is expensive. The udevd maintains information about all block devices in udev db and all devices are probed by udevd (it's linked with libblkid). We don't have to duplicate this thing in btrfs.
This patch links btrfs with libudev, the original blkid based method is used as fallback (for systems without udev, etc.)
Note that btrfs-progs project does not use autoconf, so dependence on libudev is hardcoded to Makefile for now. It would be probably better to add ./configure script to the project and make dependence on libudev optional.
udev:
# time ./btrfs device scan Scanning for Btrfs filesystems real 0m0.012s user 0m0.004s sys 0m0.003s
blkid:
# time ./btrfs device scan Scanning for Btrfs filesystems real 0m0.076s user 0m0.008s sys 0m0.024s
--- Makefile | 2 +- utils.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 84 insertions(+), 25 deletions(-)
Makefile +1 -1
@@ -26,7 +26,7 @@ TESTS = fsck-tests.sh convert-tests.sh INSTALL = install prefix ?= /usr/local bindir = $(prefix)/bin -lib_LIBS = -luuid -lblkid -lm -lz -llzo2 -L. +lib_LIBS = -ludev -luuid -lblkid -lm -lz -llzo2 -L. libdir ?= $(prefix)/lib incdir = $(prefix)/include/btrfs LIBS = $(lib_LIBS) $(libs_static)
utils.c +83 -24
138 lines not on this page · raw message
Signature · 1 line
1.9.3
PATCH 2/2 btrfs-progs: use udev to scan for devices (v2)
Currently btrfs uses libblkid to scan for block devices with BTRFS. The disadvantage is that this method is expensive. The udevd maintains information about all block devices in udev db and all devices are probed by udevd (it's linked with libblkid). We don't have to duplicate this thing in btrfs.
This patch links btrfs with libudev, the original blkid based method is used as fallback (for systems without udev, etc.)
Note that btrfs-progs project does not use autoconf, so dependence on libudev is hardcoded to Makefile for now. It would be probably better to add ./configure script to the project and make dependence on libudev optional.
udev:
# time ./btrfs device scan Scanning for Btrfs filesystems real 0m0.012s user 0m0.004s sys 0m0.003s
blkid:
# time ./btrfs device scan Scanning for Btrfs filesystems real 0m0.076s user 0m0.008s sys 0m0.024s
V2:
- use udev_enumerate_add_match_property()
--- Makefile | 2 +- utils.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 81 insertions(+), 25 deletions(-)
Makefile +1 -1
@@ -26,7 +26,7 @@ TESTS = fsck-tests.sh convert-tests.sh INSTALL = install prefix ?= /usr/local bindir = $(prefix)/bin -lib_LIBS = -luuid -lblkid -lm -lz -llzo2 -L. +lib_LIBS = -ludev -luuid -lblkid -lm -lz -llzo2 -L. libdir ?= $(prefix)/lib incdir = $(prefix)/include/btrfs LIBS = $(lib_LIBS) $(libs_static)
utils.c +80 -24
135 lines not on this page · raw message
Signature · 1 line
1.9.3