aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-ioctl.c
diff options
context:
space:
mode:
authorMike Snitzer <snitzer@redhat.com>2010-08-11 23:14:01 -0400
committerAlasdair G Kergon <agk@redhat.com>2010-08-11 23:14:01 -0400
commita5664dad7e1a278d2915c2bf79cf42250e12d7db (patch)
tree3bdbe17f12376c63ea05100c2597757e01dc95e2 /drivers/md/dm-ioctl.c
parent708e929513502fb050c0a3c3ee267cab5b056ded (diff)
dm ioctl: make bio or request based device type immutable
Determine whether a mapped device is bio-based or request-based when loading its first (inactive) table and don't allow that to be changed later. This patch performs different device initialisation in each of the two cases. (We don't think it's necessary to add code to support changing between the two types.) Allowed md->type transitions: DM_TYPE_NONE to DM_TYPE_BIO_BASED DM_TYPE_NONE to DM_TYPE_REQUEST_BASED We now prevent table_load from replacing the inactive table with a conflicting type of table even after an explicit table_clear. Introduce 'type_lock' into the struct mapped_device to protect md->type and to prepare for the next patch that will change the queue initialization and allocate memory while md->type_lock is held. Signed-off-by: Mike Snitzer <snitzer@redhat.com> Acked-by: Kiyoshi Ueda <k-ueda@ct.jp.nec.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com> drivers/md/dm-ioctl.c | 15 +++++++++++++++ drivers/md/dm.c | 37 ++++++++++++++++++++++++++++++------- drivers/md/dm.h | 5 +++++ include/linux/dm-ioctl.h | 4 ++-- 4 files changed, 52 insertions(+), 9 deletions(-)
Diffstat (limited to 'drivers/md/dm-ioctl.c')
-rw-r--r--drivers/md/dm-ioctl.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 3fd8f0e169e7..4702f380cb45 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -1189,6 +1189,21 @@ static int table_load(struct dm_ioctl *param, size_t param_size)
1189 goto out; 1189 goto out;
1190 } 1190 }
1191 1191
1192 /* Protect md->type against concurrent table loads. */
1193 dm_lock_md_type(md);
1194 if (dm_get_md_type(md) == DM_TYPE_NONE)
1195 /* Initial table load: acquire type of table. */
1196 dm_set_md_type(md, dm_table_get_type(t));
1197 else if (dm_get_md_type(md) != dm_table_get_type(t)) {
1198 DMWARN("can't change device type after initial table load.");
1199 dm_table_destroy(t);
1200 dm_unlock_md_type(md);
1201 r = -EINVAL;
1202 goto out;
1203 }
1204 dm_unlock_md_type(md);
1205
1206 /* stage inactive table */
1192 down_write(&_hash_lock); 1207 down_write(&_hash_lock);
1193 hc = dm_get_mdptr(md); 1208 hc = dm_get_mdptr(md);
1194 if (!hc || hc->md != md) { 1209 if (!hc || hc->md != md) {