diff options
author | Josef Bacik <jbacik@fb.com> | 2014-10-31 14:01:28 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2014-11-14 11:01:38 +0100 |
commit | e4e7058173330e30d9ebfa2c8d779454af653e59 (patch) | |
tree | a023f51f09b690af0d42f98d7b0017633b8c7d67 | |
parent | 9151febadd796ee0c8b7c3f9a73e7d6613186c7e (diff) |
Btrfs-progs: create missing root dirid
If we just don't have the root dirid stuff go ahead and re-create it, since it
is easily recreated. Thanks,
Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
-rw-r--r-- | cmds-check.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/cmds-check.c b/cmds-check.c index 79149838..389674f8 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -1987,6 +1987,26 @@ static int check_inode_recs(struct btrfs_root *root, error++; } } else { + if (repair) { + struct btrfs_trans_handle *trans; + + trans = btrfs_start_transaction(root, 1); + if (IS_ERR(trans)) { + err = PTR_ERR(trans); + return err; + } + + fprintf(stderr, + "root %llu missing its root dir, recreating\n", + (unsigned long long)root->objectid); + + ret = btrfs_make_root_dir(trans, root, root_dirid); + BUG_ON(ret); + + btrfs_commit_transaction(trans, root); + return -EAGAIN; + } + fprintf(stderr, "root %llu root dir %llu not found\n", (unsigned long long)root->root_key.objectid, (unsigned long long)root_dirid); |