| Index: drivers/md/dm-ioctl.c
|
| diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
|
| index d19854c98184de70a6ba7bb5432543eecd212a04..d70f687bcc5a04290a5083d6ece2b0e380c70e8a 100644
|
| --- a/drivers/md/dm-ioctl.c
|
| +++ b/drivers/md/dm-ioctl.c
|
| @@ -1061,28 +1061,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;
|
| @@ -1104,21 +1085,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;
|
| - }
|
| -
|
| down_write(&_hash_lock);
|
| hc = dm_get_mdptr(md);
|
| if (!hc || hc->md != md) {
|
| @@ -1579,6 +1545,45 @@ void dm_interface_exit(void)
|
| dm_hash_exit();
|
| }
|
|
|
| +
|
| +/**
|
| + * dm_ioctl_export - Permanently export a mapped device via the ioctl interface
|
| + * @md: Pointer to mapped_device
|
| + * @name: Buffer (size DM_NAME_LEN) for name
|
| + * @uuid: Buffer (size DM_UUID_LEN) for uuid or NULL if not desired
|
| + */
|
| +int dm_ioctl_export(struct mapped_device *md, const char *name,
|
| + const char *uuid)
|
| +{
|
| + int r = 0;
|
| + struct hash_cell *hc;
|
| +
|
| + if (!md) {
|
| + r = -ENXIO;
|
| + goto out;
|
| + }
|
| +
|
| + /* The name and uuid can only be set once. */
|
| + mutex_lock(&dm_hash_cells_mutex);
|
| + hc = dm_get_mdptr(md);
|
| + mutex_unlock(&dm_hash_cells_mutex);
|
| + if (hc) {
|
| + DMERR("%s: already exported", dm_device_name(md));
|
| + r = -ENXIO;
|
| + goto out;
|
| + }
|
| +
|
| + r = dm_hash_insert(name, uuid, md);
|
| + if (r) {
|
| + DMERR("%s: could not bind to '%s'", dm_device_name(md), name);
|
| + goto out;
|
| + }
|
| +
|
| + /* Let udev know we've changed. */
|
| + dm_kobject_uevent(md, KOBJ_CHANGE, dm_get_event_nr(md));
|
| +out:
|
| + return r;
|
| +}
|
| /**
|
| * dm_copy_name_and_uuid - Copy mapped device name & uuid into supplied buffers
|
| * @md: Pointer to mapped_device
|
|
|