]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_scrub: remove preen mode
authorDarrick J. Wong <darrick.wong@oracle.com>
Mon, 12 Feb 2018 21:47:40 +0000 (15:47 -0600)
committerEric Sandeen <sandeen@redhat.com>
Mon, 12 Feb 2018 21:47:40 +0000 (15:47 -0600)
While it's true that the kernel can tell us whether something needs
repairs or it needs optimizing, from the admin's perspective there's
no point in having an optimize-only mode -- either fix everything, or
don't.  This is what xfs_repair does w.r.t. -n, so let's do the same
thing too.

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>
man/man8/xfs_scrub.8
scrub/phase1.c
scrub/phase4.c
scrub/scrub.c
scrub/xfs_scrub.c
scrub/xfs_scrub.h

index 4c394a5f05c229dba6464404da30f89f6cb48a21..77fed92996ff6be99e7aa6eae9b919614846af17 100644 (file)
@@ -1,10 +1,10 @@
 .TH xfs_scrub 8
 .SH NAME
-xfs_scrub \- scrub the contents of an XFS filesystem
+xfs_scrub \- check the contents of a mounted XFS filesystem
 .SH SYNOPSIS
 .B xfs_scrub
 [
-.B \-abCemnTvxy
+.B \-abCemnTvx
 ]
 .RI "[" mount-point " | " block-device "]"
 .br
@@ -13,6 +13,12 @@ xfs_scrub \- scrub the contents of an XFS filesystem
 .B xfs_scrub
 attempts to check and repair all metadata in a mounted XFS filesystem.
 .PP
+.B WARNING!
+This program is
+.BR EXPERIMENTAL ","
+which means that its behavior and interface
+could change at any time!
+.PP
 .B xfs_scrub
 asks the kernel to scrub all metadata objects in the filesystem.
 Metadata records are scanned for obviously bad values and then
@@ -28,19 +34,17 @@ the standard error stream.
 Enabling verbose mode will increase the amount of status information
 sent to the output.
 .PP
-This utility does not know how to correct all errors.
-If the tool cannot fix the detected errors, you must unmount the
-filesystem and run
+If the kernel scrub reports that metadata needs repairs or optimizations and
+the user does not pass
+.B -n
+on the command line, this program will ask the kernel to make the repairs and
+to perform the optimizations.
+See the sections about optimizations and repairs for a list of optimizations
+and repairs known to this program.
+The kernel may not support repairing or optimizing the filesystem.
+If this is the case, the filesystem must be unmounted and
 .BR xfs_repair (8)
-to fix the problems.
-If this tool is not run with either of the
-.B \-n
-or
-.B \-y
-options, then it will optimize the filesystem when possible,
-but it will not try to fix errors.
-See the optimizations section below for a list of optimizations
-supported by this program.
+run on the filesystem to fix the problems.
 .SH OPTIONS
 .TP
 .BI \-a " errors"
@@ -73,14 +77,14 @@ is given, no action is taken if errors are found; this is the default
 behavior.
 .TP
 .B \-k
-Do not call FITRIM on the free space.
+Do not call TRIM on the free space.
 .TP
 .BI \-m " file"
 Search this file for mounted filesystems instead of /etc/mtab.
 .TP
 .B \-n
-Dry run, do not modify anything in the filesystem.
-This disables all optimization and repair behaviors.
+Only check filesystem metadata.
+Do not repair or optimize anything.
 .TP
 .BI \-T
 Print timing and memory usage information for each phase.
@@ -98,20 +102,11 @@ will issue O_DIRECT reads to the block device directly.
 If the block device is a SCSI disk, it will instead issue READ VERIFY commands
 directly to the disk.
 These actions will confirm that all file data blocks can be read from storage.
-.TP
-.B \-y
-Try to repair all filesystem errors.
-If the errors cannot be fixed online, then the filesystem must be taken
-offline for repair.
 .SH OPTIMIZATIONS
-Optimizations supported by this program include:
+Optimizations supported by this program include, but are not limited to:
 .IP \[bu] 2
-Updating secondary superblocks to match the primary superblock.
-.IP \[bu]
-Turning off shared block write checks for files that no longer share blocks.
-.IP \[bu]
 Instructing the underlying storage to discard unused extents via the
-.B FITRIM
+.B TRIM
 ioctl.
 .SH REPAIRS
 This program currently does not support making any repairs.
