[v2,1/4] Btrfs-progs: fsck: only allow partial opening under repair mode
diff mbox

Message ID 1401357597-9494-1-git-send-email-wangsl.fnst@cn.fujitsu.com
State Accepted
Delegated to: David Sterba
Headers show

Commit Message

Wang Shilong May 29, 2014, 9:59 a.m. UTC
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>
---
v1->v2: add necessary changelog.(Thanks to Eric)
---
 cmds-check.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

David Sterba June 2, 2014, 4:18 p.m. UTC | #1
On Thu, May 29, 2014 at 05:59:56PM +0800, Wang Shilong wrote:
> 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.

Ok, that partially answers my question under v1. This would be a
different mode, eg. a fast check, that would bail out quickly as you
intend. I'd really want to keep the (full) check and repair to do the
same sort of checks and verification.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Wang Shilong June 3, 2014, 3:35 a.m. UTC | #2
On 06/03/2014 12:18 AM, David Sterba wrote:
> On Thu, May 29, 2014 at 05:59:56PM +0800, Wang Shilong wrote:
>> 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.
> Ok, that partially answers my question under v1. This would be a
> different mode, eg. a fast check, that would bail out quickly as you
> intend. I'd really want to keep the (full) check and repair to do the
Mm...That is reasonable too..

Acutally, now fsck would bail out if if found some errors. For example
if we fail to check csum tree, it won't check fs root.

I don't have ideas that whether fsck should continue if error happen,
for example, logic error, enomem....

> same sort of checks and verification.
>

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/cmds-check.c b/cmds-check.c
index db7df80..0e4e042 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -6810,8 +6810,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;
@@ -6877,6 +6876,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");