diff options
Diffstat (limited to 'qgroup-verify.c')
-rw-r--r-- | qgroup-verify.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/qgroup-verify.c b/qgroup-verify.c index 571b4d4f..e2332be2 100644 --- a/qgroup-verify.c +++ b/qgroup-verify.c @@ -622,7 +622,7 @@ static void free_tree_blocks(void) ULIST_ITER_INIT(&uiter); while ((unode = ulist_next(tree_blocks, &uiter))) free(unode_tree_block(unode)); - ulist_free(tree_blocks); + ulist_free(tree_blocks); tree_blocks = NULL; } @@ -1160,7 +1160,7 @@ static int scan_extents(struct btrfs_fs_info *info, fprintf(stderr, "ERROR: Couldn't search slot: %d\n", ret); goto out; } - path.reada = 1; + path.reada = READA_BACK; while (1) { leaf = path.nodes[0]; @@ -1298,10 +1298,19 @@ static int report_qgroup_difference(struct qgroup_count *count, int verbose) return is_different; } -void report_qgroups(int all) +/* + * Report qgroups errors + * Return 0 if nothing wrong. + * Return <0 if any qgroup is inconsistent. + * + * @all: if set, all qgroup will be checked and reported even already + * inconsistent or under rescan. + */ +int report_qgroups(int all) { struct rb_node *node; struct qgroup_count *c; + bool found_err = false; if (!repair && counts.rescan_running) { if (all) { @@ -1310,7 +1319,7 @@ void report_qgroups(int all) } else { printf( "Qgroup rescan is running, qgroups will not be printed.\n"); - return; + return 0; } } if (counts.qgroup_inconsist && !counts.rescan_running) @@ -1319,11 +1328,16 @@ void report_qgroups(int all) while (node) { c = rb_entry(node, struct qgroup_count, rb_node); - if (report_qgroup_difference(c, all)) + if (report_qgroup_difference(c, all)) { list_add_tail(&c->bad_list, &bad_qgroups); + found_err = true; + } node = rb_next(node); } + if (found_err) + return -EUCLEAN; + return 0; } void free_qgroup_counts(void) |