index 75da2960fbe4c38468201483cd5d816a1dc92f7f..af93d0f3cb1e9f3d48bfde6c1b018097b98ed798 100644 (file)
@@ -181,11 +181,7 @@ _("Kernel metadata scrubbing facility is not available."));
 
        /* Do we need kernel-assisted metadata repair? */
        if (ctx->mode != SCRUB_MODE_DRY_RUN && !xfs_can_repair(ctx)) {
-               if (ctx->mode == SCRUB_MODE_PREEN)
-                       str_error(ctx, ctx->mntpoint,
-_("Kernel metadata optimization facility is not available.  Use -n to scrub."));
-               else
-                       str_error(ctx, ctx->mntpoint,
+               str_error(ctx, ctx->mntpoint,
 _("Kernel metadata repair facility is not available.  Use -n to scrub."));
                return false;
        }
index 3100d75bc1eb6864742684553bdc16b57426222c..1fb8da9060fe6eac8e680f44c2483065c78c120e 100644 (file)
@@ -62,25 +62,6 @@ xfs_repair_fs(
        return xfs_process_action_items(ctx);
 }
 
-/* Run the optimize-only phase if there are no errors. */
-bool
-xfs_optimize_fs(
-       struct scrub_ctx        *ctx)
-{
-       /*
-        * In preen mode, corruptions are immediately recorded as errors,
-        * so if there are any corruptions on the filesystem errors_found
-        * will be non-zero and we won't do anything.
-        */
-       if (ctx->errors_found) {
-               str_info(ctx, ctx->mntpoint,
-_("Errors found, please re-run with -y."));
-               return true;
-       }
-
-       return xfs_process_action_items(ctx);
-}
-
 /* Estimate how much work we're going to do. */
 bool
 xfs_estimate_repair_work(
index 6abca2ac9d8763199fb5d36da62021acbd37d8a8..bc0e2f050263a2f2fcedd185a6121ec44577c6ad 100644 (file)
@@ -279,7 +279,7 @@ _("Repairs are required."));
         * otherwise complain.
         */
        if (is_unoptimized(meta)) {
-               if (ctx->mode < SCRUB_MODE_PREEN) {
+               if (ctx->mode != SCRUB_MODE_REPAIR) {
                        if (!is_inode) {
                                /* AG or FS metadata, always warn. */
                                str_info(ctx, buf,
index 5ab557de780ebb5cad3af16b1e50e2b900a38409..6efcf77e93cc62b4d85e2792830a732f072846cb 100644 (file)
@@ -187,7 +187,6 @@ usage(void)
        fprintf(stderr, _("  -v           Verbose output.\n"));
        fprintf(stderr, _("  -V           Print version.\n"));
        fprintf(stderr, _("  -x           Scrub file data too.\n"));
-       fprintf(stderr, _("  -y           Repair all errors.\n"));
 
        exit(SCRUB_RET_SYNTAX);
 }
@@ -441,16 +440,11 @@ run_scrub_phases(
                /* Turn on certain phases if user said to. */
                if (sp->fn == DATASCAN_DUMMY_FN && scrub_data) {
                        sp->fn = xfs_scan_blocks;
-               } else if (sp->fn == REPAIR_DUMMY_FN) {
-                       if (ctx->mode == SCRUB_MODE_PREEN) {
-                               sp->descr = _("Optimize filesystem.");
-                               sp->fn = xfs_optimize_fs;
-                               sp->must_run = true;
-                       } else if (ctx->mode == SCRUB_MODE_REPAIR) {
-                               sp->descr = _("Repair filesystem.");
-                               sp->fn = xfs_repair_fs;
-                               sp->must_run = true;
-                       }
+               } else if (sp->fn == REPAIR_DUMMY_FN &&
+                          ctx->mode == SCRUB_MODE_REPAIR) {
+                       sp->descr = _("Repair filesystem.");
+                       sp->fn = xfs_repair_fs;
+                       sp->must_run = true;
                }
 
                /* Skip certain phases unless they're turned on. */
@@ -524,9 +518,9 @@ main(
        textdomain(PACKAGE);
 
        pthread_mutex_init(&ctx.lock, NULL);
-       ctx.mode = SCRUB_MODE_DEFAULT;
+       ctx.mode = SCRUB_MODE_REPAIR;
        ctx.error_action = ERRORS_CONTINUE;
-       while ((c = getopt(argc, argv, "a:bC:de:km:nTvxVy")) != EOF) {
+       while ((c = getopt(argc, argv, "a:bC:de:km:nTvxV")) != EOF) {
                switch (c) {
                case 'a':
                        ctx.max_errors = cvt_u64(optarg, 10);
@@ -574,11 +568,6 @@ main(
                        mtab = optarg;
                        break;
                case 'n':
-                       if (ctx.mode != SCRUB_MODE_DEFAULT) {
-                               fprintf(stderr,
-_("Only one of the options -n or -y may be specified.\n"));
-                               usage();
-                       }
                        ctx.mode = SCRUB_MODE_DRY_RUN;
                        break;
                case 'T':
@@ -595,14 +584,6 @@ _("Only one of the options -n or -y may be specified.\n"));
                case 'x':
                        scrub_data = true;
                        break;
-               case 'y':
-                       if (ctx.mode != SCRUB_MODE_DEFAULT) {
-                               fprintf(stderr,
-_("Only one of the options -n or -y may be specified.\n"));
-                               usage();
-                       }
-                       ctx.mode = SCRUB_MODE_REPAIR;
-                       break;
                case '?':
                        /* fall through */
                default:
index 8407885da94446a14cb95fc2daf46019d7b6fd1b..89b46a4ffd94ba7f7bc9fe9ece5cac5bf54346c9 100644 (file)
@@ -34,10 +34,8 @@ extern bool                  stdout_isatty;
 
 enum scrub_mode {
        SCRUB_MODE_DRY_RUN,
-       SCRUB_MODE_PREEN,
        SCRUB_MODE_REPAIR,
 };
-#define SCRUB_MODE_DEFAULT                     SCRUB_MODE_PREEN
 
 enum error_action {
        ERRORS_CONTINUE,
@@ -111,7 +109,6 @@ bool xfs_scan_connections(struct scrub_ctx *ctx);
 bool xfs_scan_blocks(struct scrub_ctx *ctx);
 bool xfs_scan_summary(struct scrub_ctx *ctx);
 bool xfs_repair_fs(struct scrub_ctx *ctx);
-bool xfs_optimize_fs(struct scrub_ctx *ctx);
 
 /* Progress estimator functions */
 uint64_t xfs_estimate_inodes(struct scrub_ctx *ctx);