Message ID | e635739e6aa18e70036ddcf63019cf0e4d4493b0.1686484067.git.anand.jain@oracle.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs-progs: cleanup and preparatory around device scan | expand |
On 2023/6/13 18:26, Anand Jain wrote: > To prepare for handling command line given devices factor out > btrfs_scan_argv_devices(). Is there something wrong with the thread? This patch is showing 5/7 but the next is only 6/6. The same problem happens to your tune patchset too, which seems worse, as what I got is 1/5, 1/1, 3/5, 3/5 and 5/5. Thanks, Qu > > Signed-off-by: Anand Jain <anand.jain@oracle.com> > --- > v3: Rename args of btrfs_scan_argv_devices() > Rename factored out function name from btrfs_scan_sdin_devices() > to btrfs_scan_argv_devices() > > cmds/inspect-dump-tree.c | 37 +++---------------------------------- > common/device-scan.c | 40 ++++++++++++++++++++++++++++++++++++++++ > common/device-scan.h | 1 + > 3 files changed, 44 insertions(+), 34 deletions(-) > > diff --git a/cmds/inspect-dump-tree.c b/cmds/inspect-dump-tree.c > index 1d2a785ac5c3..50b792bbc4e7 100644 > --- a/cmds/inspect-dump-tree.c > +++ b/cmds/inspect-dump-tree.c > @@ -327,7 +327,6 @@ static int cmd_inspect_dump_tree(const struct cmd_struct *cmd, > bool roots_only = false; > bool root_backups = false; > int traverse = BTRFS_PRINT_TREE_DEFAULT; > - int dev_optind; > u64 block_bytenr; > struct btrfs_root *tree_root_scan; > u64 tree_id = 0; > @@ -455,39 +454,9 @@ static int cmd_inspect_dump_tree(const struct cmd_struct *cmd, > if (check_argc_min(argc - optind, 1)) > return 1; > > - dev_optind = optind; > - while (dev_optind < argc) { > - int fd; > - struct btrfs_fs_devices *fs_devices; > - u64 num_devices; > - > - ret = check_arg_type(argv[optind]); > - if (ret != BTRFS_ARG_BLKDEV && ret != BTRFS_ARG_REG) { > - if (ret < 0) { > - errno = -ret; > - error("invalid argument %s: %m", argv[dev_optind]); > - } else { > - error("not a block device or regular file: %s", > - argv[dev_optind]); > - } > - } > - fd = open(argv[dev_optind], O_RDONLY); > - if (fd < 0) { > - error("cannot open %s: %m", argv[dev_optind]); > - return -EINVAL; > - } > - ret = btrfs_scan_one_device(fd, argv[dev_optind], &fs_devices, > - &num_devices, > - BTRFS_SUPER_INFO_OFFSET, > - SBREAD_DEFAULT); > - close(fd); > - if (ret < 0) { > - errno = -ret; > - error("device scan %s: %m", argv[dev_optind]); > - return ret; > - } > - dev_optind++; > - } > + ret = btrfs_scan_argv_devices(optind, argc, argv); > + if (ret) > + return ret; > > pr_verbose(LOG_DEFAULT, "%s\n", PACKAGE_STRING); > > diff --git a/common/device-scan.c b/common/device-scan.c > index 515481a6efa9..68b94ecd9d77 100644 > --- a/common/device-scan.c > +++ b/common/device-scan.c > @@ -500,3 +500,43 @@ int btrfs_scan_devices(int verbose) > return 0; > } > > +int btrfs_scan_argv_devices(int dev_optind, int dev_argc, char **dev_argv) > +{ > + int ret; > + > + while (dev_optind < dev_argc) { > + int fd; > + u64 num_devices; > + struct btrfs_fs_devices *fs_devices; > + > + ret = check_arg_type(dev_argv[dev_optind]); > + if (ret != BTRFS_ARG_BLKDEV && ret != BTRFS_ARG_REG) { > + if (ret < 0) { > + errno = -ret; > + error("invalid argument %s: %m", > + dev_argv[dev_optind]); > + } else { > + error("not a block device or regular file: %s", > + dev_argv[dev_optind]); > + } > + } > + fd = open(dev_argv[dev_optind], O_RDONLY); > + if (fd < 0) { > + error("cannot open %s: %m", dev_argv[dev_optind]); > + return -EINVAL; > + } > + ret = btrfs_scan_one_device(fd, dev_argv[dev_optind], &fs_devices, > + &num_devices, > + BTRFS_SUPER_INFO_OFFSET, > + SBREAD_DEFAULT); > + close(fd); > + if (ret < 0) { > + errno = -ret; > + error("device scan %s: %m", dev_argv[dev_optind]); > + return ret; > + } > + dev_optind++; > + } > + > + return 0; > +} > diff --git a/common/device-scan.h b/common/device-scan.h > index f805b489f595..0d0f081134f2 100644 > --- a/common/device-scan.h > +++ b/common/device-scan.h > @@ -58,5 +58,6 @@ int add_seen_fsid(u8 *fsid, struct seen_fsid *seen_fsid_hash[], > int fd, DIR *dirstream); > void free_seen_fsid(struct seen_fsid *seen_fsid_hash[]); > int test_uuid_unique(const char *uuid_str); > +int btrfs_scan_argv_devices(int dev_optind, int argc, char **argv); > > #endif
On 13/06/2023 18:49, Qu Wenruo wrote: > > > On 2023/6/13 18:26, Anand Jain wrote: >> To prepare for handling command line given devices factor out >> btrfs_scan_argv_devices(). > > Is there something wrong with the thread? > > This patch is showing 5/7 but the next is only 6/6. Sorry for the confusion. Please read the patch number as 5/6. > > The same problem happens to your tune patchset too, which seems worse, > as what I got is 1/5, 1/1, 3/5, 3/5 and 5/5. I noticed it a little late, but 1/1 should be updated to 2/5. Thanks, Anand
diff --git a/cmds/inspect-dump-tree.c b/cmds/inspect-dump-tree.c index 1d2a785ac5c3..50b792bbc4e7 100644 --- a/cmds/inspect-dump-tree.c +++ b/cmds/inspect-dump-tree.c @@ -327,7 +327,6 @@ static int cmd_inspect_dump_tree(const struct cmd_struct *cmd, bool roots_only = false; bool root_backups = false; int traverse = BTRFS_PRINT_TREE_DEFAULT; - int dev_optind; u64 block_bytenr; struct btrfs_root *tree_root_scan; u64 tree_id = 0; @@ -455,39 +454,9 @@ static int cmd_inspect_dump_tree(const struct cmd_struct *cmd, if (check_argc_min(argc - optind, 1)) return 1; - dev_optind = optind; - while (dev_optind < argc) { - int fd; - struct btrfs_fs_devices *fs_devices; - u64 num_devices; - - ret = check_arg_type(argv[optind]); - if (ret != BTRFS_ARG_BLKDEV && ret != BTRFS_ARG_REG) { - if (ret < 0) { - errno = -ret; - error("invalid argument %s: %m", argv[dev_optind]); - } else { - error("not a block device or regular file: %s", - argv[dev_optind]); - } - } - fd = open(argv[dev_optind], O_RDONLY); - if (fd < 0) { - error("cannot open %s: %m", argv[dev_optind]); - return -EINVAL; - } - ret = btrfs_scan_one_device(fd, argv[dev_optind], &fs_devices, - &num_devices, - BTRFS_SUPER_INFO_OFFSET, - SBREAD_DEFAULT); - close(fd); - if (ret < 0) { - errno = -ret; - error("device scan %s: %m", argv[dev_optind]); - return ret; - } - dev_optind++; - } + ret = btrfs_scan_argv_devices(optind, argc, argv); + if (ret) + return ret; pr_verbose(LOG_DEFAULT, "%s\n", PACKAGE_STRING); diff --git a/common/device-scan.c b/common/device-scan.c index 515481a6efa9..68b94ecd9d77 100644 --- a/common/device-scan.c +++ b/common/device-scan.c @@ -500,3 +500,43 @@ int btrfs_scan_devices(int verbose) return 0; } +int btrfs_scan_argv_devices(int dev_optind, int dev_argc, char **dev_argv) +{ + int ret; + + while (dev_optind < dev_argc) { + int fd; + u64 num_devices; + struct btrfs_fs_devices *fs_devices; + + ret = check_arg_type(dev_argv[dev_optind]); + if (ret != BTRFS_ARG_BLKDEV && ret != BTRFS_ARG_REG) { + if (ret < 0) { + errno = -ret; + error("invalid argument %s: %m", + dev_argv[dev_optind]); + } else { + error("not a block device or regular file: %s", + dev_argv[dev_optind]); + } + } + fd = open(dev_argv[dev_optind], O_RDONLY); + if (fd < 0) { + error("cannot open %s: %m", dev_argv[dev_optind]); + return -EINVAL; + } + ret = btrfs_scan_one_device(fd, dev_argv[dev_optind], &fs_devices, + &num_devices, + BTRFS_SUPER_INFO_OFFSET, + SBREAD_DEFAULT); + close(fd); + if (ret < 0) { + errno = -ret; + error("device scan %s: %m", dev_argv[dev_optind]); + return ret; + } + dev_optind++; + } + + return 0; +} diff --git a/common/device-scan.h b/common/device-scan.h index f805b489f595..0d0f081134f2 100644 --- a/common/device-scan.h +++ b/common/device-scan.h @@ -58,5 +58,6 @@ int add_seen_fsid(u8 *fsid, struct seen_fsid *seen_fsid_hash[], int fd, DIR *dirstream); void free_seen_fsid(struct seen_fsid *seen_fsid_hash[]); int test_uuid_unique(const char *uuid_str); +int btrfs_scan_argv_devices(int dev_optind, int argc, char **argv); #endif
To prepare for handling command line given devices factor out btrfs_scan_argv_devices(). Signed-off-by: Anand Jain <anand.jain@oracle.com> --- v3: Rename args of btrfs_scan_argv_devices() Rename factored out function name from btrfs_scan_sdin_devices() to btrfs_scan_argv_devices() cmds/inspect-dump-tree.c | 37 +++---------------------------------- common/device-scan.c | 40 ++++++++++++++++++++++++++++++++++++++++ common/device-scan.h | 1 + 3 files changed, 44 insertions(+), 34 deletions(-)