summaryrefslogtreecommitdiff
path: root/cmds-check.c
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fusionio.com>2013-10-23 16:24:03 -0400
committerChris Mason <chris.mason@fusionio.com>2013-11-07 13:29:30 -0500
commit337f86fea1d06e189f3cf234adba2567a07678bd (patch)
treec4fe5f392480000ffbf2419d2ba53568153e304a /cmds-check.c
parent4fc17596aaa2b03ee38c467585465923d62b1510 (diff)
Btrfs-progs: add -b to btrfsck to look at backup roots
In some cases the tree root is so hosed we can't get anything useful out of it. So add the -b option to btrfsck to make us look for the most recent backup tree root to use for repair. Then we can hopefully get ourselves into a working state. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'cmds-check.c')
-rw-r--r--cmds-check.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/cmds-check.c b/cmds-check.c
index 668af158..3453cac2 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -6022,6 +6022,7 @@ static struct option long_options[] = {
{ "repair", 0, NULL, 0 },
{ "init-csum-tree", 0, NULL, 0 },
{ "init-extent-tree", 0, NULL, 0 },
+ { "backup", 0, NULL, 0 },
{ NULL, 0, NULL, 0}
};
@@ -6030,6 +6031,7 @@ const char * const cmd_check_usage[] = {
"Check an unmounted btrfs filesystem.",
"",
"-s|--super <superblock> use this superblock copy",
+ "-b|--backup use the backup root copy",
"--repair try to repair the filesystem",
"--init-csum-tree create a new CRC tree",
"--init-extent-tree create a new extent tree",
@@ -6043,6 +6045,7 @@ int cmd_check(int argc, char **argv)
struct btrfs_fs_info *info;
u64 bytenr = 0;
char uuidbuf[37];
+ int backup_root = 0;
int ret;
int num;
int option_index = 0;
@@ -6052,12 +6055,15 @@ int cmd_check(int argc, char **argv)
while(1) {
int c;
- c = getopt_long(argc, argv, "as:", long_options,
+ c = getopt_long(argc, argv, "as:b", long_options,
&option_index);
if (c < 0)
break;
switch(c) {
case 'a': /* ignored */ break;
+ case 'b':
+ backup_root = 1;
+ break;
case 's':
num = atol(optarg);
bytenr = btrfs_sb_offset(num);
@@ -6099,7 +6105,7 @@ int cmd_check(int argc, char **argv)
return -EBUSY;
}
- info = open_ctree_fs_info(argv[optind], bytenr, 0, rw, 1);
+ info = open_ctree_fs_info(argv[optind], bytenr, 0, rw, 1, backup_root);
if (!info) {
fprintf(stderr, "Couldn't open file system\n");
return -EIO;