dm bio prison v1: add dm_cell_key_has_valid_range
authorMike Snitzer <snitzer@kernel.org>
Sat, 25 Mar 2023 21:52:01 +0000 (17:52 -0400)
committerMike Snitzer <snitzer@kernel.org>
Thu, 30 Mar 2023 19:57:51 +0000 (15:57 -0400)
commit3f8d3f5432078a558151e27230e20bcf93c23ffe
tree9c6ae4c1ea3197281a7dad244a55c503dad30a8a
parente2dd8aca2d76f937f1f08d03041684f3532e9df4
dm bio prison v1: add dm_cell_key_has_valid_range

Don't have bio_detain() BUG_ON if a dm_cell_key is beyond
BIO_PRISON_MAX_RANGE or spans a boundary.

Update dm-thin.c:build_key() to use dm_cell_key_has_valid_range() which
will do this checking without using BUG_ON. Also update
process_discard_bio() to check the discard bio that DM core passes in
(having first imposed max_discard_granularity based splitting).

dm_cell_key_has_valid_range() will merely WARN_ON_ONCE if it returns
false because if it does: it is programmer error that should be caught
with proper testing. So relax the BUG_ONs to be WARN_ON_ONCE.

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
drivers/md/dm-bio-prison-v1.c
drivers/md/dm-bio-prison-v1.h
drivers/md/dm-thin.c