Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dm: set DM_TARGET_WILDCARD feature on "error" target

The DM_TARGET_WILDCARD feature indicates that the "error" target may
replace any target; even immutable targets. This feature will be useful
to preserve the ability to replace the "multipath" target even once it
is formally converted over to having the DM_TARGET_IMMUTABLE feature.

Also, implicit in the DM_TARGET_WILDCARD feature flag being set is that
.map, .map_rq, .clone_and_map_rq and .release_clone_rq are all defined
in the target_type.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>

+26 -2
+2 -1
drivers/md/dm-ioctl.c
··· 1291 1291 1292 1292 immutable_target_type = dm_get_immutable_target_type(md); 1293 1293 if (immutable_target_type && 1294 - (immutable_target_type != dm_table_get_immutable_target_type(t))) { 1294 + (immutable_target_type != dm_table_get_immutable_target_type(t)) && 1295 + !dm_table_get_wildcard_target(t)) { 1295 1296 DMWARN("can't replace immutable target type %s", 1296 1297 immutable_target_type->name); 1297 1298 r = -EINVAL;
+14
drivers/md/dm-table.c
··· 920 920 return t->immutable_target_type; 921 921 } 922 922 923 + struct dm_target *dm_table_get_wildcard_target(struct dm_table *t) 924 + { 925 + struct dm_target *uninitialized_var(ti); 926 + unsigned i = 0; 927 + 928 + while (i < dm_table_get_num_targets(t)) { 929 + ti = dm_table_get_target(t, i++); 930 + if (dm_target_is_wildcard(ti->type)) 931 + return ti; 932 + } 933 + 934 + return NULL; 935 + } 936 + 923 937 bool dm_table_request_based(struct dm_table *t) 924 938 { 925 939 return __table_type_request_based(dm_table_get_type(t));
+2 -1
drivers/md/dm-target.c
··· 150 150 151 151 static struct target_type error_target = { 152 152 .name = "error", 153 - .version = {1, 3, 0}, 153 + .version = {1, 4, 0}, 154 + .features = DM_TARGET_WILDCARD, 154 155 .ctr = io_err_ctr, 155 156 .dtr = io_err_dtr, 156 157 .map = io_err_map,
+1
drivers/md/dm.h
··· 73 73 int dm_table_any_congested(struct dm_table *t, int bdi_bits); 74 74 unsigned dm_table_get_type(struct dm_table *t); 75 75 struct target_type *dm_table_get_immutable_target_type(struct dm_table *t); 76 + struct dm_target *dm_table_get_wildcard_target(struct dm_table *t); 76 77 bool dm_table_request_based(struct dm_table *t); 77 78 bool dm_table_mq_request_based(struct dm_table *t); 78 79 void dm_table_free_md_mempools(struct dm_table *t);
+7
include/linux/device-mapper.h
··· 190 190 #define dm_target_is_immutable(type) ((type)->features & DM_TARGET_IMMUTABLE) 191 191 192 192 /* 193 + * Indicates that a target may replace any target; even immutable targets. 194 + * .map, .map_rq, .clone_and_map_rq and .release_clone_rq are all defined. 195 + */ 196 + #define DM_TARGET_WILDCARD 0x00000008 197 + #define dm_target_is_wildcard(type) ((type)->features & DM_TARGET_WILDCARD) 198 + 199 + /* 193 200 * Some targets need to be sent the same WRITE bio severals times so 194 201 * that they can send copies of it to different devices. This function 195 202 * examines any supplied bio and returns the number of copies of it the