[dm-devel] [PATCH] dm: Devices not having .iterate_devices may want to set max_io_len

Kirill Tkhai ktkhai at virtuozzo.com
Wed Nov 25 20:49:25 UTC 2020


After commit 5091cdec56fa "dm: change max_io_len() to use
blk_max_size_offset()" my out-of-tree driver stopped to work.
The reason is that now ti->max_io_len from such target is ignored:
max_io_len() ignores ti->max_io_len, while
dm_calculate_queue_limits() never stacks ti->chunk_sectors into
ti_limits.chunk_sectors.

Here I see two possible solutions, both are in dm_calculate_queue_limits():

1)Move ti_limits.chunk_sectors assignment down, so it will be made
right under combine_limits label. Thus, every time ti->max_io_len
will transform into chunk_sectors, even in case of device
has no .iterate_devices method;

2)Move io_hints call under the label (like it's made in this patch),
so one can set desired chunk_sectors there.

First solution looks less clear, since in two drivers chunk_sectors
are assigned in io_hints (see unstripe_io_hints() and dmz_io_hints()),
and this rewrites, and we should not rewrite it.

Second solution does not break anything since we change only
order with ->iterate_devices(device_area_is_invalid), while
device_area_is_invalid never touches chunk_sectors. So I choosed it.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/md/dm-table.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 2073ee8d18f4..9994c767dc82 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -1453,10 +1453,6 @@ int dm_calculate_queue_limits(struct dm_table *table,
 		if (ti->max_io_len)
 			ti_limits.chunk_sectors = lcm_not_zero(ti->max_io_len,
 							       ti_limits.chunk_sectors);
-		/* 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.
@@ -1466,6 +1462,10 @@ int dm_calculate_queue_limits(struct dm_table *table,
 			return -EINVAL;
 
 combine_limits:
+		/* Set I/O hints portion of queue limits */
+		if (ti->type->io_hints)
+			ti->type->io_hints(ti, &ti_limits);
+
 		/*
 		 * Merge this target's queue limits into the overall limits
 		 * for the table.





More information about the dm-devel mailing list