public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/libdm libdevmapper.h libdm-deptree.c
@ 2011-10-04 16:22 zkabelac
0 siblings, 0 replies; 7+ messages in thread
From: zkabelac @ 2011-10-04 16:22 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-10-04 16:22:39
Modified files:
libdm : libdevmapper.h libdm-deptree.c
Log message:
Name changes
typo zeroeing->zeroing
add size low_water_mark->low_water_mark_size so it's more obvious its sector
related variable.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.156&r2=1.157
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.119&r2=1.120
--- LVM2/libdm/libdevmapper.h 2011/10/03 18:34:52 1.156
+++ LVM2/libdm/libdevmapper.h 2011/10/04 16:22:38 1.157
@@ -542,8 +542,8 @@
const char *pool_uuid,
const char *metadata_uuid,
uint32_t data_block_size,
- uint64_t low_water_mark,
- unsigned skip_block_zeroeing); /* Maybe separate _set_ call ? */
+ uint64_t low_water_mark_size,
+ unsigned skip_block_zeroing);
int dm_tree_node_add_thin_target(struct dm_tree_node *node,
uint64_t size,
--- LVM2/libdm/libdm-deptree.c 2011/10/03 18:34:52 1.119
+++ LVM2/libdm/libdm-deptree.c 2011/10/04 16:22:39 1.120
@@ -169,9 +169,9 @@
struct dm_tree_node *metadata; /* Thin_pool */
struct dm_tree_node *pool; /* Thin_pool, Thin */
- uint64_t low_water_mark; /* Thin_pool */
+ uint64_t low_water_mark_size; /* Thin_pool */
uint32_t data_block_size; /* Thin_pool */
- unsigned skip_block_zeroeing; /* Thin_pool */
+ unsigned skip_block_zeroing; /* Thin_pool */
uint32_t device_id; /* Thin */
};
@@ -1978,8 +1978,8 @@
if (!_build_dev_string(pool, sizeof(pool), seg->pool))
return_0;
EMIT_PARAMS(pos, "%s %s %d %" PRIu64 " %s", metadata, pool,
- seg->data_block_size, seg->low_water_mark,
- seg->skip_block_zeroeing ? "1 skip_block_zeroing" : "");
+ seg->data_block_size, seg->low_water_mark_size,
+ seg->skip_block_zeroing ? "1 skip_block_zeroing" : "");
break;
case SEG_THIN:
if (!_build_dev_string(pool, sizeof(pool), seg->pool))
@@ -2715,8 +2715,8 @@
const char *pool_uuid,
const char *metadata_uuid,
uint32_t data_block_size,
- uint64_t low_water_mark,
- unsigned skip_block_zeroeing)
+ uint64_t low_water_mark_size,
+ unsigned skip_block_zeroing)
{
struct load_segment *seg;
@@ -2754,9 +2754,9 @@
return_0;
node->props.thin_pool_transaction_id = transaction_id; // compare on resume
- seg->low_water_mark = low_water_mark;
+ seg->low_water_mark_size = low_water_mark_size;
seg->data_block_size = data_block_size;
- seg->skip_block_zeroeing = skip_block_zeroeing;
+ seg->skip_block_zeroing = skip_block_zeroing;
return 1;
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* LVM2/libdm libdevmapper.h libdm-deptree.c
@ 2011-12-21 12:52 zkabelac
0 siblings, 0 replies; 7+ messages in thread
From: zkabelac @ 2011-12-21 12:52 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-12-21 12:52:38
Modified files:
libdm : libdevmapper.h libdm-deptree.c
Log message:
Add Thin API for parsing thin status
Add dm_get_status_thin_pool and dm_get_status_thin functions to
parse 'params' argument which is received via dm_get_next_target.
Returns filed structure allocated from given mempool.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.172&r2=1.173
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.146&r2=1.147
--- LVM2/libdm/libdevmapper.h 2011/12/21 12:47:45 1.172
+++ LVM2/libdm/libdevmapper.h 2011/12/21 12:52:38 1.173
@@ -238,6 +238,29 @@
void *next, uint64_t *start, uint64_t *length,
char **target_type, char **params);
+/* Parse params from STATUS call for thin_pool target */
+struct dm_pool;
+
+struct dm_status_thin_pool {
+ uint64_t transaction_id;
+ uint64_t used_meta_blocks;
+ uint64_t total_meta_blocks;
+ uint64_t used_data_blocks;
+ uint64_t total_data_blocks;
+};
+
+int dm_get_status_thin_pool(struct dm_pool *mem, const char *params,
+ struct dm_status_thin_pool **status);
+
+/* Parse params from STATUS call for thin target */
+struct dm_status_thin {
+ uint64_t mapped_sectors;
+ uint64_t highest_mapped_sector;
+};
+
+int dm_get_status_thin(struct dm_pool *mem, const char *params,
+ struct dm_status_thin **status);
+
/*
* Call this to actually run the ioctl.
*/
--- LVM2/libdm/libdm-deptree.c 2011/11/12 22:44:10 1.146
+++ LVM2/libdm/libdm-deptree.c 2011/12/21 12:52:38 1.147
@@ -3030,6 +3030,54 @@
return 1;
}
+
+int dm_get_status_thin_pool(struct dm_pool *mem, const char *params,
+ struct dm_status_thin_pool **status)
+{
+ struct dm_status_thin_pool *s;
+
+ if (!(s = dm_pool_zalloc(mem, sizeof(struct dm_status_thin_pool)))) {
+ log_error("Failed to allocate thin_pool status structure.");
+ return 0;
+ }
+
+ if (sscanf(params, "%" PRIu64 " %" PRIu64 "/%" PRIu64 " %" PRIu64 "/%" PRIu64,
+ &s->transaction_id,
+ &s->used_meta_blocks,
+ &s->total_meta_blocks,
+ &s->used_data_blocks,
+ &s->total_data_blocks) != 5) {
+ log_error("Failed to parse thin pool params: %s.", params);
+ return 0;
+ }
+
+ *status = s;
+
+ return 1;
+}
+
+int dm_get_status_thin(struct dm_pool *mem, const char *params,
+ struct dm_status_thin **status)
+{
+ struct dm_status_thin *s;
+
+ if (!(s = dm_pool_zalloc(mem, sizeof(struct dm_status_thin)))) {
+ log_error("Failed to allocate thin status structure.");
+ return 0;
+ }
+
+ if (sscanf(params, "%" PRIu64 " %" PRIu64,
+ &s->mapped_sectors,
+ &s->highest_mapped_sector) != 2) {
+ log_error("Failed to parse thin params: %s.", params);
+ return 0;
+ }
+
+ *status = s;
+
+ return 1;
+}
+
static int _add_area(struct dm_tree_node *node, struct load_segment *seg, struct dm_tree_node *dev_node, uint64_t offset)
{
struct seg_area *area;
^ permalink raw reply [flat|nested] 7+ messages in thread
* LVM2/libdm libdevmapper.h libdm-deptree.c
@ 2011-11-03 14:43 zkabelac
0 siblings, 0 replies; 7+ messages in thread
From: zkabelac @ 2011-11-03 14:43 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-11-03 14:43:22
Modified files:
libdm : libdevmapper.h libdm-deptree.c
Log message:
Thin api change for dm_tree_node_add_thin_target
A little code shuffling and adding support for
DM_THIN_ERROR_DEVICE_ID which might be eventually be used
for activation of thin which is going to be deleted.
For now we do not need it lvm.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.166&r2=1.167
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.142&r2=1.143
--- LVM2/libdm/libdevmapper.h 2011/10/28 20:06:50 1.166
+++ LVM2/libdm/libdevmapper.h 2011/11/03 14:43:21 1.167
@@ -540,11 +540,9 @@
* FIXME: Defines bellow are based on kernel's dm-thin.c defines
* DATA_DEV_BLOCK_SIZE_MIN_SECTORS (64 * 1024 >> SECTOR_SHIFT)
* DATA_DEV_BLOCK_SIZE_MAX_SECTORS (1024 * 1024 * 1024 >> SECTOR_SHIFT)
- * MAX_DEV_ID ((1 << 24) - 1)
*/
#define DM_THIN_MIN_DATA_BLOCK_SIZE (UINT32_C(128))
#define DM_THIN_MAX_DATA_BLOCK_SIZE (UINT32_C(2097152))
-#define DM_THIN_MAX_DEVICE_ID (UINT32_C((1 << 24) - 1))
int dm_tree_node_add_thin_pool_target(struct dm_tree_node *node,
uint64_t size,
@@ -591,9 +589,18 @@
int dm_tree_node_add_thin_pool_message(struct dm_tree_node *node,
const struct dm_thin_message *message);
+/*
+ * FIXME: Defines bellow are based on kernel's dm-thin.c defines
+ * MAX_DEV_ID ((1 << 24) - 1)
+ */
+#define DM_THIN_MAX_DEVICE_ID (UINT32_C((1 << 24) - 1))
+/* Reserved device_id for error (deleted) thin device */
+// FIXME - only needed for in-delete thin is not activated
+#define DM_THIN_ERROR_DEVICE_ID (UINT32_MAX)
+
int dm_tree_node_add_thin_target(struct dm_tree_node *node,
uint64_t size,
- const char *thin_pool_uuid,
+ const char *pool_uuid,
uint32_t device_id);
void dm_tree_node_set_udev_flags(struct dm_tree_node *node, uint16_t udev_flags);
--- LVM2/libdm/libdm-deptree.c 2011/10/30 22:52:08 1.142
+++ LVM2/libdm/libdm-deptree.c 2011/11/03 14:43:21 1.143
@@ -2973,26 +2973,33 @@
int dm_tree_node_add_thin_target(struct dm_tree_node *node,
uint64_t size,
- const char *thin_pool_uuid,
+ const char *pool_uuid,
uint32_t device_id)
{
+ struct dm_tree_node *pool;
struct load_segment *seg;
- if (!_thin_validate_device_id(device_id))
- return_0;
-
- if (!(seg = _add_segment(node, SEG_THIN, size)))
- return_0;
-
- if (!(seg->pool = dm_tree_find_node_by_uuid(node->dtree, thin_pool_uuid))) {
- log_error("Missing thin pool uuid %s.", thin_pool_uuid);
+ if (!(pool = dm_tree_find_node_by_uuid(node->dtree, pool_uuid))) {
+ log_error("Missing thin pool uuid %s.", pool_uuid);
return 0;
}
- if (!_link_tree_nodes(node, seg->pool))
+ if (!_link_tree_nodes(node, pool))
return_0;
- seg->device_id = device_id;
+ if (device_id == DM_THIN_ERROR_DEVICE_ID) {
+ if (!dm_tree_node_add_error_target(node, size))
+ return_0;
+ } else {
+ if (!_thin_validate_device_id(device_id))
+ return_0;
+
+ if (!(seg = _add_segment(node, SEG_THIN, size)))
+ return_0;
+
+ seg->pool = pool;
+ seg->device_id = device_id;
+ }
return 1;
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* LVM2/libdm libdevmapper.h libdm-deptree.c
@ 2011-10-20 10:33 zkabelac
0 siblings, 0 replies; 7+ messages in thread
From: zkabelac @ 2011-10-20 10:33 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-10-20 10:33:31
Modified files:
libdm : libdevmapper.h libdm-deptree.c
Log message:
Adapt to thin kernel target API
Since kernel target uses low_water_mark - use this name in libdm as well.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.163&r2=1.164
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.135&r2=1.136
--- LVM2/libdm/libdevmapper.h 2011/10/20 10:31:27 1.163
+++ LVM2/libdm/libdevmapper.h 2011/10/20 10:33:30 1.164
@@ -552,7 +552,7 @@
const char *metadata_uuid,
const char *pool_uuid,
uint32_t data_block_size,
- uint64_t low_water_mark_size,
+ uint64_t low_water_mark,
unsigned skip_block_zeroing);
/* Supported messages for thin provision target */
--- LVM2/libdm/libdm-deptree.c 2011/10/20 10:31:27 1.135
+++ LVM2/libdm/libdm-deptree.c 2011/10/20 10:33:30 1.136
@@ -170,7 +170,7 @@
struct dm_tree_node *metadata; /* Thin_pool */
struct dm_tree_node *pool; /* Thin_pool, Thin */
struct dm_list thin_messages; /* Thin_pool */
- uint64_t low_water_mark_size; /* Thin_pool */
+ uint64_t low_water_mark; /* Thin_pool */
uint32_t data_block_size; /* Thin_pool */
unsigned skip_block_zeroing; /* Thin_pool */
uint32_t device_id; /* Thin */
@@ -2085,7 +2085,7 @@
if (!_build_dev_string(pool, sizeof(pool), seg->pool))
return_0;
EMIT_PARAMS(pos, "%s %s %d %" PRIu64 " %s", metadata, pool,
- seg->data_block_size, seg->low_water_mark_size,
+ seg->data_block_size, seg->low_water_mark,
seg->skip_block_zeroing ? "1 skip_block_zeroing" : "");
break;
case SEG_THIN:
@@ -2828,7 +2828,7 @@
const char *metadata_uuid,
const char *pool_uuid,
uint32_t data_block_size,
- uint64_t low_water_mark_size,
+ uint64_t low_water_mark,
unsigned skip_block_zeroing)
{
struct load_segment *seg;
@@ -2865,7 +2865,7 @@
return_0;
node->props.thin_pool_transaction_id = transaction_id; // compare on resume
- seg->low_water_mark_size = low_water_mark_size;
+ seg->low_water_mark = low_water_mark;
seg->data_block_size = data_block_size;
seg->skip_block_zeroing = skip_block_zeroing;
dm_list_init(&seg->thin_messages);
^ permalink raw reply [flat|nested] 7+ messages in thread
* LVM2/libdm libdevmapper.h libdm-deptree.c
@ 2011-10-17 14:16 zkabelac
0 siblings, 0 replies; 7+ messages in thread
From: zkabelac @ 2011-10-17 14:16 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-10-17 14:16:25
Modified files:
libdm : libdevmapper.h libdm-deptree.c
Log message:
Add thin_pool dm message support
Experimental support for kernel message via resume sequence.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.160&r2=1.161
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.127&r2=1.128
--- LVM2/libdm/libdevmapper.h 2011/10/17 14:15:01 1.160
+++ LVM2/libdm/libdevmapper.h 2011/10/17 14:16:25 1.161
@@ -555,6 +555,42 @@
uint64_t low_water_mark_size,
unsigned skip_block_zeroing);
+/* Supported messages for thin provision target */
+typedef enum {
+ DM_THIN_MESSAGE_CREATE_SNAP,
+ DM_THIN_MESSAGE_CREATE_THIN,
+ DM_THIN_MESSAGE_DELETE,
+ DM_THIN_MESSAGE_SET_TRANSACTION_ID,
+ DM_THIN_MESSAGE_TRIM
+} dm_thin_message_t;
+
+struct dm_thin_message {
+ dm_thin_message_t type;
+ union {
+ struct {
+ uint32_t device_id;
+ uint32_t origin_id;
+ } m_create_snap;
+ struct {
+ uint32_t device_id;
+ } m_create_thin;
+ struct {
+ uint32_t device_id;
+ } m_delete;
+ struct {
+ uint64_t current_id;
+ uint64_t new_id;
+ } m_set_transaction_id;
+ struct {
+ uint32_t device_id;
+ uint64_t new_size;
+ } m_trim;
+ } u;
+};
+
+int dm_tree_node_add_thin_pool_message(struct dm_tree_node *node,
+ struct dm_thin_message *message);
+
int dm_tree_node_add_thin_target(struct dm_tree_node *node,
uint64_t size,
const char *thin_pool_uuid,
--- LVM2/libdm/libdm-deptree.c 2011/10/17 14:15:26 1.127
+++ LVM2/libdm/libdm-deptree.c 2011/10/17 14:16:25 1.128
@@ -108,6 +108,11 @@
uint32_t flags; /* Replicator sync log flags */
};
+struct thin_message {
+ struct dm_list list;
+ struct dm_thin_message message;
+};
+
/* Replicator-log has a list of sites */
/* FIXME: maybe move to seg_area too? */
struct replicator_site {
@@ -163,6 +168,7 @@
struct dm_tree_node *metadata; /* Thin_pool */
struct dm_tree_node *pool; /* Thin_pool, Thin */
+ struct dm_list thin_messages; /* Thin_pool */
uint64_t low_water_mark_size; /* Thin_pool */
uint32_t data_block_size; /* Thin_pool */
unsigned skip_block_zeroing; /* Thin_pool */
@@ -1211,50 +1217,159 @@
return r;
}
-static int _check_thin_pool_transaction_id(const char *name, uint32_t major, uint32_t minor,
- uint64_t transaction_id)
+static int _thin_pool_status_transaction_id(struct dm_tree_node *dnode, uint64_t *transaction_id)
{
struct dm_task *dmt;
int r = 0;
uint64_t start, length;
char *type = NULL;
char *params = NULL;
- uint64_t t_id = transaction_id; // FIXME: fake
- log_verbose("Checking transaction id %s (%" PRIu32 ":%" PRIu32 ")", name, major, minor);
+ if (!(dmt = dm_task_create(DM_DEVICE_STATUS)))
+ return_0;
- if (!(dmt = dm_task_create(DM_DEVICE_STATUS))) {
- log_debug("Device status dm_task creation failed for %s.", name);
- return 0;
+ if (!dm_task_set_major(dmt, dnode->info.major) ||
+ !dm_task_set_minor(dmt, dnode->info.minor)) {
+ log_error("Failed to set major minor.");
+ goto out;
}
- if (!dm_task_set_name(dmt, name)) {
- log_debug("Failed to set device name for %s status.", name);
+ if (!dm_task_run(dmt))
+ goto_out;
+
+ dm_get_next_target(dmt, NULL, &start, &length, &type, ¶ms);
+
+ if (type && (strcmp(type, "thin-pool") != 0)) {
+ log_error(INTERNAL_ERROR
+ "Expected thin-pool target for %d:%d and got %s.",
+ dnode->info.major, dnode->info.minor, type);
goto out;
}
- if (!dm_task_set_major_minor(dmt, major, minor, 1)) {
- log_error("Failed to set device number for %s status.", name);
+ if (!params || (sscanf(params, "%" PRIu64, transaction_id) != 1)) {
+ log_error(INTERNAL_ERROR
+ "Failed to parse transaction_id from %s.", params);
goto out;
}
- if (!dm_task_no_open_count(dmt))
- log_error("Failed to disable open_count");
+ log_debug("Thin pool transaction id: %" PRIu64 " status: %s.", *transaction_id, params);
- if (!(r = dm_task_run(dmt)))
- goto_out;
+ r = 1;
+out:
+ dm_task_destroy(dmt);
- dm_get_next_target(dmt, NULL, &start, &length, &type, ¶ms);
- log_verbose("PARSE params %s", params); // FIXME: parse status
+ return r;
+}
- r = (transaction_id == t_id);
+static int _thin_pool_node_message(struct dm_tree_node *dnode, struct thin_message *tm)
+{
+ struct dm_task *dmt;
+ struct dm_thin_message *m = &tm->message;
+ char buf[64];
+ int r;
+ switch (m->type) {
+ case DM_THIN_MESSAGE_CREATE_SNAP:
+ r = dm_snprintf(buf, sizeof(buf), "create_snap %u %u",
+ m->u.m_create_snap.device_id,
+ m->u.m_create_snap.origin_id);
+ break;
+ case DM_THIN_MESSAGE_CREATE_THIN:
+ r = dm_snprintf(buf, sizeof(buf), "create_thin %u",
+ m->u.m_create_thin.device_id);
+ break;
+ case DM_THIN_MESSAGE_DELETE:
+ r = dm_snprintf(buf, sizeof(buf), "delete %u",
+ m->u.m_delete.device_id);
+ break;
+ case DM_THIN_MESSAGE_TRIM:
+ r = dm_snprintf(buf, sizeof(buf), "trim %u %" PRIu64,
+ m->u.m_trim.device_id,
+ m->u.m_trim.new_size);
+ break;
+ case DM_THIN_MESSAGE_SET_TRANSACTION_ID:
+ r = dm_snprintf(buf, sizeof(buf),
+ "set_transaction_id %" PRIu64 " %" PRIu64,
+ m->u.m_set_transaction_id.current_id,
+ m->u.m_set_transaction_id.new_id);
+ break;
+ }
+
+ if (!r) {
+ log_error("Failed to prepare message.");
+ return 0;
+ }
+
+ r = 0;
+
+ if (!(dmt = dm_task_create(DM_DEVICE_TARGET_MSG)))
+ return_0;
+
+ if (!dm_task_set_major(dmt, dnode->info.major) ||
+ !dm_task_set_minor(dmt, dnode->info.minor)) {
+ log_error("Failed to set message major minor.");
+ goto out;
+ }
+
+ if (!dm_task_set_message(dmt, buf))
+ goto_out;
+
+ if (!dm_task_run(dmt))
+ goto_out;
+
+ r = 1;
out:
dm_task_destroy(dmt);
return r;
}
+static int _thin_pool_node_send_messages(struct dm_tree_node *dnode,
+ const char *uuid_prefix,
+ size_t uuid_prefix_len)
+{
+ struct load_segment *seg;
+ struct thin_message *tmsg;
+ uint64_t current_id;
+ const char *uuid;
+
+ if ((dnode == &dnode->dtree->root) || /* root has rops.segs uninitialized */
+ (dm_list_size(&dnode->props.segs) != 1))
+ return 1;
+
+ seg = dm_list_item(dm_list_last(&dnode->props.segs), struct load_segment);
+
+ if (seg->type != SEG_THIN_POOL)
+ return 1;
+
+ if (!(uuid = dm_tree_node_get_uuid(dnode)))
+ return_0;
+
+ if (!_uuid_prefix_matches(uuid, uuid_prefix, uuid_prefix_len)) {
+ log_debug("UUID \"%s\" does not match.", uuid);
+ return 1;
+ }
+
+ if (!_thin_pool_status_transaction_id(dnode, ¤t_id))
+ return_0;
+
+ log_debug("Expecting transaction_id: %" PRIu64, dnode->props.thin_pool_transaction_id);
+ if (current_id == dnode->props.thin_pool_transaction_id)
+ return 1; /* In sync - skip messages */
+
+ if (current_id != (dnode->props.thin_pool_transaction_id - 1)) {
+ log_error("Thin pool transaction_id=%" PRIu64 ", while expected: %" PRIu64 ".",
+ current_id, dnode->props.thin_pool_transaction_id - 1);
+ return 0; /* Nothing to send */
+ }
+
+ dm_list_iterate_items(tmsg, &seg->thin_messages)
+ if (!(_thin_pool_node_message(dnode, tmsg)))
+ return_0;
+
+ return 1;
+}
+
/*
* FIXME Don't attempt to deactivate known internal dependencies.
*/
@@ -2205,6 +2320,13 @@
dm_tree_set_cookie(dnode, 0);
}
+ if (r && !_thin_pool_node_send_messages(dnode, uuid_prefix, uuid_prefix_len)) {
+ stack;
+ if (!(dm_tree_deactivate_children(dnode, uuid_prefix, uuid_prefix_len)))
+ log_error("Failed to deactivate %s", dnode->name);
+ r = 0;
+ }
+
return r;
}
@@ -2744,6 +2866,82 @@
seg->low_water_mark_size = low_water_mark_size;
seg->data_block_size = data_block_size;
seg->skip_block_zeroing = skip_block_zeroing;
+ dm_list_init(&seg->thin_messages);
+
+ return 1;
+}
+
+int dm_tree_node_add_thin_pool_message(struct dm_tree_node *node,
+ struct dm_thin_message *message)
+{
+ struct load_segment *seg;
+ struct thin_message *tm;
+
+ if (node->props.segment_count != 1) {
+ log_error(INTERNAL_ERROR "Attempt to use non thin pool segment.");
+ return 0;
+ }
+
+ seg = dm_list_item(dm_list_last(&node->props.segs), struct load_segment);
+
+ if (seg->type != SEG_THIN_POOL) {
+ log_error(INTERNAL_ERROR "Attempt to use non thin pool segment %s.",
+ dm_segtypes[seg->type].target);
+ return 0;
+ }
+
+ if (!(tm = dm_pool_zalloc(node->dtree->mem, sizeof (*tm)))) {
+ log_error("Failed to allocate thin message.");
+ return 0;
+ }
+
+ switch (message->type) {
+ case DM_THIN_MESSAGE_CREATE_SNAP:
+ /* Origin MUST be suspend! */
+ if (message->u.m_create_snap.device_id == message->u.m_create_snap.origin_id) {
+ log_error("Same origin used for thin snapshot.");
+ return 0;
+ }
+ if (!_thin_validate_device_id(message->u.m_create_snap.device_id) ||
+ !_thin_validate_device_id(message->u.m_create_snap.origin_id))
+ return_0;
+ tm->message.u.m_create_snap.device_id = message->u.m_create_snap.device_id;
+ tm->message.u.m_create_snap.origin_id = message->u.m_create_snap.origin_id;
+ break;
+ case DM_THIN_MESSAGE_CREATE_THIN:
+ if (!_thin_validate_device_id(message->u.m_create_thin.device_id))
+ return_0;
+ tm->message.u.m_create_thin.device_id = message->u.m_create_thin.device_id;
+ break;
+ case DM_THIN_MESSAGE_DELETE:
+ if (!_thin_validate_device_id(message->u.m_delete.device_id))
+ return_0;
+ tm->message.u.m_delete.device_id = message->u.m_delete.device_id;
+ break;
+ case DM_THIN_MESSAGE_TRIM:
+ if (!_thin_validate_device_id(message->u.m_trim.device_id))
+ return_0;
+ tm->message.u.m_trim.device_id = message->u.m_trim.device_id;
+ tm->message.u.m_trim.new_size = message->u.m_trim.new_size;
+ break;
+ case DM_THIN_MESSAGE_SET_TRANSACTION_ID:
+ if (message->u.m_set_transaction_id.current_id !=
+ (message->u.m_set_transaction_id.new_id - 1)) {
+ log_error("New transaction_id must be sequential.");
+ return 0; /* FIXME: Maybe too strict here? */
+ }
+ tm->message.u.m_set_transaction_id.current_id =
+ message->u.m_set_transaction_id.current_id;
+ tm->message.u.m_set_transaction_id.new_id =
+ message->u.m_set_transaction_id.new_id;
+ break;
+ default:
+ log_error("Unsupported message type %d.", (int) message->type);
+ return 0;
+ }
+
+ tm->message.type = message->type;
+ dm_list_add(&seg->thin_messages, &tm->list);
return 1;
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* LVM2/libdm libdevmapper.h libdm-deptree.c
@ 2011-10-17 14:15 zkabelac
0 siblings, 0 replies; 7+ messages in thread
From: zkabelac @ 2011-10-17 14:15 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-10-17 14:15:01
Modified files:
libdm : libdevmapper.h libdm-deptree.c
Log message:
Swap parameters
Use metadata uuid first (match kernel target).
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.159&r2=1.160
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.125&r2=1.126
--- LVM2/libdm/libdevmapper.h 2011/10/06 14:45:42 1.159
+++ LVM2/libdm/libdevmapper.h 2011/10/17 14:15:01 1.160
@@ -549,8 +549,8 @@
int dm_tree_node_add_thin_pool_target(struct dm_tree_node *node,
uint64_t size,
uint64_t transaction_id,
- const char *pool_uuid,
const char *metadata_uuid,
+ const char *pool_uuid,
uint32_t data_block_size,
uint64_t low_water_mark_size,
unsigned skip_block_zeroing);
--- LVM2/libdm/libdm-deptree.c 2011/10/17 14:14:33 1.125
+++ LVM2/libdm/libdm-deptree.c 2011/10/17 14:15:01 1.126
@@ -2690,8 +2690,8 @@
int dm_tree_node_add_thin_pool_target(struct dm_tree_node *node,
uint64_t size,
uint64_t transaction_id,
- const char *pool_uuid,
const char *metadata_uuid,
+ const char *pool_uuid,
uint32_t data_block_size,
uint64_t low_water_mark_size,
unsigned skip_block_zeroing)
^ permalink raw reply [flat|nested] 7+ messages in thread
* LVM2/libdm libdevmapper.h libdm-deptree.c
@ 2011-10-03 18:34 zkabelac
0 siblings, 0 replies; 7+ messages in thread
From: zkabelac @ 2011-10-03 18:34 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-10-03 18:34:52
Modified files:
libdm : libdevmapper.h libdm-deptree.c
Log message:
Add intial code to check transaction_id
Fix typy in transaction_id.
Add this as node property, so it could be easily checked on resume.
Code is not yet finished.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.155&r2=1.156
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.118&r2=1.119
--- LVM2/libdm/libdevmapper.h 2011/10/03 18:26:07 1.155
+++ LVM2/libdm/libdevmapper.h 2011/10/03 18:34:52 1.156
@@ -538,7 +538,7 @@
/* API for thin provisioning is experimental, DO NOT USE. */
int dm_tree_node_add_thin_pool_target(struct dm_tree_node *node,
uint64_t size,
- uint64_t transation_id,
+ uint64_t transaction_id,
const char *pool_uuid,
const char *metadata_uuid,
uint32_t data_block_size,
--- LVM2/libdm/libdm-deptree.c 2011/10/03 18:29:48 1.118
+++ LVM2/libdm/libdm-deptree.c 2011/10/03 18:34:52 1.119
@@ -169,8 +169,8 @@
struct dm_tree_node *metadata; /* Thin_pool */
struct dm_tree_node *pool; /* Thin_pool, Thin */
- uint32_t data_block_size; /* Thin_pool */
uint64_t low_water_mark; /* Thin_pool */
+ uint32_t data_block_size; /* Thin_pool */
unsigned skip_block_zeroeing; /* Thin_pool */
uint32_t device_id; /* Thin */
@@ -185,6 +185,8 @@
uint32_t read_ahead;
uint32_t read_ahead_flags;
+ uint64_t thin_pool_transaction_id; /* Thin_pool */
+
unsigned segment_count;
unsigned size_changed;
struct dm_list segs;
@@ -1207,6 +1209,50 @@
return r;
}
+static int _check_thin_pool_transaction_id(const char *name, uint32_t major, uint32_t minor,
+ uint64_t transaction_id)
+{
+ struct dm_task *dmt;
+ int r = 0;
+ uint64_t start, length;
+ char *type = NULL;
+ char *params = NULL;
+ uint64_t t_id = transaction_id; // FIXME: fake
+
+ log_verbose("Checking transaction id %s (%" PRIu32 ":%" PRIu32 ")", name, major, minor);
+
+ if (!(dmt = dm_task_create(DM_DEVICE_STATUS))) {
+ log_debug("Device status dm_task creation failed for %s.", name);
+ return 0;
+ }
+
+ if (!dm_task_set_name(dmt, name)) {
+ log_debug("Failed to set device name for %s status.", name);
+ goto out;
+ }
+
+ if (!dm_task_set_major_minor(dmt, major, minor, 1)) {
+ log_error("Failed to set device number for %s status.", name);
+ goto out;
+ }
+
+ if (!dm_task_no_open_count(dmt))
+ log_error("Failed to disable open_count");
+
+ if (!(r = dm_task_run(dmt)))
+ goto_out;
+
+ dm_get_next_target(dmt, NULL, &start, &length, &type, ¶ms);
+ log_verbose("PARSE params %s", params); // FIXME: parse status
+
+ r = (transaction_id == t_id);
+
+out:
+ dm_task_destroy(dmt);
+
+ return r;
+}
+
/*
* FIXME Don't attempt to deactivate known internal dependencies.
*/
@@ -1464,6 +1510,18 @@
/* Update cached info */
child->info = newinfo;
+
+ /* FIXME: trial version - to avoid use of unsynchronized thin_pool transaction_id */
+ if (child->props.thin_pool_transaction_id &&
+ !_check_thin_pool_transaction_id(child->name, child->info.major,
+ child->info.minor,
+ child->props.thin_pool_transaction_id)) {
+ stack;
+ if (!(dm_tree_deactivate_children(child, uuid_prefix, uuid_prefix_len)))
+ log_error("Failed to deactivate %s", child->name);
+ r = 0;
+ continue;
+ }
}
}
@@ -2148,6 +2206,17 @@
if (child->props.immediate_dev_node)
update_devs_flag = 1;
+ /* FIXME: trial version - to avoid use of unsynchronized thin_pool transaction_id */
+ if (child->props.thin_pool_transaction_id &&
+ !_check_thin_pool_transaction_id(child->name, child->info.major,
+ child->info.minor,
+ child->props.thin_pool_transaction_id)) {
+ stack;
+ if (!(dm_tree_deactivate_children(child, uuid_prefix, uuid_prefix_len)))
+ log_error("Failed to deactivate %s", child->name);
+ r = 0;
+ continue;
+ }
}
handle = NULL;
@@ -2642,7 +2711,7 @@
int dm_tree_node_add_thin_pool_target(struct dm_tree_node *node,
uint64_t size,
- uint64_t transation_id,
+ uint64_t transaction_id,
const char *pool_uuid,
const char *metadata_uuid,
uint32_t data_block_size,
@@ -2684,8 +2753,9 @@
if (!_link_tree_nodes(node, seg->pool))
return_0;
- seg->data_block_size = data_block_size;
+ node->props.thin_pool_transaction_id = transaction_id; // compare on resume
seg->low_water_mark = low_water_mark;
+ seg->data_block_size = data_block_size;
seg->skip_block_zeroeing = skip_block_zeroeing;
return 1;
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-12-21 12:52 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-04 16:22 LVM2/libdm libdevmapper.h libdm-deptree.c zkabelac
-- strict thread matches above, loose matches on Subject: below --
2011-12-21 12:52 zkabelac
2011-11-03 14:43 zkabelac
2011-10-20 10:33 zkabelac
2011-10-17 14:16 zkabelac
2011-10-17 14:15 zkabelac
2011-10-03 18:34 zkabelac
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).