From da422967d4936bac6d191be5f734cb45c336ea24 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 17 Dec 2015 09:26:05 -0800 Subject: [PATCH] Fix zfs_vdev_aggregation_limit bounds checking Update the bounds checking for zfs_vdev_aggregation_limit so that it has a floor of zero and a maximum value of the supported block size for the pool. Additionally add an early return when zfs_vdev_aggregation_limit equals zero to disable aggregation. For very fast solid state or memory devices it may be more expensive to perform the aggregation than to issue the IO immediately. Signed-off-by: Brian Behlendorf Requires-spl: refs/pull/515/head --- module/zfs/vdev_queue.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/module/zfs/vdev_queue.c b/module/zfs/vdev_queue.c index 0c62a6fa3c7d..f1e0d9605027 100644 --- a/module/zfs/vdev_queue.c +++ b/module/zfs/vdev_queue.c @@ -504,15 +504,12 @@ vdev_queue_aggregate(vdev_queue_t *vq, zio_t *zio) enum zio_flag flags = zio->io_flags & ZIO_FLAG_AGG_INHERIT; void *buf; - if (zio->io_flags & ZIO_FLAG_DONT_AGGREGATE) - return (NULL); + zfs_vdev_aggregation_limit = MAX(MIN(zfs_vdev_aggregation_limit, + spa_maxblocksize(vq->vq_vdev->vdev_spa)), 0); - /* - * Prevent users from setting the zfs_vdev_aggregation_limit - * tuning larger than SPA_MAXBLOCKSIZE. - */ - zfs_vdev_aggregation_limit = - MIN(zfs_vdev_aggregation_limit, SPA_MAXBLOCKSIZE); + if (zio->io_flags & ZIO_FLAG_DONT_AGGREGATE || + zfs_vdev_aggregation_limit == 0) + return (NULL); first = last = zio;