Skip to content

Commit 9b4b5a7

Browse files
mbrozsnitm
authored andcommitted
dm table: add flag to allow target to handle its own integrity metadata
Add DM_TARGET_INTEGRITY flag that specifies bio integrity metadata is not inherited but implemented in the target itself. Signed-off-by: Milan Broz <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent b29d498 commit 9b4b5a7

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

drivers/md/dm-table.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct dm_table {
4747
bool integrity_supported:1;
4848
bool singleton:1;
4949
bool all_blk_mq:1;
50+
unsigned integrity_added:1;
5051

5152
/*
5253
* Indicates the rw permissions for the new logical
@@ -725,6 +726,9 @@ int dm_table_add_target(struct dm_table *t, const char *type,
725726
t->immutable_target_type = tgt->type;
726727
}
727728

729+
if (dm_target_has_integrity(tgt->type))
730+
t->integrity_added = 1;
731+
728732
tgt->table = t;
729733
tgt->begin = start;
730734
tgt->len = len;
@@ -1168,6 +1172,10 @@ static int dm_table_register_integrity(struct dm_table *t)
11681172
struct mapped_device *md = t->md;
11691173
struct gendisk *template_disk = NULL;
11701174

1175+
/* If target handles integrity itself do not register it here. */
1176+
if (t->integrity_added)
1177+
return 0;
1178+
11711179
template_disk = dm_table_get_integrity_disk(t);
11721180
if (!template_disk)
11731181
return 0;
@@ -1394,6 +1402,9 @@ static void dm_table_verify_integrity(struct dm_table *t)
13941402
{
13951403
struct gendisk *template_disk = NULL;
13961404

1405+
if (t->integrity_added)
1406+
return;
1407+
13971408
if (t->integrity_supported) {
13981409
/*
13991410
* Verify that the original integrity profile

include/linux/device-mapper.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,12 @@ struct target_type {
221221
*/
222222
typedef unsigned (*dm_num_write_bios_fn) (struct dm_target *ti, struct bio *bio);
223223

224+
/*
225+
* A target implements own bio data integrity.
226+
*/
227+
#define DM_TARGET_INTEGRITY 0x00000010
228+
#define dm_target_has_integrity(type) ((type)->features & DM_TARGET_INTEGRITY)
229+
224230
struct dm_target {
225231
struct dm_table *table;
226232
struct target_type *type;

0 commit comments

Comments
 (0)