public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 lib/thin/thin.c libdm/libdevmapper.h libd ...
@ 2011-11-03 14:45 zkabelac
  0 siblings, 0 replies; 4+ messages in thread
From: zkabelac @ 2011-11-03 14:45 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-11-03 14:45:01

Modified files:
	lib/thin       : thin.c 
	libdm          : libdevmapper.h libdm-deptree.c 

Log message:
	Thin api change for passing message into libdm
	
	Avoid exposing another struct to the libdm user and
	use only simple dm_tree_node_add_thin_pool_message with
	2 overloaded uint64_t values.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/thin/thin.c.diff?cvsroot=lvm2&r1=1.28&r2=1.29
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.167&r2=1.168
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.143&r2=1.144

--- LVM2/lib/thin/thin.c	2011/11/03 14:37:23	1.28
+++ LVM2/lib/thin/thin.c	2011/11/03 14:45:01	1.29
@@ -222,7 +222,6 @@
 {
 	char *metadata_dlid, *pool_dlid;
 	const struct lv_thin_message *lmsg;
-	struct dm_thin_message dmsg;
 
 	if (!(metadata_dlid = build_dm_uuid(mem, seg->pool_metadata_lv->lvid.s, NULL))) {
 		log_error("Failed to build uuid for metadata LV %s.",
@@ -243,27 +242,30 @@
 		return_0;
 
 	dm_list_iterate_items(lmsg, &seg->thin_messages) {
-		dmsg.type = lmsg->type;
 		switch (lmsg->type) {
 		case DM_THIN_MESSAGE_CREATE_SNAP:
 			/* FIXME: to be implemented */
 			log_debug("Thin pool create_snap %s.", lmsg->u.lv->name);
-			dmsg.u.m_create_snap.device_id = first_seg(lmsg->u.lv)->device_id;
-			dmsg.u.m_create_snap.origin_id = 0;//first_seg(first_seg(lmsg->u.lv)->origin)->device_id;
-			if (!dm_tree_node_add_thin_pool_message(node, &dmsg))
+			if (!dm_tree_node_add_thin_pool_message(node,
+								lmsg->type,
+								first_seg(lmsg->u.lv)->device_id,
+								0))//first_seg(first_seg(lmsg->u.lv)->origin)->device_id;
 				return_0;
 			log_error("Sorry SNAPSHOT is not yet supported.");
 			return 0;
 		case DM_THIN_MESSAGE_CREATE_THIN:
 			log_debug("Thin pool create_thin %s.", lmsg->u.lv->name);
-			dmsg.u.m_create_thin.device_id = first_seg(lmsg->u.lv)->device_id;
-			if (!dm_tree_node_add_thin_pool_message(node, &dmsg))
+			if (!dm_tree_node_add_thin_pool_message(node,
+								lmsg->type,
+								first_seg(lmsg->u.lv)->device_id,
+								0))
 				return_0;
 			break;
 		case DM_THIN_MESSAGE_DELETE:
 			log_debug("Thin pool delete %u.", lmsg->u.delete_id);
-			dmsg.u.m_delete.device_id = lmsg->u.delete_id;
-			if (!dm_tree_node_add_thin_pool_message(node, &dmsg))
+			if (!dm_tree_node_add_thin_pool_message(node,
+								lmsg->type,
+								lmsg->u.delete_id, 0))
 				return_0;
 			break;
 		case DM_THIN_MESSAGE_TRIM:
@@ -278,11 +280,11 @@
 
 	if (!dm_list_empty(&seg->thin_messages)) {
 		/* Messages were passed, modify transaction_id as the last one */
-		log_debug("Thin pool set_transaction_id %" PRIu64 ".", seg->transaction_id);
-		dmsg.type = DM_THIN_MESSAGE_SET_TRANSACTION_ID;
-		dmsg.u.m_set_transaction_id.current_id = seg->transaction_id - 1;
-		dmsg.u.m_set_transaction_id.new_id = seg->transaction_id;
-		if (!dm_tree_node_add_thin_pool_message(node, &dmsg))
+		log_debug("Thin pool set transaction id %" PRIu64 ".", seg->transaction_id);
+		if (!dm_tree_node_add_thin_pool_message(node,
+							DM_THIN_MESSAGE_SET_TRANSACTION_ID,
+							seg->transaction_id - 1,
+							seg->transaction_id))
 			return_0;
 	}
 
--- LVM2/libdm/libdevmapper.h	2011/11/03 14:43:21	1.167
+++ LVM2/libdm/libdevmapper.h	2011/11/03 14:45:01	1.168
@@ -555,39 +555,16 @@
 
 /* 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_CREATE_SNAP,		/* device_id, origin_id */
+	DM_THIN_MESSAGE_CREATE_THIN,		/* device_id */
+	DM_THIN_MESSAGE_DELETE,			/* device_id */
+	DM_THIN_MESSAGE_SET_TRANSACTION_ID,	/* current_id, new_id */
+	DM_THIN_MESSAGE_TRIM			/* device_id, new_size */
 } 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,
-                                       const struct dm_thin_message *message);
+				       dm_thin_message_t type,
+				       uint64_t id1, uint64_t id2);
 
 /*
  * FIXME: Defines bellow are based on kernel's dm-thin.c defines
--- LVM2/libdm/libdm-deptree.c	2011/11/03 14:43:21	1.143
+++ LVM2/libdm/libdm-deptree.c	2011/11/03 14:45:01	1.144
@@ -108,6 +108,30 @@
 	uint32_t flags;			/* Replicator sync log flags */
 };
 
+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;
+};
+
 struct thin_message {
 	struct dm_list list;
 	struct dm_thin_message message;
@@ -2901,7 +2925,8 @@
 }
 
 int dm_tree_node_add_thin_pool_message(struct dm_tree_node *node,
-				       const struct dm_thin_message *message)
+				       dm_thin_message_t type,
+				       uint64_t id1, uint64_t id2)
 {
 	struct load_segment *seg;
 	struct thin_message *tm;
@@ -2923,49 +2948,55 @@
 		return 0;
 	}
 
