@@ -21,23 +21,35 @@
/* Phase 8: Trim filesystem. */
-/* Trim the filesystem, if desired. */
-int
-phase8_func(
+static inline bool
+fstrim_ok(
struct scrub_ctx *ctx)
{
- if (action_list_empty(ctx->fs_repair_list) &&
- action_list_empty(ctx->file_repair_list))
- goto maybe_trim;
-
/*
* If errors remain on the filesystem, do not trim anything. We don't
* have any threads running, so it's ok to skip the ctx lock here.
*/
- if (ctx->corruptions_found || ctx->unfixable_errors != 0)
+ if (!action_list_empty(ctx->fs_repair_list))
+ return false;
+ if (!action_list_empty(ctx->file_repair_list))
+ return false;
+
+ if (ctx->corruptions_found != 0)
+ return false;
+ if (ctx->unfixable_errors != 0)
+ return false;
+
+ return true;
+}
+
+/* Trim the filesystem, if desired. */
+int
+phase8_func(
+ struct scrub_ctx *ctx)
+{
+ if (!fstrim_ok(ctx))
return 0;
-maybe_trim:
fstrim(ctx);
progress_add(1);
return 0;
@@ -51,7 +63,11 @@ phase8_estimate(
unsigned int *nr_threads,
int *rshift)
{
- *items = 1;
+ *items = 0;
+
+ if (fstrim_ok(ctx))
+ *items = 1;
+
*nr_threads = 1;
*rshift = 0;
return 0;