dm ioctl: refactor dm_table_complete

This change unifies the various checks and finalization that occurs on a
table prior to use.  By doing so, it allows table construction without
traversing the dm-ioctl interface.

Signed-off-by: Will Drewry <wad@chromium.org>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
This commit is contained in:
Will Drewry
2010-08-12 04:14:03 +01:00
committed by Alasdair G Kergon
parent b1d5552838
commit 26803b9f06
3 changed files with 52 additions and 38 deletions

View File

@@ -1131,28 +1131,9 @@ static int populate_table(struct dm_table *table,
next = spec->next;
}
r = dm_table_set_type(table);
if (r) {
DMWARN("unable to set table type");
return r;
}
return dm_table_complete(table);
}
static int table_prealloc_integrity(struct dm_table *t,
struct mapped_device *md)
{
struct list_head *devices = dm_table_get_devices(t);
struct dm_dev_internal *dd;
list_for_each_entry(dd, devices, list)
if (bdev_get_integrity(dd->dm_dev.bdev))
return blk_integrity_register(dm_disk(md), NULL);
return 0;
}
static int table_load(struct dm_ioctl *param, size_t param_size)
{
int r;
@@ -1174,21 +1155,6 @@ static int table_load(struct dm_ioctl *param, size_t param_size)
goto out;
}
r = table_prealloc_integrity(t, md);
if (r) {
DMERR("%s: could not register integrity profile.",
dm_device_name(md));
dm_table_destroy(t);
goto out;
}
r = dm_table_alloc_md_mempools(t);
if (r) {
DMWARN("unable to allocate mempools for this table");
dm_table_destroy(t);
goto out;
}
/* Protect md->type and md->queue against concurrent table loads. */
dm_lock_md_type(md);
if (dm_get_md_type(md) == DM_TYPE_NONE)