Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 273324
b: refs/heads/master
c: 5a25f0e
h: refs/heads/master
v: v3
  • Loading branch information
Jonathan E Brassow authored and Alasdair G Kergon committed Oct 31, 2011
1 parent 63ca61e commit 398283b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b89544575d0096735edc9b0ad187e635487905ad
refs/heads/master: 5a25f0eb707bbb4a5aaaf19c933605a6dbaf77a5
35 changes: 32 additions & 3 deletions trunk/drivers/md/dm-log-userspace-base.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,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;
Expand Down Expand Up @@ -161,13 +162,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;
Expand Down Expand Up @@ -195,9 +198,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)
Expand All @@ -220,7 +233,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);
Expand All @@ -241,6 +267,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);

Expand Down
18 changes: 13 additions & 5 deletions trunk/include/linux/dm-log-userspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,20 @@
* Payload-to-userspace:
* A single string containing all the argv arguments separated by ' 's
* Payload-to-kernel:
* None. ('data_size' in the dm_ulog_request struct should be 0.)
* A NUL-terminated string that is the name of the device that is used
* as the backing store for the log data. 'dm_get_device' will be called
* on this device. ('dm_put_device' will be called on this device
* automatically after calling DM_ULOG_DTR.) If there is no device needed
* for log data, 'data_size' in the dm_ulog_request struct should be 0.
*
* The UUID contained in the dm_ulog_request structure is the reference that
* will be used by all request types to a specific log. The constructor must
* record this assotiation with instance created.
* record this association with the instance created.
*
* When the request has been processed, user-space must return the
* dm_ulog_request to the kernel - setting the 'error' field and
* 'data_size' appropriately.
* dm_ulog_request to the kernel - setting the 'error' field, filling the
* data field with the log device if necessary, and setting 'data_size'
* appropriately.
*/
#define DM_ULOG_CTR 1

Expand Down Expand Up @@ -377,8 +382,11 @@
* dm_ulog_request or a change in the way requests are
* issued/handled. Changes are outlined here:
* version 1: Initial implementation
* version 2: DM_ULOG_CTR allowed to return a string containing a
* device name that is to be registered with DM via
* 'dm_get_device'.
*/
#define DM_ULOG_REQUEST_VERSION 1
#define DM_ULOG_REQUEST_VERSION 2

struct dm_ulog_request {
/*
Expand Down

0 comments on commit 398283b

Please sign in to comment.