mirror of
https://github.com/kdave/btrfs-progs
synced 2025-04-07 01:31:17 +00:00
Btrfs-progs: allow fsck to take the tree bytenr
Sometimes we have a pretty corrupted fs but have an old tree bytenr that we could use, add the ability to specify the tree root bytenr. Thanks, Signed-off-by: Josef Bacik <jbacik@fb.com> Tested-by: Ansgar Hockmann-Stolle <ansgar.hockmann-stolle@uni-osnabrueck.de> Signed-off-by: David Sterba <dsterba@suse.cz>
This commit is contained in:
parent
05063de62c
commit
3a98fe43f6
11
cmds-check.c
11
cmds-check.c
@ -7677,6 +7677,7 @@ static struct option long_options[] = {
|
|||||||
{ "backup", 0, NULL, 0 },
|
{ "backup", 0, NULL, 0 },
|
||||||
{ "subvol-extents", 1, NULL, 'E' },
|
{ "subvol-extents", 1, NULL, 'E' },
|
||||||
{ "qgroup-report", 0, NULL, 'Q' },
|
{ "qgroup-report", 0, NULL, 'Q' },
|
||||||
|
{ "tree-root", 1, NULL, 'r' },
|
||||||
{ NULL, 0, NULL, 0}
|
{ NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -7692,6 +7693,7 @@ const char * const cmd_check_usage[] = {
|
|||||||
"--check-data-csum verify checkums of data blocks",
|
"--check-data-csum verify checkums of data blocks",
|
||||||
"--qgroup-report print a report on qgroup consistency",
|
"--qgroup-report print a report on qgroup consistency",
|
||||||
"--subvol-extents <subvolid> print subvolume extents and sharing state",
|
"--subvol-extents <subvolid> print subvolume extents and sharing state",
|
||||||
|
"--tree-root <bytenr> use the given bytenr for the tree root",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -7702,6 +7704,7 @@ int cmd_check(int argc, char **argv)
|
|||||||
struct btrfs_fs_info *info;
|
struct btrfs_fs_info *info;
|
||||||
u64 bytenr = 0;
|
u64 bytenr = 0;
|
||||||
u64 subvolid = 0;
|
u64 subvolid = 0;
|
||||||
|
u64 tree_root_bytenr = 0;
|
||||||
char uuidbuf[BTRFS_UUID_UNPARSED_SIZE];
|
char uuidbuf[BTRFS_UUID_UNPARSED_SIZE];
|
||||||
int ret;
|
int ret;
|
||||||
u64 num;
|
u64 num;
|
||||||
@ -7712,7 +7715,7 @@ int cmd_check(int argc, char **argv)
|
|||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
int c;
|
int c;
|
||||||
c = getopt_long(argc, argv, "as:b", long_options,
|
c = getopt_long(argc, argv, "as:br:", long_options,
|
||||||
&option_index);
|
&option_index);
|
||||||
if (c < 0)
|
if (c < 0)
|
||||||
break;
|
break;
|
||||||
@ -7739,6 +7742,9 @@ int cmd_check(int argc, char **argv)
|
|||||||
case 'E':
|
case 'E':
|
||||||
subvolid = arg_strtou64(optarg);
|
subvolid = arg_strtou64(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'r':
|
||||||
|
tree_root_bytenr = arg_strtou64(optarg);
|
||||||
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
case 'h':
|
case 'h':
|
||||||
usage(cmd_check_usage);
|
usage(cmd_check_usage);
|
||||||
@ -7782,7 +7788,8 @@ int cmd_check(int argc, char **argv)
|
|||||||
if (repair)
|
if (repair)
|
||||||
ctree_flags |= OPEN_CTREE_PARTIAL;
|
ctree_flags |= OPEN_CTREE_PARTIAL;
|
||||||
|
|
||||||
info = open_ctree_fs_info(argv[optind], bytenr, 0, ctree_flags);
|
info = open_ctree_fs_info(argv[optind], bytenr, tree_root_bytenr,
|
||||||
|
ctree_flags);
|
||||||
if (!info) {
|
if (!info) {
|
||||||
fprintf(stderr, "Couldn't open file system\n");
|
fprintf(stderr, "Couldn't open file system\n");
|
||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
|
Loading…
Reference in New Issue
Block a user