From: Darrick J. Wong Date: Thu, 17 Oct 2019 02:35:26 +0000 (-0400) Subject: xfs_scrub: enforce read verify pool minimum io size X-Git-Tag: v5.3.0-rc2~67 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=29c4f385a701fb2c7f4a425e84b8e1f8a1c7e7a9;p=thirdparty%2Fxfsprogs-dev.git xfs_scrub: enforce read verify pool minimum io size Make sure we always issue media verification requests aligned to the minimum IO size that the caller cares about. Concretely, this means that we only care about doing IO in filesystem block-sized chunks. Signed-off-by: Darrick J. Wong Reviewed-by: Eric Sandeen Signed-off-by: Eric Sandeen --- diff --git a/scrub/read_verify.c b/scrub/read_verify.c index 9f78b79c5..231df8026 100644 --- a/scrub/read_verify.c +++ b/scrub/read_verify.c @@ -82,6 +82,15 @@ read_verify_pool_alloc( struct read_verify_pool *rvp; int ret; + /* + * The minimum IO size must be a multiple of the disk sector size + * and a factor of the max io size. + */ + if (miniosz % disk->d_lbasize) + return EINVAL; + if (RVP_IO_MAX_SIZE % miniosz) + return EINVAL; + rvp = calloc(1, sizeof(struct read_verify_pool)); if (!rvp) return errno; @@ -249,6 +258,11 @@ read_verify_schedule_io( int ret; assert(rvp->readbuf); + + /* Round up and down to the start of a miniosz chunk. */ + start &= ~(rvp->miniosz - 1); + length = roundup(length, rvp->miniosz); + rv = ptvar_get(rvp->rvstate, &ret); if (ret) return ret;