block: add blk_limits_io_min() and stack io_opt
Subsystems (2)
RFC PATCH 1/2 block: add blk_limits_io_min() and stack io_opt
Introduce blk_limits_io_min() and make blk_queue_io_min() call it.
blk_stack_limits() doesn't stack io_opt and DM needs it to.
--- block/blk-settings.c | 32 +++++++++++++++++++++++++------- include/linux/blkdev.h | 1 + 2 files changed, 26 insertions(+), 7 deletions(-)
block/blk-settings.c +25 -7
@@ -377,6 +377,29 @@EXPORT_SYMBOL (blk_queue_alignment_offset);/** +* blk_limits_io_min - set minimum request size for a device +* @limits: the queue limits +* @min: smallest I/O size in bytes +* +* Description: +* Some devices have an internal block size bigger than the reported +* hardware sector size. This function can be used to signal the +* smallest I/O the device can perform without incurring a performance +* penalty. +*/ +void blk_limits_io_min (struct queue_limits *limits,unsigned int min) +{ + limits->io_min = min; + +if (limits->io_min < limits->logical_block_size) + limits->io_min = limits->logical_block_size; + +if (limits->io_min < limits->physical_block_size) + limits->io_min = limits->physical_block_size; +} +EXPORT_SYMBOL (blk_limits_io_min); + +/** * blk_queue_io_min - set minimum request size for the queue * @q: the request queue for the device * @min: smallest I/O size in bytes
@@ -389,13 +412,7 @@*/ void blk_queue_io_min (struct request_queue *q,unsigned int min) { - q->limits.io_min = min; - -if (q->limits.io_min < q->limits.logical_block_size) - q->limits.io_min = q->limits.logical_block_size; - -if (q->limits.io_min < q->limits.physical_block_size) - q->limits.io_min = q->limits.physical_block_size; +blk_limits_io_min (&q->limits, min); }EXPORT_SYMBOL (blk_queue_io_min);
@@ -496,6 +513,7 @@ b->physical_block_size); t->io_min =max (t->io_min, b->io_min); + t->io_opt =min_not_zero (t->io_opt, b->io_opt); t->no_cluster |= b->no_cluster;/* Bottom device offset aligned? */
include/linux/blkdev.h +1 -0
@@ -924,6 +924,7 @@extern void blk_queue_physical_block_size (struct request_queue *,unsigned short );extern void blk_queue_alignment_offset (struct request_queue *q,unsigned int alignment); +extern void blk_limits_io_min (struct queue_limits *limits,unsigned int min);extern void blk_queue_io_min (struct request_queue *q,unsigned int min);extern void blk_queue_io_opt (struct request_queue *q,unsigned int opt);extern void blk_set_default_limits (struct queue_limits *lim);
RFC PATCH 2/2 properly expose dm-stripe target's I/O hints
Add .io_hints to 'struct target_type' to allow the I/O hints portion of the 'struct queue_limits' to be set in dm-stripe target.
--- drivers/md/dm-stripe.c | 11 +++++++++++ drivers/md/dm-table.c | 4 ++++ include/linux/device-mapper.h | 4 ++++ 3 files changed, 19 insertions(+)
drivers/md/dm-stripe.c +11 -0
@@ -328,6 +328,16 @@return ret; } +static void stripe_io_hints (struct dm_target *ti, +struct queue_limits *limits) +{ +struct stripe_c *sc = ti->private; +unsigned chunk_size = (sc->chunk_mask +1 ) <<9 ; + +blk_limits_io_min (chunk_size); + limits->io_opt = chunk_size * sc->stripes; +} +static struct target_type stripe_target = { .name ="striped" , .version = {1 ,2 ,0 },
@@ -338,6 +348,7 @@ .end_io = stripe_end_io, .status = stripe_status, .iterate_devices = stripe_iterate_devices, + .io_hints = stripe_io_hints, };int __init dm_stripe_init (void )
drivers/md/dm-table.c +4 -0
@@ -1001,6 +1001,10 @@ ti->type->iterate_devices (ti, dm_set_device_limits, &ti_limits); +/* Set I/O hints portion of queue limits */ +if (ti->type->io_hints) + ti->type->io_hints (ti, &ti_limits); +/* * Check each device area is consistent with the target's * overall queue limits.
include/linux/device-mapper.h +4 -0
@@ -91,6 +91,9 @@iterate_devices_callout_fn fn, void *data); +typedef void (*dm_io_hints_fn ) (struct dm_target *ti, +struct queue_limits *limits); +/* * Returns: * 0: The target can handle the next I/O immediately.
@@ -151,6 +154,7 @@dm_merge_fn merge;dm_busy_fn busy;dm_iterate_devices_fn iterate_devices; +dm_io_hints_fn io_hints;/* For internal device-mapper use. */ struct list_head list;