]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_scrub: enforce read verify pool minimum io size
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 17 Oct 2019 02:35:26 +0000 (22:35 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Thu, 17 Oct 2019 02:35:26 +0000 (22:35 -0400)
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 <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
scrub/read_verify.c

index 9f78b79c5f81c539f7464b4810d0f1751809b309..231df802668f3110b9a27d6351a963652ecc545c 100644 (file)
@@ -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;