qemu-img check: Print fixed clusters and recheck
When any inconsistencies have been fixed, print the statistics and run another check to make sure everything is correct now. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
4534ff5426
commit
ccf34716ee
2
block.h
2
block.h
@ -187,6 +187,8 @@ typedef struct BdrvCheckResult {
|
|||||||
int corruptions;
|
int corruptions;
|
||||||
int leaks;
|
int leaks;
|
||||||
int check_errors;
|
int check_errors;
|
||||||
|
int corruptions_fixed;
|
||||||
|
int leaks_fixed;
|
||||||
BlockFragInfo bfi;
|
BlockFragInfo bfi;
|
||||||
} BdrvCheckResult;
|
} BdrvCheckResult;
|
||||||
|
|
||||||
|
@ -87,6 +87,7 @@ static unsigned int qed_check_l2_table(QEDCheck *check, QEDTable *table)
|
|||||||
if (!qed_check_cluster_offset(s, offset)) {
|
if (!qed_check_cluster_offset(s, offset)) {
|
||||||
if (check->fix) {
|
if (check->fix) {
|
||||||
table->offsets[i] = 0;
|
table->offsets[i] = 0;
|
||||||
|
check->result->corruptions_fixed++;
|
||||||
} else {
|
} else {
|
||||||
check->result->corruptions++;
|
check->result->corruptions++;
|
||||||
}
|
}
|
||||||
@ -127,6 +128,7 @@ static int qed_check_l1_table(QEDCheck *check, QEDTable *table)
|
|||||||
/* Clear invalid offset */
|
/* Clear invalid offset */
|
||||||
if (check->fix) {
|
if (check->fix) {
|
||||||
table->offsets[i] = 0;
|
table->offsets[i] = 0;
|
||||||
|
check->result->corruptions_fixed++;
|
||||||
} else {
|
} else {
|
||||||
check->result->corruptions++;
|
check->result->corruptions++;
|
||||||
}
|
}
|
||||||
|
10
qemu-img.c
10
qemu-img.c
@ -425,6 +425,16 @@ static int img_check(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (result.corruptions_fixed || result.leaks_fixed) {
|
||||||
|
printf("The following inconsistencies were found and repaired:\n\n"
|
||||||
|
" %d leaked clusters\n"
|
||||||
|
" %d corruptions\n\n"
|
||||||
|
"Double checking the fixed image now...\n",
|
||||||
|
result.leaks_fixed,
|
||||||
|
result.corruptions_fixed);
|
||||||
|
ret = bdrv_check(bs, &result, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (!(result.corruptions || result.leaks || result.check_errors)) {
|
if (!(result.corruptions || result.leaks || result.check_errors)) {
|
||||||
printf("No errors were found on the image.\n");
|
printf("No errors were found on the image.\n");
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user