@@ -152,6 +152,7 @@ resolve paths to all files at given 'logical' address in the linear filesystem s
skip the path resolving and print the inodes instead
-v::::
verbose mode, print count of returned paths and all ioctl() return values
+This option is merged to the global verbose option
-o::::
ignore offsets, find all references to an extent instead of a single block.
Requires kernel support for the V2 ioctl (added in 4.15). The results might need
@@ -38,7 +38,7 @@ static const char * const inspect_cmd_group_usage[] = {
NULL
};
-static int __ino_to_path_fd(u64 inum, int fd, int verbose, const char *prepend)
+static int __ino_to_path_fd(u64 inum, int fd, const char *prepend)
{
int ret;
int i;
@@ -117,8 +117,7 @@ static int cmd_inspect_inode_resolve(const struct cmd_struct *cmd,
if (fd < 0)
return 1;
- ret = __ino_to_path_fd(arg_strtou64(argv[optind]), fd,
- bconf.verbose, argv[optind+1]);
+ ret = __ino_to_path_fd(arg_strtou64(argv[optind]), fd, argv[optind+1]);
close_file_or_dir(fd, dirstream);
return !!ret;
@@ -137,6 +136,8 @@ static const char * const cmd_inspect_logical_resolve_usage[] = {
" container's size in case it is not enough to read all the ",
" resolved results. The max value one can set is 64k with the",
" v1 ioctl. Sizes over 64k will use the v2 ioctl (kernel 4.15+)",
+ HELPINFO_INSERT_GLOBALS,
+ HELPINFO_INSERT_VERBOSE,
NULL
};
@@ -146,7 +147,6 @@ static int cmd_inspect_logical_resolve(const struct cmd_struct *cmd,
int ret;
int fd;
int i;
- int verbose = 0;
int getpath = 1;
int bytes_left;
struct btrfs_ioctl_logical_ino_args loi = { 0 };
@@ -169,7 +169,7 @@ static int cmd_inspect_logical_resolve(const struct cmd_struct *cmd,
getpath = 0;
break;
case 'v':
- verbose = 1;
+ bconf_be_verbose();
break;
case 'o':
flags |= BTRFS_LOGICAL_INO_ARGS_IGNORE_OFFSET;
@@ -211,13 +211,11 @@ static int cmd_inspect_logical_resolve(const struct cmd_struct *cmd,
goto out;
}
- if (verbose)
- printf("ioctl ret=%d, total_size=%llu, bytes_left=%lu, "
- "bytes_missing=%lu, cnt=%d, missed=%d\n",
- ret, size,
- (unsigned long)inodes->bytes_left,
- (unsigned long)inodes->bytes_missing,
- inodes->elem_cnt, inodes->elem_missed);
+ pr_verbose(1,
+"ioctl ret=%d, total_size=%llu, bytes_left=%lu, bytes_missing=%lu, cnt=%d, missed=%d\n",
+ ret, size, (unsigned long)inodes->bytes_left,
+ (unsigned long)inodes->bytes_missing, inodes->elem_cnt,
+ inodes->elem_missed);
bytes_left = sizeof(full_path);
ret = snprintf(full_path, bytes_left, "%s/", argv[optind+1]);
@@ -262,8 +260,7 @@ static int cmd_inspect_logical_resolve(const struct cmd_struct *cmd,
goto out;
}
}
- ret = __ino_to_path_fd(inum, path_fd, verbose,
- full_path);
+ ret = __ino_to_path_fd(inum, path_fd, full_path);
if (path_fd != fd)
close_file_or_dir(path_fd, dirs);
} else {
Transpire global --verbose option down to the btrfs inspect-internal logical-resolve sub-command. Command btrfs inspect-internal logical-resolve provides local verbose option this patch makes it enable-able by using the global --verbose option. Suggested-by: David Sterba <dsterba@suse.com> Signed-off-by: Anand Jain <anand.jain@oracle.com> --- v3: update help and documentation v2: Use new helper function bconf_be_verbose() Documentation/btrfs-inspect-internal.asciidoc | 1 + cmds/inspect.c | 25 ++++++++----------- 2 files changed, 12 insertions(+), 14 deletions(-)