From: Darrick J. Wong <darrick.wong@xxxxxxxxxx> Add a new abort function to the read verify pool code so that the caller can immediately abort all pending verification work if things start going wrong. There's no point in waiting for queued work to run if we've already decided to bail. Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx> --- v2: fix errors_seen bogosity --- scrub/phase6.c | 6 +++--- scrub/read_verify.c | 10 ++++++++++ scrub/read_verify.h | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/scrub/phase6.c b/scrub/phase6.c index d9285fee..4c81ee7b 100644 --- a/scrub/phase6.c +++ b/scrub/phase6.c @@ -514,16 +514,16 @@ _("Could not create data device media verifier.")); out_rtpool: if (vs.rvp_realtime) { - read_verify_pool_flush(vs.rvp_realtime); + read_verify_pool_abort(vs.rvp_realtime); read_verify_pool_destroy(vs.rvp_realtime); } out_logpool: if (vs.rvp_log) { - read_verify_pool_flush(vs.rvp_log); + read_verify_pool_abort(vs.rvp_log); read_verify_pool_destroy(vs.rvp_log); } out_datapool: - read_verify_pool_flush(vs.rvp_data); + read_verify_pool_abort(vs.rvp_data); read_verify_pool_destroy(vs.rvp_data); out_rbad: bitmap_free(&vs.r_bad); diff --git a/scrub/read_verify.c b/scrub/read_verify.c index d020ce2f..835b9660 100644 --- a/scrub/read_verify.c +++ b/scrub/read_verify.c @@ -121,6 +121,16 @@ read_verify_pool_init( return NULL; } +/* Abort all verification work. */ +void +read_verify_pool_abort( + struct read_verify_pool *rvp) +{ + if (!rvp->runtime_error) + rvp->runtime_error = ECANCELED; + workqueue_terminate(&rvp->wq); +} + /* Finish up any read verification work. */ void read_verify_pool_flush( diff --git a/scrub/read_verify.h b/scrub/read_verify.h index 5fabe5e0..f0ed8902 100644 --- a/scrub/read_verify.h +++ b/scrub/read_verify.h @@ -19,6 +19,7 @@ struct read_verify_pool *read_verify_pool_init(struct scrub_ctx *ctx, struct disk *disk, size_t miniosz, read_verify_ioerr_fn_t ioerr_fn, unsigned int submitter_threads); +void read_verify_pool_abort(struct read_verify_pool *rvp); void read_verify_pool_flush(struct read_verify_pool *rvp); void read_verify_pool_destroy(struct read_verify_pool *rvp);