-	switch (message->type) {
+	switch (type) {
 	case DM_THIN_MESSAGE_CREATE_SNAP:
 		/* If the thin origin is active, it must be suspend first! */
-		if (message->u.m_create_snap.device_id == message->u.m_create_snap.origin_id) {
+		if (id1 == id2) {
 			log_error("Cannot use same device id for origin and its 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))
+		if (!_thin_validate_device_id(id1) ||
+		    !_thin_validate_device_id(id2))
 			return_0;
-		tm->message.u.m_create_snap = message->u.m_create_snap;
+		tm->message.u.m_create_snap.device_id = id1;
+		tm->message.u.m_create_snap.origin_id = id2;
 		break;
 	case DM_THIN_MESSAGE_CREATE_THIN:
-		if (!_thin_validate_device_id(message->u.m_create_thin.device_id))
+		if (!_thin_validate_device_id(id1))
 			return_0;
-		tm->message.u.m_create_thin = message->u.m_create_thin;
+		tm->message.u.m_create_thin.device_id = id1;
 		tm->expected_errno = EEXIST;
 		break;
 	case DM_THIN_MESSAGE_DELETE:
-		if (!_thin_validate_device_id(message->u.m_delete.device_id))
+		if (!_thin_validate_device_id(id1))
 			return_0;
-		tm->message.u.m_delete = message->u.m_delete;
+		tm->message.u.m_delete.device_id = id1;
 		tm->expected_errno = ENODATA;
 		break;
 	case DM_THIN_MESSAGE_TRIM:
-		if (!_thin_validate_device_id(message->u.m_trim.device_id))
+		if (!_thin_validate_device_id(id1))
 			return_0;
-		tm->message.u.m_trim = message->u.m_trim;
+		tm->message.u.m_trim.device_id = id1;
+		tm->message.u.m_trim.new_size = id2;
 		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.");
+		if ((id1 + 1) !=  id2) {
+			log_error("New transaction id must be sequential.");
+			return 0; /* FIXME: Maybe too strict here? */
+		}
+		if (id1 !=  seg->transaction_id) {
+			log_error("Current transaction id is different from thin pool.");
 			return 0; /* FIXME: Maybe too strict here? */
 		}
-		tm->message.u.m_set_transaction_id = message->u.m_set_transaction_id;
+		tm->message.u.m_set_transaction_id.current_id = id1;
+		tm->message.u.m_set_transaction_id.new_id = id2;
 		break;
 	default:
-		log_error("Unsupported message type %d.", (int) message->type);
+		log_error("Unsupported message type %d.", (int) type);
 		return 0;
 	}
 
-	tm->message.type = message->type;
+	tm->message.type = type;
 	dm_list_add(&seg->thin_messages, &tm->list);
 
 	return 1;


^ permalink raw reply	[flat|nested] 4+ messages in thread

* LVM2 lib/thin/thin.c libdm/libdevmapper.h libd ...
@ 2011-11-12 22:44 zkabelac
  0 siblings, 0 replies; 4+ messages in thread
From: zkabelac @ 2011-11-12 22:44 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-11-12 22:44:11

Modified files:
	lib/thin       : thin.c 
	libdm          : libdevmapper.h libdm-deptree.c 
	tools          : lvm.c toollib.c 

Log message:
	Thin remove unused define
	
	Remove DM_THIN_ERROR_DEVICE_ID from API.
	Remove API warning.
	Drop code that was using DM_THIN_ERROR_DEVICE_ID (already commented)
	Remove debug message which slipped in through some previous commit.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/thin/thin.c.diff?cvsroot=lvm2&r1=1.32&r2=1.33
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.168&r2=1.169
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.145&r2=1.146
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvm.c.diff?cvsroot=lvm2&r1=1.115&r2=1.116
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.234&r2=1.235

--- LVM2/lib/thin/thin.c	2011/11/10 15:30:59	1.32
+++ LVM2/lib/thin/thin.c	2011/11/12 22:44:10	1.33
@@ -230,8 +230,6 @@
 			return 0;
 		}
 
-		//if (!dm_tree_node_add_thin_target(node, len, pool_dlid,
-		//				    DM_THIN_ERROR_DEVICE_ID))
 		if (!dm_tree_node_add_linear_target(node, len) ||
 		    !dm_tree_node_add_target_area(node, NULL, pool_dlid, 0))
 			return_0;
--- LVM2/libdm/libdevmapper.h	2011/11/03 14:45:01	1.168
+++ LVM2/libdm/libdevmapper.h	2011/11/12 22:44:10	1.169
@@ -535,7 +535,6 @@
 					   uint32_t slog_region_size);
 /* End of Replicator API */
 
-/* API for thin provisioning is experimental, DO NOT USE. */
 /*
  * FIXME: Defines bellow are based on kernel's dm-thin.c defines
  * DATA_DEV_BLOCK_SIZE_MIN_SECTORS (64 * 1024 >> SECTOR_SHIFT)
@@ -571,10 +570,6 @@
  * 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 *pool_uuid,
--- LVM2/libdm/libdm-deptree.c	2011/11/04 12:39:45	1.145
+++ LVM2/libdm/libdm-deptree.c	2011/11/12 22:44:10	1.146
@@ -3018,19 +3018,14 @@
 	if (!_link_tree_nodes(node, pool))
 		return_0;
 
-	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 (!_thin_validate_device_id(device_id))
+		return_0;
 
-		if (!(seg = _add_segment(node, SEG_THIN, size)))
-			return_0;
+	if (!(seg = _add_segment(node, SEG_THIN, size)))
+		return_0;
 
-		seg->pool = pool;
-		seg->device_id = device_id;
-	}
+	seg->pool = pool;
+	seg->device_id = device_id;
 
 	return 1;
 }
--- LVM2/tools/lvm.c	2010/11/11 17:29:06	1.115
+++ LVM2/tools/lvm.c	2011/11/12 22:44:11	1.116
@@ -167,7 +167,6 @@
 
 	stifle_history(find_config_tree_int(cmd, "shell/history_size",
 				       DEFAULT_MAX_HISTORY));
-
 }
 
 static void _write_history(void)
--- LVM2/tools/toollib.c	2011/11/10 12:43:05	1.234
+++ LVM2/tools/toollib.c	2011/11/12 22:44:11	1.235
@@ -329,7 +329,6 @@
 		dm_list_iterate_items(sll, &arg_lvnames) {
 			const char *vg_name = sll->str;
 			const char *lv_name = strchr(vg_name, '/');
-log_error("VGNAME strdup %p %s   %s", lv_name, vg_name,  vgname);
 
 			if ((!lv_name && !strcmp(vg_name, vgname))) {
 				/* Process all LVs in this VG */


^ permalink raw reply	[flat|nested] 4+ messages in thread

* LVM2 lib/thin/thin.c libdm/libdevmapper.h libd ...
@ 2011-10-20 10:31 zkabelac
  0 siblings, 0 replies; 4+ messages in thread
From: zkabelac @ 2011-10-20 10:31 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-10-20 10:31:27

Modified files:
	lib/thin       : thin.c 
	libdm          : libdevmapper.h libdm-deptree.c 

Log message:
	Use const pointers in thin API were appropriate

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/thin/thin.c.diff?cvsroot=lvm2&r1=1.20&r2=1.21
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.162&r2=1.163
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.134&r2=1.135

--- LVM2/lib/thin/thin.c	2011/10/20 10:30:39	1.20
+++ LVM2/lib/thin/thin.c	2011/10/20 10:31:27	1.21
@@ -150,7 +150,7 @@
 static int _thin_pool_text_export(const struct lv_segment *seg, struct formatter *f)
 {
 	unsigned cnt = 0;
-	struct lv_thin_message *tmsg;
+	const struct lv_thin_message *tmsg;
 
 	outf(f, "pool = \"%s\"", seg_lv(seg, 0)->name);
 	outf(f, "metadata = \"%s\"", seg->pool_metadata_lv->name);
@@ -220,7 +220,7 @@
 				      uint32_t *pvmove_mirror_count __attribute__((unused)))
 {
 	char *metadata_dlid, *pool_dlid;
-	struct lv_thin_message *lmsg;
+	const struct lv_thin_message *lmsg;
 	struct dm_thin_message dmsg;
 
 	if (!(metadata_dlid = build_dm_uuid(mem, seg->pool_metadata_lv->lvid.s, NULL))) {
--- LVM2/libdm/libdevmapper.h	2011/10/20 10:28:42	1.162
+++ LVM2/libdm/libdevmapper.h	2011/10/20 10:31:27	1.163
@@ -589,7 +589,7 @@
 };
 
 int dm_tree_node_add_thin_pool_message(struct dm_tree_node *node,
-                                       struct dm_thin_message *message);
+                                       const struct dm_thin_message *message);
 
 int dm_tree_node_add_thin_target(struct dm_tree_node *node,
 				 uint64_t size,
--- LVM2/libdm/libdm-deptree.c	2011/10/20 10:28:42	1.134
+++ LVM2/libdm/libdm-deptree.c	2011/10/20 10:31:27	1.135
@@ -2874,7 +2874,7 @@
 }
 
 int dm_tree_node_add_thin_pool_message(struct dm_tree_node *node,
-				       struct dm_thin_message *message)
+				       const struct dm_thin_message *message)
 {
 	struct load_segment *seg;
 	struct thin_message *tm;


^ permalink raw reply	[flat|nested] 4+ messages in thread

* LVM2 lib/thin/thin.c libdm/libdevmapper.h libd ...
@ 2011-10-03 18:26 zkabelac
  0 siblings, 0 replies; 4+ messages in thread
From: zkabelac @ 2011-10-03 18:26 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-10-03 18:26:08

Modified files:
	lib/thin       : thin.c 
	libdm          : libdevmapper.h libdm-deptree.c 

Log message:
	Transaction_id is property of thin_pool
	
	Remove Transaction_id from thin target.
	Store device_id for thin target.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/thin/thin.c.diff?cvsroot=lvm2&r1=1.13&r2=1.14
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.154&r2=1.155
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.115&r2=1.116

--- LVM2/lib/thin/thin.c	2011/09/29 08:56:39	1.13
+++ LVM2/lib/thin/thin.c	2011/10/03 18:26:07	1.14
@@ -199,7 +199,7 @@
 		return 0;
 	}
 
-	if (!dm_tree_node_add_thin_target(node, len, 0, thin_pool_dlid, seg->device_id))
+	if (!dm_tree_node_add_thin_target(node, len, thin_pool_dlid, seg->device_id))
 		return_0;
 
 	return 1;
--- LVM2/libdm/libdevmapper.h	2011/09/29 08:53:48	1.154
+++ LVM2/libdm/libdevmapper.h	2011/10/03 18:26:07	1.155
@@ -547,7 +547,6 @@
 
 int dm_tree_node_add_thin_target(struct dm_tree_node *node,
 				 uint64_t size,
-				 uint64_t transation_id,
 				 const char *thin_pool_uuid,
 				 uint32_t device_id);
 
--- LVM2/libdm/libdm-deptree.c	2011/09/29 08:53:48	1.115
+++ LVM2/libdm/libdm-deptree.c	2011/10/03 18:26:07	1.116
@@ -2690,7 +2690,6 @@
 
 int dm_tree_node_add_thin_target(struct dm_tree_node *node,
 				 uint64_t size,
-				 uint64_t transation_id,
 				 const char *thin_pool_uuid,
 				 uint32_t device_id)
 {
@@ -2713,6 +2712,8 @@
 	if (!_link_tree_nodes(node, seg->pool))
 		return_0;
 
+	seg->device_id = device_id;
+
 	return 1;
 }
 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-11-12 22:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-03 14:45 LVM2 lib/thin/thin.c libdm/libdevmapper.h libd zkabelac
  -- strict thread matches above, loose matches on Subject: below --
2011-11-12 22:44 zkabelac
2011-10-20 10:31 zkabelac
2011-10-03 18:26 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).