From: Darrick J. Wong <djwong@xxxxxxxxxx> If the user told us to skip trimming the filesystem, don't run the phase at all. Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx> Reviewed-by: Christoph Hellwig <hch@xxxxxx> --- scrub/xfs_scrub.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scrub/xfs_scrub.c b/scrub/xfs_scrub.c index e49538ca1..edf58d07b 100644 --- a/scrub/xfs_scrub.c +++ b/scrub/xfs_scrub.c @@ -249,6 +249,7 @@ struct phase_rusage { /* Operations for each phase. */ #define DATASCAN_DUMMY_FN ((void *)1) #define REPAIR_DUMMY_FN ((void *)2) +#define FSTRIM_DUMMY_FN ((void *)3) struct phase_ops { char *descr; int (*fn)(struct scrub_ctx *ctx); @@ -429,6 +430,11 @@ run_scrub_phases( .fn = phase7_func, .must_run = true, }, + { + .descr = _("Trim filesystem storage."), + .fn = FSTRIM_DUMMY_FN, + .estimate_work = phase8_estimate, + }, { NULL }, @@ -449,6 +455,8 @@ run_scrub_phases( /* Turn on certain phases if user said to. */ if (sp->fn == DATASCAN_DUMMY_FN && scrub_data) { sp->fn = phase6_func; + } else if (sp->fn == FSTRIM_DUMMY_FN && want_fstrim) { + sp->fn = phase8_func; } else if (sp->fn == REPAIR_DUMMY_FN && ctx->mode == SCRUB_MODE_REPAIR) { sp->descr = _("Repair filesystem."); @@ -458,7 +466,8 @@ run_scrub_phases( /* Skip certain phases unless they're turned on. */ if (sp->fn == REPAIR_DUMMY_FN || - sp->fn == DATASCAN_DUMMY_FN) + sp->fn == DATASCAN_DUMMY_FN || + sp->fn == FSTRIM_DUMMY_FN) continue; /* Allow debug users to force a particular phase. */