summaryrefslogtreecommitdiff
path: root/cmds-check.c
diff options
context:
space:
mode:
authorWang Shilong <wangsl.fnst@cn.fujitsu.com>2014-05-29 17:59:56 +0800
committerDavid Sterba <dsterba@suse.cz>2014-10-10 18:11:32 +0200
commit8d2abcb6cc50762536fe04c50bf262f1ccf3b9a3 (patch)
treef8fd847f82c2ef4663783758c0ebceab7555979e /cmds-check.c
parent31aa2b5fa7fad6b4bc382b9e40d5b44f856a3f53 (diff)
Btrfs-progs: fsck: only allow partial opening under repair mode
The reason that we allow partial opening is that sometimes, we may have some corrupted trees.(for example extent tree), for fsck repair case, the broken tree may be rebuilt later. So if users only want to do check but not repair anything, this patch will make fsck return failure as soon as possible and tell users that some critial roots have been corrupted. Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'cmds-check.c')
-rw-r--r--cmds-check.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/cmds-check.c b/cmds-check.c
index a1d5a557..7c5cfbb1 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -6821,8 +6821,7 @@ int cmd_check(int argc, char **argv)
int option_index = 0;
int init_csum_tree = 0;
int qgroup_report = 0;
- enum btrfs_open_ctree_flags ctree_flags =
- OPEN_CTREE_PARTIAL | OPEN_CTREE_EXCLUSIVE;
+ enum btrfs_open_ctree_flags ctree_flags = OPEN_CTREE_EXCLUSIVE;
while(1) {
int c;
@@ -6892,6 +6891,10 @@ int cmd_check(int argc, char **argv)
goto err_out;
}
+ /* only allow partial opening under repair mode */
+ if (repair)
+ ctree_flags |= OPEN_CTREE_PARTIAL;
+
info = open_ctree_fs_info(argv[optind], bytenr, 0, ctree_flags);
if (!info) {
fprintf(stderr, "Couldn't open file system\n");