@@ -20,6 +20,11 @@
#include "descr.h"
#include "scrub_private.h"
+static int repair_epilogue(struct scrub_ctx *ctx, struct descr *dsc,
+ struct scrub_item *sri, unsigned int repair_flags,
+ struct xfs_scrub_metadata *oldm,
+ struct xfs_scrub_metadata *meta, int error);
+
/* General repair routines. */
/*
@@ -133,6 +138,22 @@ xfs_repair_metadata(
_("Attempting optimization."));
error = -xfrog_scrub_metadata(xfdp, &meta);
+ return repair_epilogue(ctx, &dsc, sri, repair_flags, &oldm, &meta,
+ error);
+}
+
+static int
+repair_epilogue(
+ struct scrub_ctx *ctx,
+ struct descr *dsc,
+ struct scrub_item *sri,
+ unsigned int repair_flags,
+ struct xfs_scrub_metadata *oldm,
+ struct xfs_scrub_metadata *meta,
+ int error)
+{
+ unsigned int scrub_type = meta->sm_type;
+
switch (error) {
case 0:
/* No operational errors encountered. */
@@ -141,12 +162,12 @@ xfs_repair_metadata(
case EBUSY:
/* Filesystem is busy, try again later. */
if (debug || verbose)
- str_info(ctx, descr_render(&dsc),
+ str_info(ctx, descr_render(dsc),
_("Filesystem is busy, deferring repair."));
return 0;
case ESHUTDOWN:
/* Filesystem is already shut down, abort. */
- str_error(ctx, descr_render(&dsc),
+ str_error(ctx, descr_render(dsc),
_("Filesystem is shut down, aborting."));
return ECANCELED;
case ENOTTY:
@@ -157,7 +178,7 @@ _("Filesystem is shut down, aborting."));
* how to perform the repair, don't requeue the request. Mark
* it done and move on.
*/
- if (is_unoptimized(&oldm) ||
+ if (is_unoptimized(oldm) ||
debug_tweak_on("XFS_SCRUB_FORCE_REPAIR")) {
scrub_item_clean_state(sri, scrub_type);
return 0;
@@ -175,14 +196,14 @@ _("Filesystem is shut down, aborting."));
fallthrough;
case EINVAL:
/* Kernel doesn't know how to repair this? */
- str_corrupt(ctx, descr_render(&dsc),
+ str_corrupt(ctx, descr_render(dsc),
_("Don't know how to fix; offline repair required."));
scrub_item_clean_state(sri, scrub_type);
return 0;
case EROFS:
/* Read-only filesystem, can't fix. */
- if (verbose || debug || needs_repair(&oldm))
- str_error(ctx, descr_render(&dsc),
+ if (verbose || debug || needs_repair(oldm))
+ str_error(ctx, descr_render(dsc),
_("Read-only filesystem; cannot make changes."));
return ECANCELED;
case ENOENT:
@@ -192,7 +213,7 @@ _("Read-only filesystem; cannot make changes."));
case ENOMEM:
case ENOSPC:
/* Don't care if preen fails due to low resources. */
- if (is_unoptimized(&oldm) && !needs_repair(&oldm)) {
+ if (is_unoptimized(oldm) && !needs_repair(oldm)) {
scrub_item_clean_state(sri, scrub_type);
return 0;
}
@@ -207,7 +228,7 @@ _("Read-only filesystem; cannot make changes."));
*/
if (!(repair_flags & XRM_FINAL_WARNING))
return 0;
- str_liberror(ctx, error, descr_render(&dsc));
+ str_liberror(ctx, error, descr_render(dsc));
scrub_item_clean_state(sri, scrub_type);
return 0;
}
@@ -218,12 +239,12 @@ _("Read-only filesystem; cannot make changes."));
* the repair again, just in case the fs was busy. Only retry so many
* times.
*/
- if (want_retry(&meta) && scrub_item_schedule_retry(sri, scrub_type))
+ if (want_retry(meta) && scrub_item_schedule_retry(sri, scrub_type))
return 0;
if (repair_flags & XRM_FINAL_WARNING)
- scrub_warn_incomplete_scrub(ctx, &dsc, &meta);
- if (needs_repair(&meta) || is_incomplete(&meta)) {
+ scrub_warn_incomplete_scrub(ctx, dsc, meta);
+ if (needs_repair(meta) || is_incomplete(meta)) {
/*
* Still broken; if we've been told not to complain then we
* just requeue this and try again later. Otherwise we
@@ -231,9 +252,9 @@ _("Read-only filesystem; cannot make changes."));
*/
if (!(repair_flags & XRM_FINAL_WARNING))
return 0;
- str_corrupt(ctx, descr_render(&dsc),
+ str_corrupt(ctx, descr_render(dsc),
_("Repair unsuccessful; offline repair required."));
- } else if (xref_failed(&meta)) {
+ } else if (xref_failed(meta)) {
/*
* This metadata object itself looks ok, but we still noticed
* inconsistencies when comparing it with the other filesystem
@@ -242,31 +263,31 @@ _("Repair unsuccessful; offline repair required."));
* reverify the cross-referencing as repairs progress.
*/
if (repair_flags & XRM_FINAL_WARNING) {
- str_info(ctx, descr_render(&dsc),
+ str_info(ctx, descr_render(dsc),
_("Seems correct but cross-referencing failed; offline repair recommended."));
} else {
if (verbose)
- str_info(ctx, descr_render(&dsc),
+ str_info(ctx, descr_render(dsc),
_("Seems correct but cross-referencing failed; will keep checking."));
return 0;
}
- } else if (meta.sm_flags & XFS_SCRUB_OFLAG_NO_REPAIR_NEEDED) {
+ } else if (meta->sm_flags & XFS_SCRUB_OFLAG_NO_REPAIR_NEEDED) {
if (verbose)
- str_info(ctx, descr_render(&dsc),
+ str_info(ctx, descr_render(dsc),
_("No modification needed."));
} else {
/* Clean operation, no corruption detected. */
- if (is_corrupt(&oldm))
- record_repair(ctx, descr_render(&dsc),
+ if (is_corrupt(oldm))
+ record_repair(ctx, descr_render(dsc),
_("Repairs successful."));
- else if (xref_disagrees(&oldm))
- record_repair(ctx, descr_render(&dsc),
+ else if (xref_disagrees(oldm))
+ record_repair(ctx, descr_render(dsc),
_("Repairs successful after discrepancy in cross-referencing."));
- else if (xref_failed(&oldm))
- record_repair(ctx, descr_render(&dsc),
+ else if (xref_failed(oldm))
+ record_repair(ctx, descr_render(dsc),
_("Repairs successful after cross-referencing failure."));
else
- record_preen(ctx, descr_render(&dsc),
+ record_preen(ctx, descr_render(dsc),
_("Optimization successful."));
}