summaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-bio-prison-v1.c
diff options
context:
space:
mode:
authorMike Snitzer <snitzer@kernel.org>2023-03-25 22:52:01 +0100
committerMike Snitzer <snitzer@kernel.org>2023-03-30 21:57:51 +0200
commit3f8d3f5432078a558151e27230e20bcf93c23ffe (patch)
tree9c6ae4c1ea3197281a7dad244a55c503dad30a8a /drivers/md/dm-bio-prison-v1.c
parentdm bio prison v1: improve concurrent IO performance (diff)
downloadlinux-3f8d3f5432078a558151e27230e20bcf93c23ffe.tar.xz
linux-3f8d3f5432078a558151e27230e20bcf93c23ffe.zip
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>
Diffstat (limited to 'drivers/md/dm-bio-prison-v1.c')
-rw-r--r--drivers/md/dm-bio-prison-v1.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/md/dm-bio-prison-v1.c b/drivers/md/dm-bio-prison-v1.c
index 2b8af861e5f6..78bb559b521c 100644
--- a/drivers/md/dm-bio-prison-v1.c
+++ b/drivers/md/dm-bio-prison-v1.c
@@ -120,12 +120,17 @@ static unsigned lock_nr(struct dm_cell_key *key)
return (key->block_begin >> BIO_PRISON_MAX_RANGE_SHIFT) & LOCK_MASK;
}
-static void check_range(struct dm_cell_key *key)
+bool dm_cell_key_has_valid_range(struct dm_cell_key *key)
{
- BUG_ON(key->block_end - key->block_begin > BIO_PRISON_MAX_RANGE);
- BUG_ON((key->block_begin >> BIO_PRISON_MAX_RANGE_SHIFT) !=
- ((key->block_end - 1) >> BIO_PRISON_MAX_RANGE_SHIFT));
+ if (WARN_ON_ONCE(key->block_end - key->block_begin > BIO_PRISON_MAX_RANGE))
+ return false;
+ if (WARN_ON_ONCE((key->block_begin >> BIO_PRISON_MAX_RANGE_SHIFT) !=
+ (key->block_end - 1) >> BIO_PRISON_MAX_RANGE_SHIFT))
+ return false;
+
+ return true;
}
+EXPORT_SYMBOL(dm_cell_key_has_valid_range);
static int __bio_detain(struct rb_root *root,
struct dm_cell_key *key,
@@ -172,7 +177,6 @@ static int bio_detain(struct dm_bio_prison *prison,
{
int r;
unsigned l = lock_nr(key);
- check_range(key);
spin_lock_irq(&prison->regions[l].lock);
r = __bio_detain(&prison->regions[l].cell, key, inmate, cell_prealloc, cell_result);