diff options
author | Alasdair G Kergon <agk@redhat.com> | 2011-10-31 16:19:04 -0400 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2011-10-31 16:19:04 -0400 |
commit | 36a0456fbf2d9680bf9af81b39daf4a8e22cb1b8 (patch) | |
tree | a19af18640d538e8357c195e6b4c77d0f6c92391 /drivers/md/dm-ioctl.c | |
parent | cc6cbe141a20f6d876b161b60af38d93935bfa85 (diff) |
dm table: add immutable feature
Introduce DM_TARGET_IMMUTABLE to indicate that the target type cannot be mixed
with any other target type, and once loaded into a device, it cannot be
replaced with a table containing a different type.
The thin provisioning pool device will use this.
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md/dm-ioctl.c')
-rw-r--r-- | drivers/md/dm-ioctl.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index 2e9a3ca37bdd..31c2dc25886d 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c | |||
@@ -1215,6 +1215,7 @@ static int table_load(struct dm_ioctl *param, size_t param_size) | |||
1215 | struct hash_cell *hc; | 1215 | struct hash_cell *hc; |
1216 | struct dm_table *t; | 1216 | struct dm_table *t; |
1217 | struct mapped_device *md; | 1217 | struct mapped_device *md; |
1218 | struct target_type *immutable_target_type; | ||
1218 | 1219 | ||
1219 | md = find_device(param); | 1220 | md = find_device(param); |
1220 | if (!md) | 1221 | if (!md) |
@@ -1230,6 +1231,16 @@ static int table_load(struct dm_ioctl *param, size_t param_size) | |||
1230 | goto out; | 1231 | goto out; |
1231 | } | 1232 | } |
1232 | 1233 | ||
1234 | immutable_target_type = dm_get_immutable_target_type(md); | ||
1235 | if (immutable_target_type && | ||
1236 | (immutable_target_type != dm_table_get_immutable_target_type(t))) { | ||
1237 | DMWARN("can't replace immutable target type %s", | ||
1238 | immutable_target_type->name); | ||
1239 | dm_table_destroy(t); | ||
1240 | r = -EINVAL; | ||
1241 | goto out; | ||
1242 | } | ||
1243 | |||
1233 | /* Protect md->type and md->queue against concurrent table loads. */ | 1244 | /* Protect md->type and md->queue against concurrent table loads. */ |
1234 | dm_lock_md_type(md); | 1245 | dm_lock_md_type(md); |
1235 | if (dm_get_md_type(md) == DM_TYPE_NONE) | 1246 | if (dm_get_md_type(md) == DM_TYPE_NONE) |