X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fmd%2Fdm-log-userspace-base.c;h=9429159d9ee335c78c57f19e023b68d602683acc;hb=32aaeffbd4a7457bf2f7448b33b5946ff2a960eb;hp=1021c89860116a5bb6e3a2faea1362c0ea805f52;hpb=b53d63ecce17c4ddf8636def9f6e8b865c3927f9;p=pandora-kernel.git diff --git a/drivers/md/dm-log-userspace-base.c b/drivers/md/dm-log-userspace-base.c index 1021c8986011..9429159d9ee3 100644 --- a/drivers/md/dm-log-userspace-base.c +++ b/drivers/md/dm-log-userspace-base.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "dm-log-userspace-transfer.h" @@ -30,6 +31,7 @@ struct flush_entry { struct log_c { struct dm_target *ti; + struct dm_dev *log_dev; uint32_t region_size; region_t region_count; uint64_t luid; @@ -146,7 +148,7 @@ static int build_constructor_string(struct dm_target *ti, * * Where 'other args' is the userspace implementation specific log * arguments. An example might be: - * clustered_disk [[no]sync] + * clustered-disk [[no]sync] * * So, this module will strip off the for identification purposes * when communicating with userspace about a log; but will pass on everything @@ -161,13 +163,15 @@ static int userspace_ctr(struct dm_dirty_log *log, struct dm_target *ti, struct log_c *lc = NULL; uint64_t rdata; size_t rdata_size = sizeof(rdata); + char *devices_rdata = NULL; + size_t devices_rdata_size = DM_NAME_LEN; if (argc < 3) { DMWARN("Too few arguments to userspace dirty log"); return -EINVAL; } - lc = kmalloc(sizeof(*lc), GFP_KERNEL); + lc = kzalloc(sizeof(*lc), GFP_KERNEL); if (!lc) { DMWARN("Unable to allocate userspace log context."); return -ENOMEM; @@ -195,9 +199,19 @@ static int userspace_ctr(struct dm_dirty_log *log, struct dm_target *ti, return str_size; } - /* Send table string */ + devices_rdata = kzalloc(devices_rdata_size, GFP_KERNEL); + if (!devices_rdata) { + DMERR("Failed to allocate memory for device information"); + r = -ENOMEM; + goto out; + } + + /* + * Send table string and get back any opened device. + */ r = dm_consult_userspace(lc->uuid, lc->luid, DM_ULOG_CTR, - ctr_str, str_size, NULL, NULL); + ctr_str, str_size, + devices_rdata, &devices_rdata_size); if (r < 0) { if (r == -ESRCH) @@ -220,7 +234,20 @@ static int userspace_ctr(struct dm_dirty_log *log, struct dm_target *ti, lc->region_size = (uint32_t)rdata; lc->region_count = dm_sector_div_up(ti->len, lc->region_size); + if (devices_rdata_size) { + if (devices_rdata[devices_rdata_size - 1] != '\0') { + DMERR("DM_ULOG_CTR device return string not properly terminated"); + r = -EINVAL; + goto out; + } + r = dm_get_device(ti, devices_rdata, + dm_table_get_mode(ti->table), &lc->log_dev); + if (r) + DMERR("Failed to register %s with device-mapper", + devices_rdata); + } out: + kfree(devices_rdata); if (r) { kfree(lc); kfree(ctr_str); @@ -241,6 +268,9 @@ static void userspace_dtr(struct dm_dirty_log *log) NULL, 0, NULL, NULL); + if (lc->log_dev) + dm_put_device(lc->ti, lc->log_dev); + kfree(lc->usr_argv_str); kfree(lc);