- Fix DM thinp discard performance regression introduced during 6.4
  merge; where DM core was splitting large discards every 128K
  (max_sectors_kb) rather than every 64M (discard_max_bytes).

- Extend DM core LOCKFS fix, made during 6.4 merge, to also fix race
  between do_mount and dm's do_suspend (in addition to the earlier
  fix's do_mount race with dm's do_resume).

- Fix DM thin metadata operations to first check if the thin-pool is
  in "fail_io" mode; otherwise UAF can occur.

- Fix DM thinp's call to __blkdev_issue_discard to use GFP_NOIO rather
  than GFP_NOWAIT (__blkdev_issue_discard cannot handle NULL return
  from bio_alloc).
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>
1 file changed