From 3f8d3f5432078a558151e27230e20bcf93c23ffe Mon Sep 17 00:00:00 2001 From: Mike Snitzer Date: Sat, 25 Mar 2023 17:52:01 -0400 Subject: 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 --- drivers/md/dm-bio-prison-v1.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers/md/dm-bio-prison-v1.h') diff --git a/drivers/md/dm-bio-prison-v1.h b/drivers/md/dm-bio-prison-v1.h index 0b8acd6708fb..2a097ed0d85e 100644 --- a/drivers/md/dm-bio-prison-v1.h +++ b/drivers/md/dm-bio-prison-v1.h @@ -83,6 +83,11 @@ int dm_get_cell(struct dm_bio_prison *prison, struct dm_bio_prison_cell *cell_prealloc, struct dm_bio_prison_cell **cell_result); +/* + * Returns false if key is beyond BIO_PRISON_MAX_RANGE or spans a boundary. + */ +bool dm_cell_key_has_valid_range(struct dm_cell_key *key); + /* * An atomic op that combines retrieving or creating a cell, and adding a * bio to it. -- cgit v1.2.3