@@ -167,8 +167,11 @@ progress_end_phase(void)
pt.fp = NULL;
}
-/* Set ourselves up to report progress. */
-bool
+/*
+ * Set ourselves up to report progress. If errors are encountered, this
+ * function will log them and return nonzero.
+ */
+int
progress_init_phase(
struct scrub_ctx *ctx,
FILE *fp,
@@ -182,7 +185,7 @@ progress_init_phase(
assert(pt.fp == NULL);
if (fp == NULL || max == 0) {
pt.fp = NULL;
- return true;
+ return 0;
}
pt.fp = fp;
pt.isatty = isatty(fileno(fp));
@@ -205,7 +208,7 @@ progress_init_phase(
goto out_ptcounter;
}
- return true;
+ return 0;
out_ptcounter:
ptcounter_free(pt.ptc);
@@ -213,5 +216,5 @@ progress_init_phase(
out_max:
pt.max = 0;
pt.fp = NULL;
- return false;
+ return ret;
}
@@ -10,7 +10,7 @@
#define START_IGNORE '\001'
#define END_IGNORE '\002'
-bool progress_init_phase(struct scrub_ctx *ctx, FILE *progress_fp,
+int progress_init_phase(struct scrub_ctx *ctx, FILE *progress_fp,
unsigned int phase, uint64_t max, int rshift,
unsigned int nr_threads);
void progress_end_phase(void);
@@ -423,6 +423,7 @@ run_scrub_phases(
unsigned int debug_phase = 0;
unsigned int phase;
int rshift;
+ int ret;
if (debug_tweak_on("XFS_SCRUB_PHASE"))
debug_phase = atoi(getenv("XFS_SCRUB_PHASE"));
@@ -468,15 +469,19 @@ run_scrub_phases(
* whatever other per-thread data we need to allocate.
*/
work_threads++;
- moveon = progress_init_phase(ctx, progress_fp, phase,
+ ret = progress_init_phase(ctx, progress_fp, phase,
max_work, rshift, work_threads);
- if (!moveon)
+ if (ret) {
+ moveon = false;
break;
+ }
moveon = descr_init_phase(ctx, work_threads) == 0;
} else {
- moveon = progress_init_phase(ctx, NULL, phase, 0, 0, 0);
- if (!moveon)
+ ret = progress_init_phase(ctx, NULL, phase, 0, 0, 0);
+ if (ret) {
+ moveon = false;
break;
+ }
moveon = descr_init_phase(ctx, 1) == 0;
}
if (!moveon)