Skip to contentSkip to conversation

master - thin: move alloc_pool_metadata

PATCH Zdenek Kabelac 1 participant 1 message Jul 4, 2013

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f88f5a1ca3b0c77a2c353460ff35d802bbb05a34
Commit:        f88f5a1ca3b0c77a2c353460ff35d802bbb05a34
Parent:        f88497079778b00fe5ed9a43d890af64d272c325
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Thu Jul 4 11:04:05 2013 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Thu Jul 4 13:33:41 2013 +0200

thin: move alloc_pool_metadata

Move function from /tool to /lib to thin_manip.c Since lvm2api will need to move many things into /lib anyway.

---
 lib/metadata/metadata-exported.h |    5 ++++
 lib/metadata/thin_manip.c        |   40 ++++++++++++++++++++++++++++++++++
 tools/lvconvert.c                |    9 ++++---
 tools/toollib.c                  |   44 --------------------------------------
 tools/toollib.h                  |    5 ----
 5 files changed, 50 insertions(+), 53 deletions(-)
lib/metadata/metadata-exported.h +5 -0
index 7b7ac3c..ee3ae66 100644
@@ -657,6 +657,11 @@ int update_pool_params(struct cmd_context *cmd, unsigned attr, int passed_args,
 		       uint64_t *pool_metadata_size);
 int get_pool_discards(const char *str, thin_discards_t *discards);
 const char *get_pool_discards_name(thin_discards_t discards);
+struct logical_volume *alloc_pool_metadata(struct logical_volume *pool_lv,
+					   const char *name, uint32_t read_ahead,
+					   uint32_t stripes, uint32_t stripe_size,
+					   uint64_t size, alloc_policy_t alloc,
+					   struct dm_list *pvh);
 
 /*
  * Activation options
lib/metadata/thin_manip.c +40 -0
index 4ff647a..f40fd74 100644
@@ -681,3 +681,43 @@ const char *get_pool_discards_name(thin_discards_t discards)
 
 	return "unknown";
 }
+
+struct logical_volume *alloc_pool_metadata(struct logical_volume *pool_lv,
+					   const char *name, uint32_t read_ahead,
+					   uint32_t stripes, uint32_t stripe_size,
+					   uint64_t size, alloc_policy_t alloc,
+					   struct dm_list *pvh)
+{
+	struct logical_volume *metadata_lv;
+	/* FIXME: Make lvm2api usable */
+	struct lvcreate_params lvc = {
+		.activate = CHANGE_ALY,
+		.alloc = alloc,
+		.lv_name = name,
+		.major = -1,
+		.minor = -1,
+		.permission = LVM_READ | LVM_WRITE,
+		.pvh = pvh,
+		.read_ahead = read_ahead,
+		.stripe_size = stripe_size,
+		.stripes = stripes,
+		.vg_name = pool_lv->vg->name,
+		.zero = 1,
+	};
+
+	dm_list_init(&lvc.tags);
+
+	if (!(lvc.extents = extents_from_size(pool_lv->vg->cmd, size,
+					      pool_lv->vg->extent_size)))
+		return_0;
+
+	if (!(lvc.segtype = get_segtype_from_string(pool_lv->vg->cmd, "striped")))
+		return_0;
+
+	/* FIXME: allocate properly space for metadata_lv */
+
+	if (!(metadata_lv = lv_create_single(pool_lv->vg, &lvc)))
+		return_0;
+
+	return metadata_lv;
+}
tools/lvconvert.c +5 -4
index ccc8420..c2041c0 100644
@@ -2145,10 +2145,11 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
 		if (!get_stripe_params(cmd, &lp->stripes, &lp->stripe_size))
 			return_0;
 
-		if (!(metadata_lv = alloc_pool_metadata(pool_lv, lp->alloc, metadata_name,
-							lp->pvh, lp->read_ahead,
-							lp->stripes, lp->stripe_size,
-							lp->poolmetadata_size)))
+		if (!(metadata_lv = alloc_pool_metadata(pool_lv, metadata_name,
+							lp->read_ahead,	lp->stripes,
+							lp->stripe_size,
+							lp->poolmetadata_size,
+							lp->alloc, lp->pvh)))
 			return_0;
 	}
 
tools/toollib.c +0 -44

50 lines not on this page · raw message

tools/toollib.h +0 -5
index 32884db..cfcb934 100644
@@ -122,11 +122,6 @@ int get_pool_params(struct cmd_context *cmd,
 		    uint64_t *pool_metadata_size,
 		    int *zero);
 
-struct logical_volume *alloc_pool_metadata(struct logical_volume *pool_lv,
-					   alloc_policy_t alloc, const char *name,
-					   struct dm_list *pvh, uint32_t read_ahead,
-					   uint32_t stripes, uint32_t stripe_size,
-					   uint64_t size);
 int get_stripe_params(struct cmd_context *cmd, uint32_t *stripes,
 		      uint32_t *stripe_size);