dm: use op specific max_sectors when splitting abnormal io
authorMike Snitzer <snitzer@kernel.org>
Thu, 15 Jun 2023 01:47:46 +0000 (21:47 -0400)
committerMike Snitzer <snitzer@kernel.org>
Thu, 15 Jun 2023 16:47:16 +0000 (12:47 -0400)
commitbe04c14a1bd262a49e5764e5cf864259b7e740fd
tree27b84bba096a35646dcc8bffedc7c84a7d50e210
parent722d90822321497e2837cfc9000202e256e6b32f
dm: use op specific max_sectors when splitting abnormal io

Split abnormal IO in terms of the corresponding operation specific
max_sectors (max_discard_sectors, max_secure_erase_sectors or
max_write_zeroes_sectors).

This fixes a significant dm-thinp discard performance regression that
was introduced with commit e2dd8aca2d76 ("dm bio prison v1: improve
concurrent IO performance"). Relative to discard: max_discard_sectors
is used instead of max_sectors; which fixes excessive discard splitting
(e.g. max_sectors=128K vs max_discard_sectors=64M).

Tested by discarding an 1 Petabyte dm-thin device:
lvcreate -V 1125899906842624B -T test/pool -n thin
time blkdiscard /dev/test/thin

Before this fix (splitting discards every 128K): ~116m
 After this fix (splitting discards every 64M) : 0m33.460s

Reported-by: Zorro Lang <zlang@redhat.com>
Fixes: 06961c487a33 ("dm: split discards further if target sets max_discard_granularity")
Requires: 13f6facf3fae ("dm: allow targets to require splitting WRITE_ZEROES and SECURE_ERASE")
Fixes: e2dd8aca2d76 ("dm bio prison v1: improve concurrent IO performance")
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
drivers/md/dm.c