From: Wang Shilong Date: Thu, 29 May 2014 09:59:56 +0000 (+0800) Subject: Btrfs-progs: fsck: only allow partial opening under repair mode X-Git-Tag: upstream/4.16.1~2665 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8d2abcb6cc50762536fe04c50bf262f1ccf3b9a3;p=platform%2Fupstream%2Fbtrfs-progs.git 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 Signed-off-by: David Sterba --- diff --git a/cmds-check.c b/cmds-check.c index a1d5a55..7c5cfbb 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");