summaryrefslogtreecommitdiff
path: root/cmds-inspect.c
diff options
context:
space:
mode:
authorLiu Bo <bo.li.liu@oracle.com>2012-08-31 05:40:44 +0000
committerChris Mason <chris.mason@fusionio.com>2012-10-04 20:33:20 -0400
commit723e5b0f9a47b9f9d2c4d8b87693af754a2730e9 (patch)
treef3691905d4b59449e0bad5ec7a987ab10d37a47a /cmds-inspect.c
parent6eba9002956ac40db87d42fb653a0524dc568810 (diff)
downloadbtrfs-progs-723e5b0f9a47b9f9d2c4d8b87693af754a2730e9.tar.gz
Btrfs-progs: add options to change bufsize in logical to inode translation
Add an option 's' to set bufsize in logical to inode transition, then we are able to read all the refs to the logical address. Meanwhile, set a max value 64k for the bufsize. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'cmds-inspect.c')
-rw-r--r--cmds-inspect.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/cmds-inspect.c b/cmds-inspect.c
index 376fab2..4e072b0 100644
--- a/cmds-inspect.c
+++ b/cmds-inspect.c
@@ -113,8 +113,13 @@ static int cmd_inode_resolve(int argc, char **argv)
}
static const char * const cmd_logical_resolve_usage[] = {
- "btrfs inspect-internal logical-resolve [-Pv] <logical> <path>",
+ "btrfs inspect-internal logical-resolve [-Pv] [-s bufsize] <logical> <path>",
"Get file system paths for the given logical address",
+ "-P skip the path resolving and print the inodes instead",
+ "-v verbose mode",
+ "-s bufsize set inode container's size. This is used to increase inode",
+ " container's size in case it is not enough to read all the ",
+ " resolved results. The max value one can set is 64k",
NULL
};
@@ -128,12 +133,13 @@ static int cmd_logical_resolve(int argc, char **argv)
int bytes_left;
struct btrfs_ioctl_logical_ino_args loi;
struct btrfs_data_container *inodes;
+ u64 size = 4096;
char full_path[4096];
char *path_ptr;
optind = 1;
while (1) {
- int c = getopt(argc, argv, "Pv");
+ int c = getopt(argc, argv, "Pvs:");
if (c < 0)
break;
@@ -144,6 +150,9 @@ static int cmd_logical_resolve(int argc, char **argv)
case 'v':
verbose = 1;
break;
+ case 's':
+ size = atoll(optarg);
+ break;
default:
usage(cmd_logical_resolve_usage);
}
@@ -152,12 +161,13 @@ static int cmd_logical_resolve(int argc, char **argv)
if (check_argc_exact(argc - optind, 2))
usage(cmd_logical_resolve_usage);
- inodes = malloc(4096);
+ size = min(size, 64 * 1024);
+ inodes = malloc(size);
if (!inodes)
return 1;
loi.logical = atoll(argv[optind]);
- loi.size = 4096;
+ loi.size = size;
loi.inodes = (u64)inodes;
fd = open_file_or_dir(argv[optind+1]);
@@ -174,8 +184,9 @@ static int cmd_logical_resolve(int argc, char **argv)
}
if (verbose)
- printf("ioctl ret=%d, bytes_left=%lu, bytes_missing=%lu, "
- "cnt=%d, missed=%d\n", ret,
+ 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);