dm ioctl: allow change device target type to error
PATCH 1/1 dm ioctl: allow change device target type to error
commit a5664da "dm ioctl: make bio or request based device type immutable" prevented "dmsetup wape_table" change the target type to "error".
Signed-off-by Joe Jin <[email protected]>
--- drivers/md/dm-ioctl.c | 6 +++++- drivers/md/dm-table.c | 12 ++++++++++++ drivers/md/dm.h | 1 + 3 files changed, 18 insertions(+), 1 deletion(-)
drivers/md/dm-ioctl.c +5 -1
@@ -1250,7 +1250,7 @@ static int populate_table(struct dm_table *table,static int table_load (struct dm_ioctl *param,size_t param_size) { -int r; +int r =0 ;struct hash_cell *hc;struct dm_table *t, *old_map =NULL ;struct mapped_device *md;
@@ -1280,6 +1280,9 @@ static int table_load(struct dm_ioctl *param, size_t param_size) goto out; } +if (dm_is_error_target (t)) + goto error_target; +/* Protect md->type and md->queue against concurrent table loads. */ dm_lock_md_type (md);if (dm_get_md_type (md) ==DM_TYPE_NONE )
@@ -1303,6 +1306,7 @@ static int table_load(struct dm_ioctl *param, size_t param_size) }dm_unlock_md_type (md); +error_target:/* stage inactive table */ down_write (&_hash_lock); hc =dm_get_mdptr (md);
drivers/md/dm-table.c +12 -0
@@ -184,6 +184,18 @@ static int alloc_targets(struct dm_table *t, unsigned int num)return 0 ; } +bool dm_is_error_target (struct dm_table *t) +{ +unsigned i; + +for (i =0 ; i < t->num_targets; i++) { +struct dm_target *tgt = t->targets + i; +if (strcmp (tgt->type->name,"error" ) ==0 ) +return true; + } +return false; +} +int dm_table_create (struct dm_table **result,fmode_t mode,unsigned num_targets,struct mapped_device *md) {
drivers/md/dm.h +1 -0
@@ -69,6 +69,7 @@ unsigned dm_table_get_type(struct dm_table *t);struct target_type *dm_table_get_immutable_target_type (struct dm_table *t);bool dm_table_request_based (struct dm_table *t);bool dm_table_supports_discards (struct dm_table *t); +bool dm_is_error_target (struct dm_table *t);int dm_table_alloc_md_mempools (struct dm_table *t);void dm_table_free_md_mempools (struct dm_table *t);struct dm_md_mempools *dm_table_get_md_mempools (struct dm_table *t);
Signature · 1 line
1.8.3.1