From: Darrick J. Wong Date: Thu, 17 Oct 2019 02:35:25 +0000 (-0400) Subject: xfs_scrub: abort all read verification work immediately on error X-Git-Tag: v5.3.0-rc2~73 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4cd869e5a6af916d988795191804495d0e1e96cb;p=thirdparty%2Fxfsprogs-dev.git xfs_scrub: abort all read verification work immediately on error 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 Reviewed-by: Eric Sandeen Signed-off-by: Eric Sandeen --- diff --git a/scrub/phase6.c b/scrub/phase6.c index d9285feed..4c81ee7ba 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 d020ce2f2..835b96606 100644 --- a/scrub/read_verify.c +++ b/scrub/read_verify.c @@ -121,6 +121,16 @@ out_free: 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 5fabe5e04..f0ed89028 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);