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>
This commit is contained in:
parent
6eba900295
commit
723e5b0f9a
|
@ -113,8 +113,13 @@ static int cmd_inode_resolve(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char * const cmd_logical_resolve_usage[] = {
|
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",
|
"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
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -128,12 +133,13 @@ static int cmd_logical_resolve(int argc, char **argv)
|
||||||
int bytes_left;
|
int bytes_left;
|
||||||
struct btrfs_ioctl_logical_ino_args loi;
|
struct btrfs_ioctl_logical_ino_args loi;
|
||||||
struct btrfs_data_container *inodes;
|
struct btrfs_data_container *inodes;
|
||||||
|
u64 size = 4096;
|
||||||
char full_path[4096];
|
char full_path[4096];
|
||||||
char *path_ptr;
|
char *path_ptr;
|
||||||
|
|
||||||
optind = 1;
|
optind = 1;
|
||||||
while (1) {
|
while (1) {
|
||||||
int c = getopt(argc, argv, "Pv");
|
int c = getopt(argc, argv, "Pvs:");
|
||||||
if (c < 0)
|
if (c < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -144,6 +150,9 @@ static int cmd_logical_resolve(int argc, char **argv)
|
||||||
case 'v':
|
case 'v':
|
||||||
verbose = 1;
|
verbose = 1;
|
||||||
break;
|
break;
|
||||||
|
case 's':
|
||||||
|
size = atoll(optarg);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage(cmd_logical_resolve_usage);
|
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))
|
if (check_argc_exact(argc - optind, 2))
|
||||||
usage(cmd_logical_resolve_usage);
|
usage(cmd_logical_resolve_usage);
|
||||||
|
|
||||||
inodes = malloc(4096);
|
size = min(size, 64 * 1024);
|
||||||
|
inodes = malloc(size);
|
||||||
if (!inodes)
|
if (!inodes)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
loi.logical = atoll(argv[optind]);
|
loi.logical = atoll(argv[optind]);
|
||||||
loi.size = 4096;
|
loi.size = size;
|
||||||
loi.inodes = (u64)inodes;
|
loi.inodes = (u64)inodes;
|
||||||
|
|
||||||
fd = open_file_or_dir(argv[optind+1]);
|
fd = open_file_or_dir(argv[optind+1]);
|
||||||
|
@ -174,8 +184,9 @@ static int cmd_logical_resolve(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
printf("ioctl ret=%d, bytes_left=%lu, bytes_missing=%lu, "
|
printf("ioctl ret=%d, total_size=%llu, bytes_left=%lu, "
|
||||||
"cnt=%d, missed=%d\n", ret,
|
"bytes_missing=%lu, cnt=%d, missed=%d\n",
|
||||||
|
ret, size,
|
||||||
(unsigned long)inodes->bytes_left,
|
(unsigned long)inodes->bytes_left,
|
||||||
(unsigned long)inodes->bytes_missing,
|
(unsigned long)inodes->bytes_missing,
|
||||||
inodes->elem_cnt, inodes->elem_missed);
|
inodes->elem_cnt, inodes->elem_missed);
|
||||||
|
|
|
@ -50,7 +50,7 @@ btrfs \- control a btrfs filesystem
|
||||||
\fBbtrfs\fP \fBinspect-internal inode-resolve\fP [-v] \fI<inode>\fP \fI<path>\fP
|
\fBbtrfs\fP \fBinspect-internal inode-resolve\fP [-v] \fI<inode>\fP \fI<path>\fP
|
||||||
.PP
|
.PP
|
||||||
\fBbtrfs\fP \fBinspect-internal logical-resolve\fP
|
\fBbtrfs\fP \fBinspect-internal logical-resolve\fP
|
||||||
[-Pv] \fI<logical>\fP \fI<path>\fP
|
[-Pv] [-s size] \fI<logical>\fP \fI<path>\fP
|
||||||
.PP
|
.PP
|
||||||
\fBbtrfs\fP \fBhelp|\-\-help|\-h \fP\fI\fP
|
\fBbtrfs\fP \fBhelp|\-\-help|\-h \fP\fI\fP
|
||||||
.PP
|
.PP
|
||||||
|
@ -335,7 +335,7 @@ verbose mode. print count of returned paths and ioctl() return value
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.TP
|
||||||
|
|
||||||
\fBinspect-internal logical-resolve\fP [-Pv] \fI<logical>\fP \fI<path>\fP
|
\fBinspect-internal logical-resolve\fP [-Pv] [-s bufsize] \fI<logical>\fP \fI<path>\fP
|
||||||
Resolves a <logical> address in the filesystem mounted at <path> to all inodes.
|
Resolves a <logical> address in the filesystem mounted at <path> to all inodes.
|
||||||
By default, each inode is then resolved to a file system path (similar to the
|
By default, each inode is then resolved to a file system path (similar to the
|
||||||
\fBinode-resolve\fP subcommand).
|
\fBinode-resolve\fP subcommand).
|
||||||
|
@ -346,6 +346,9 @@ By default, each inode is then resolved to a file system path (similar to the
|
||||||
skip the path resolving and print the inodes instead
|
skip the path resolving and print the inodes instead
|
||||||
.IP -v 5
|
.IP -v 5
|
||||||
verbose mode. print count of returned paths and all ioctl() return values
|
verbose mode. print count of returned paths and all ioctl() return values
|
||||||
|
.IP -s bufsize 5
|
||||||
|
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.
|
||||||
.RE
|
.RE
|
||||||
|
|
||||||
.SH EXIT STATUS
|
.SH EXIT STATUS
|
||||||
|
|
Loading…
Reference in New Issue