diff mbox series

[1/2] dm: introduce the target flag mempool_needs_integrity

Message ID a5896fbb-9538-2f79-29cf-c820152158@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: Mikulas Patocka
Headers show
Series [1/2] dm: introduce the target flag mempool_needs_integrity | expand

Commit Message

Mikulas Patocka June 25, 2024, 5:56 p.m. UTC
This commit introduces the dm target flag mempool_needs_integrity. When
the flag is set, device mapper will call bioset_integrity_create on it's
bio sets. The target can then call bio_integrity_alloc on the bios
allocated from the table's mempool.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>

---
 drivers/md/dm-table.c         |    7 +++++--
 include/linux/device-mapper.h |    6 ++++++
 2 files changed, 11 insertions(+), 2 deletions(-)
diff mbox series

Patch

Index: linux-2.6/include/linux/device-mapper.h
===================================================================
--- linux-2.6.orig/include/linux/device-mapper.h	2024-06-25 19:25:12.000000000 +0200
+++ linux-2.6/include/linux/device-mapper.h	2024-06-25 19:25:30.000000000 +0200
@@ -397,6 +397,12 @@  struct dm_target {
 	 * bio_set_dev(). NOTE: ideally a target should _not_ need this.
 	 */
 	bool needs_bio_set_dev:1;
+
+	/*
+	 * Set if the target calls bio_integrity_alloc on bios received
+	 * in the map method.
+	 */
+	bool mempool_needs_integrity:1;
 };
 
 void *dm_per_bio_data(struct bio *bio, size_t data_size);
Index: linux-2.6/drivers/md/dm-table.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-table.c	2024-06-25 19:25:15.000000000 +0200
+++ linux-2.6/drivers/md/dm-table.c	2024-06-25 19:25:44.000000000 +0200
@@ -1022,6 +1022,7 @@  static int dm_table_alloc_md_mempools(st
 	unsigned int per_io_data_size = 0, front_pad, io_front_pad;
 	unsigned int min_pool_size = 0, pool_size;
 	struct dm_md_mempools *pools;
+	bool mempool_needs_integrity = t->integrity_supported;
 
 	if (unlikely(type == DM_TYPE_NONE)) {
 		DMERR("no table type is set, can't allocate mempools");
@@ -1043,6 +1044,8 @@  static int dm_table_alloc_md_mempools(st
 
 		per_io_data_size = max(per_io_data_size, ti->per_io_data_size);
 		min_pool_size = max(min_pool_size, ti->num_flush_bios);
+
+		mempool_needs_integrity |= ti->mempool_needs_integrity;
 	}
 	pool_size = max(dm_get_reserved_bio_based_ios(), min_pool_size);
 	front_pad = roundup(per_io_data_size,
@@ -1053,13 +1056,13 @@  static int dm_table_alloc_md_mempools(st
 	if (bioset_init(&pools->io_bs, pool_size, io_front_pad,
 			dm_table_supports_poll(t) ? BIOSET_PERCPU_CACHE : 0))
 		goto out_free_pools;
-	if (t->integrity_supported &&
+	if (mempool_needs_integrity &&
 	    bioset_integrity_create(&pools->io_bs, pool_size))
 		goto out_free_pools;
 init_bs:
 	if (bioset_init(&pools->bs, pool_size, front_pad, 0))
 		goto out_free_pools;
-	if (t->integrity_supported &&
+	if (mempool_needs_integrity &&
 	    bioset_integrity_create(&pools->bs, pool_size))
 		goto out_free_pools;