From f4dc37cc72b475c043988e6793d9bdd417b02d39 Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Sun, 28 Feb 2016 10:43:33 +0100 Subject: [PATCH] dm-table: Add flag to allow own target handling of integrity metadata. This patch adds DM_TARGET_INTEGRITY flag that specifies bio integrity metadata is not inherited but implemented in target itself. Signed-off-by: Milan Broz --- drivers/md/dm-table.c | 11 +++++++++++ include/linux/device-mapper.h | 6 ++++++ 2 files changed, 17 insertions(+) Index: linux-4.6-rc6/drivers/md/dm-table.c =================================================================== --- linux-4.6-rc6.orig/drivers/md/dm-table.c 2016-05-02 13:02:26.000000000 +0200 +++ linux-4.6-rc6/drivers/md/dm-table.c 2016-05-02 15:32:29.000000000 +0200 @@ -45,6 +45,7 @@ struct dm_table { struct target_type *immutable_target_type; unsigned integrity_supported:1; unsigned singleton:1; + unsigned integrity_added:1; /* * Indicates the rw permissions for the new logical @@ -744,6 +745,9 @@ int dm_table_add_target(struct dm_table t->immutable_target_type = tgt->type; } + if (dm_target_has_integrity(tgt->type)) + t->integrity_added = 1; + tgt->table = t; tgt->begin = start; tgt->len = len; @@ -1118,6 +1122,10 @@ static int dm_table_register_integrity(s struct mapped_device *md = t->md; struct gendisk *template_disk = NULL; + /* If target handles integrity itself do not register it here. */ + if (t->integrity_added) + return 0; + template_disk = dm_table_get_integrity_disk(t); if (!template_disk) return 0; @@ -1355,6 +1363,9 @@ static void dm_table_verify_integrity(st { struct gendisk *template_disk = NULL; + if (t->integrity_added) + return; + if (t->integrity_supported) { /* * Verify that the original integrity profile Index: linux-4.6-rc6/include/linux/device-mapper.h =================================================================== --- linux-4.6-rc6.orig/include/linux/device-mapper.h 2016-05-02 13:02:24.000000000 +0200 +++ linux-4.6-rc6/include/linux/device-mapper.h 2016-05-02 15:33:26.000000000 +0200 @@ -198,6 +198,12 @@ struct target_type { #define DM_TARGET_WILDCARD 0x00000008 #define dm_target_is_wildcard(type) ((type)->features & DM_TARGET_WILDCARD) +/* + * A target implements own bio data integrity. + */ +#define DM_TARGET_INTEGRITY 0x00000010 +#define dm_target_has_integrity(type) ((type)->features & DM_TARGET_INTEGRITY) + struct dm_target { struct dm_table *table; struct target_type *type;