@@ -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. */