]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_scrub: explicitly track corruptions, not just errors
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 1 Nov 2019 21:55:06 +0000 (17:55 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Fri, 1 Nov 2019 21:55:06 +0000 (17:55 -0400)
Rename the @errors_found variable to @corruptions_found to make it
more explicit that we're tracking fs corruption issues.  Add a new
str_corrupt() function to handle communications that fall under this new
corruption classification.  str_error() now exists to log runtime errors
that do not have an associated errno code.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
scrub/common.c
scrub/common.h
scrub/phase4.c
scrub/phase5.c
scrub/phase6.c
scrub/scrub.c
scrub/xfs_scrub.c
scrub/xfs_scrub.h

index 8bd1984896600b036f9168a08bd7dae15a4e9b6c..26756c58019d1f6bf38ce52d7ca1aba8c350cfb3 100644 (file)
@@ -36,7 +36,7 @@ xfs_scrub_excessive_errors(
        bool                    ret;
 
        pthread_mutex_lock(&ctx->lock);
-       ret = ctx->max_errors > 0 && ctx->errors_found >= ctx->max_errors;
+       ret = ctx->max_errors > 0 && ctx->corruptions_found >= ctx->max_errors;
        pthread_mutex_unlock(&ctx->lock);
 
        return ret;
@@ -50,6 +50,10 @@ static struct {
                .string = "Error",
                .loglevel = LOG_ERR,
        },
+       [S_CORRUPT] = {
+               .string = "Corruption",
+               .loglevel = LOG_ERR,
+       },
        [S_WARN]   = {
                .string = "Warning",
                .loglevel = LOG_WARNING,
@@ -121,10 +125,10 @@ __str_out(
                fflush(stream);
 
 out_record:
-       if (error)      /* A syscall failed */
+       if (error || level == S_ERROR)      /* A syscall failed */
                ctx->runtime_errors++;
-       else if (level == S_ERROR)
-               ctx->errors_found++;
+       else if (level == S_CORRUPT)
+               ctx->corruptions_found++;
        else if (level == S_WARN)
                ctx->warnings_found++;
        else if (level == S_REPAIR)
index ef4cf439d8064a81a320ef0dc0ea1f3283b19cb3..b1f2ea2cba2ebe415bb75765dff00d0c75e99279 100644 (file)
@@ -17,6 +17,7 @@ bool xfs_scrub_excessive_errors(struct scrub_ctx *ctx);
 
 enum error_level {
        S_ERROR = 0,
+       S_CORRUPT,
        S_WARN,
        S_INFO,
        S_REPAIR,
@@ -30,6 +31,8 @@ void __str_out(struct scrub_ctx *ctx, const char *descr, enum error_level level,
        __str_out(ctx, str, S_ERROR,    errno,  __FILE__, __LINE__, NULL)
 #define str_liberror(ctx, error, str) \
        __str_out(ctx, str, S_ERROR,    error,  __FILE__, __LINE__, NULL)
+#define str_corrupt(ctx, str, ...) \
+       __str_out(ctx, str, S_CORRUPT,  0,      __FILE__, __LINE__, __VA_ARGS__)
 #define str_error(ctx, str, ...) \
        __str_out(ctx, str, S_ERROR,    0,      __FILE__, __LINE__, __VA_ARGS__)
 #define str_warn(ctx, str, ...) \
index eb30c189756e900621836cb335ff3234784519f6..1cf3f6b7be45dffcb83eff37340672a358868197 100644 (file)
@@ -99,7 +99,7 @@ xfs_process_action_items(
        workqueue_destroy(&wq);
 
        pthread_mutex_lock(&ctx->lock);
-       if (moveon && ctx->errors_found == 0 && want_fstrim) {
+       if (moveon && ctx->corruptions_found == 0 && want_fstrim) {
                fstrim(ctx);
                progress_add(1);
        }
index 279419071b6e19e1c36a141551685cf28d311ec9..dc0ee5e88440b9530638e781c1ed36809128048c 100644 (file)
@@ -336,7 +336,7 @@ xfs_scan_connections(
        bool                    moveon = true;
        bool                    ret;
 
-       if (ctx->errors_found) {
+       if (ctx->corruptions_found) {
                str_info(ctx, ctx->mntpoint,
 _("Filesystem has errors, skipping connectivity checks."));
                return true;
index fccd18e9dc470e30749d5e519479a312c7b66946..bb159641aab8aea3b0fa7c51e6571406cd094f98 100644 (file)
@@ -233,7 +233,7 @@ _("found unexpected realtime attr fork extent."));
        }
 
        if (bitmap_test(bmp, bmap->bm_physical, bmap->bm_length))
-               str_error(ctx, descr,
+               str_corrupt(ctx, descr,
 _("media error in extended attribute data."));
 
        return true;
@@ -389,7 +389,7 @@ report_ioerr_fsmap(
                snprintf(buf, DESCR_BUFSZ, _("disk offset %"PRIu64),
                                (uint64_t)map->fmr_physical + err_off);
                type = xfs_decode_special_owner(map->fmr_owner);
-               str_error(ctx, buf, _("media error in %s."), type);
+               str_corrupt(ctx, buf, _("media error in %s."), type);
        }
 
        /* Report extent maps */
@@ -400,7 +400,7 @@ report_ioerr_fsmap(
                                map->fmr_owner, 0, " %s",
                                attr ? _("extended attribute") :
                                       _("file data"));
-               str_error(ctx, buf, _("media error in extent map"));
+               str_corrupt(ctx, buf, _("media error in extent map"));
        }
 
        /*
index 0293ce30602753cb9c25d827b9cb558e817a9e35..75a64efa9eec01db96dd7c3a913dbca2004b34da 100644 (file)
@@ -188,7 +188,7 @@ _("Kernel bug!  errno=%d"), code);
         */
        if (is_corrupt(meta) || xref_disagrees(meta)) {
                if (ctx->mode < SCRUB_MODE_REPAIR) {
-                       str_error(ctx, buf,
+                       str_corrupt(ctx, buf,
 _("Repairs are required."));
                        return CHECK_DONE;
                }
@@ -727,7 +727,7 @@ _("Filesystem is shut down, aborting."));
                        /* fall through */
                case EINVAL:
                        /* Kernel doesn't know how to repair this? */
-                       str_error(ctx, buf,
+                       str_corrupt(ctx, buf,
 _("Don't know how to fix; offline repair required."));
                        return CHECK_DONE;
                case EROFS:
@@ -768,7 +768,7 @@ _("Read-only filesystem; cannot make changes."));
                 */
                if (!(repair_flags & XRM_COMPLAIN_IF_UNFIXED))
                        return CHECK_RETRY;
-               str_error(ctx, buf,
+               str_corrupt(ctx, buf,
 _("Repair unsuccessful; offline repair required."));
        } else {
                /* Clean operation, no corruption detected. */
index c730569450150b28a6621e6dd6332988ac103483..222daae15f3b170ef8fa45e7b1eb725873e28efa 100644 (file)
@@ -513,17 +513,25 @@ report_outcome(
 {
        unsigned long long      total_errors;
 
-       total_errors = ctx->errors_found + ctx->runtime_errors;
+       total_errors = ctx->corruptions_found + ctx->runtime_errors;
 
        if (total_errors == 0 && ctx->warnings_found == 0) {
                log_info(ctx, _("No problems found."));
                return;
        }
 
-       if (total_errors > 0) {
-               fprintf(stderr, _("%s: errors found: %llu\n"), ctx->mntpoint,
-                               total_errors);
-               log_err(ctx, _("errors found: %llu"), total_errors);
+       if (ctx->corruptions_found > 0) {
+               fprintf(stderr, _("%s: corruptions found: %llu\n"),
+                               ctx->mntpoint, ctx->corruptions_found);
+               log_err(ctx, _("corruptions found: %llu"),
+                               ctx->corruptions_found);
+       }
+
+       if (ctx->runtime_errors > 0) {
+               fprintf(stderr, _("%s: operational errors found: %llu\n"),
+                               ctx->mntpoint, ctx->runtime_errors);
+               log_err(ctx, _("operational errors found: %llu"),
+                               ctx->runtime_errors);
        }
 
        if (ctx->warnings_found > 0) {
@@ -745,7 +753,7 @@ out:
        report_modifications(&ctx);
        report_outcome(&ctx);
 
-       if (ctx.errors_found) {
+       if (ctx.corruptions_found) {
                if (ctx.error_action == ERRORS_SHUTDOWN)
                        xfs_shutdown_fs(&ctx);
                ret |= SCRUB_RET_CORRUPT;
index 37d78f61f687c751e29979439efeaf4c903e98f5..5abc41fd60ed67cee7061b9b3689579a5568df2d 100644 (file)
@@ -73,7 +73,7 @@ struct scrub_ctx {
        struct xfs_action_list  *action_lists;
        unsigned long long      max_errors;
        unsigned long long      runtime_errors;
-       unsigned long long      errors_found;
+       unsigned long long      corruptions_found;
        unsigned long long      warnings_found;
        unsigned long long      inodes_checked;
        unsigned long long      bytes_checked;