dm-ioctl.c (6ad390a25a9d1d8606b9b826878f0a30639dc2b3) dm-ioctl.c (36a0456fbf2d9680bf9af81b39daf4a8e22cb1b8)
1/*
2 * Copyright (C) 2001, 2002 Sistina Software (UK) Limited.
3 * Copyright (C) 2004 - 2006 Red Hat, Inc. All rights reserved.
4 *
5 * This file is released under the GPL.
6 */
7
8#include "dm.h"

--- 1201 unchanged lines hidden (view full) ---

1210}
1211
1212static int table_load(struct dm_ioctl *param, size_t param_size)
1213{
1214 int r;
1215 struct hash_cell *hc;
1216 struct dm_table *t;
1217 struct mapped_device *md;
1/*
2 * Copyright (C) 2001, 2002 Sistina Software (UK) Limited.
3 * Copyright (C) 2004 - 2006 Red Hat, Inc. All rights reserved.
4 *
5 * This file is released under the GPL.
6 */
7
8#include "dm.h"

--- 1201 unchanged lines hidden (view full) ---

1210}
1211
1212static int table_load(struct dm_ioctl *param, size_t param_size)
1213{
1214 int r;
1215 struct hash_cell *hc;
1216 struct dm_table *t;
1217 struct mapped_device *md;
1218 struct target_type *immutable_target_type;
1218
1219 md = find_device(param);
1220 if (!md)
1221 return -ENXIO;
1222
1223 r = dm_table_create(&t, get_mode(param), param->target_count, md);
1224 if (r)
1225 goto out;
1226
1227 r = populate_table(t, param, param_size);
1228 if (r) {
1229 dm_table_destroy(t);
1230 goto out;
1231 }
1232
1219
1220 md = find_device(param);
1221 if (!md)
1222 return -ENXIO;
1223
1224 r = dm_table_create(&t, get_mode(param), param->target_count, md);
1225 if (r)
1226 goto out;
1227
1228 r = populate_table(t, param, param_size);
1229 if (r) {
1230 dm_table_destroy(t);
1231 goto out;
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. */
1234 dm_lock_md_type(md);
1235 if (dm_get_md_type(md) == DM_TYPE_NONE)
1236 /* Initial table load: acquire type of table. */
1237 dm_set_md_type(md, dm_table_get_type(t));
1238 else if (dm_get_md_type(md) != dm_table_get_type(t)) {
1239 DMWARN("can't change device type after initial table load.");
1240 dm_table_destroy(t);

--- 530 unchanged lines hidden ---
1244 /* Protect md->type and md->queue against concurrent table loads. */
1245 dm_lock_md_type(md);
1246 if (dm_get_md_type(md) == DM_TYPE_NONE)
1247 /* Initial table load: acquire type of table. */
1248 dm_set_md_type(md, dm_table_get_type(t));
1249 else if (dm_get_md_type(md) != dm_table_get_type(t)) {
1250 DMWARN("can't change device type after initial table load.");
1251 dm_table_destroy(t);

--- 530 unchanged lines hidden ---