Skip to contentSkip to conversation

master - lvm2app: Add thin and thin pool lv creation

PATCH tasleson 1 participant 1 message Jul 12, 2013

lore
Share & tools
lore

tasleson

author
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5227b65588cb45d27bb6841617970e73903c0b9f
Commit:        5227b65588cb45d27bb6841617970e73903c0b9f
Parent:        9775a19af1f2a93d5550f4ff5843e3ac8e556eb1
Author:        Tony Asleson <[email protected]>
AuthorDate:    Fri Jul 12 16:40:10 2013 -0400
Committer:     Tony Asleson <[email protected]>
CommitterDate: Fri Jul 12 16:52:16 2013 -0500

lvm2app: Add thin and thin pool lv creation

Add thin and thin pool lv creation support to lvm library

This is Mohan's thinp patch, re-worked to include suggestions from Zdenek and Mohan.

Rework of commit 4d5de8322b3a6050def60542b167b46d97b2824d which uses refactored properties handling.

Based on work done by M. Mohan Kumar <[email protected]>

---
 lib/properties/prop_common.h |    9 ++
 liblvm/Makefile.in           |    3 +-
 liblvm/lvm2app.h             |  153 ++++++++++++++++++++++-
 liblvm/lvm_lv.c              |  293 +++++++++++++++++++++++++++++++++++++++++-
 liblvm/lvm_misc.c            |   24 +++-
 liblvm/lvm_misc.h            |    8 +-
 liblvm/lvm_pv.c              |    4 +-
 liblvm/lvm_vg.c              |    6 +-
 8 files changed, 483 insertions(+), 17 deletions(-)
lib/properties/prop_common.h +9 -0
index a39f2f1..6c89ad6 100644
@@ -62,6 +62,15 @@ static int _ ## NAME ## _set (void *obj, struct lvm_property_type *prop) \
 	return 1; \
 }
 
+#define SET_NUM_PROPERTY(NAME, VALUE, TYPE, VAR)			\
+static int _ ## NAME ## _set (void *obj, struct lvm_property_type *prop) \
+{ \
+	struct TYPE *VAR = (struct TYPE *)obj; \
+\
+	VALUE = prop->value.integer;		\
+	return 1; \
+}
+
 #define GET_STR_PROPERTY_FN(NAME, VALUE, TYPE, VAR)			\
 static int _ ## NAME ## _get (const void *obj, struct lvm_property_type *prop) \
 { \
liblvm/Makefile.in +2 -1
index 8ae4661..d0f8d1b 100644
@@ -1,6 +1,6 @@
 #
 # Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
-# Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2004-2013 Red Hat, Inc. All rights reserved.
 #
 # This file is part of LVM2.
 #
@@ -18,6 +18,7 @@ top_builddir = @top_builddir@
 
 SOURCES =\
 	lvm_misc.c \
+	lvm_prop.c \
 	lvm_base.c \
 	lvm_lv.c \
 	lvm_pv.c \
liblvm/lvm2app.h +152 -1

175 lines not on this page · raw message

liblvm/lvm_lv.c +290 -3

320 lines not on this page · raw message

liblvm/lvm_misc.c +20 -4
index 0a0ea12..c79af8f 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008,2010 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2008-2013 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -16,6 +16,7 @@
 #include "properties.h"
 #include "lvm_misc.h"
 #include "lvm2app.h"
+#include "lvm_prop.h"
 
 struct dm_list *tag_list_copy(struct dm_pool *p, struct dm_list *tag_list)
 {
@@ -46,8 +47,11 @@ struct dm_list *tag_list_copy(struct dm_pool *p, struct dm_list *tag_list)
 }
 
 struct lvm_property_value get_property(const pv_t pv, const vg_t vg,
-				       const lv_t lv, const lvseg_t lvseg,
-				       const pvseg_t pvseg, const char *name)
+				       const lv_t lv,
+				       const lvseg_t lvseg,
+				       const pvseg_t pvseg,
+				       const struct lvcreate_params *lvcp,
+				       const char *name)
 {
 	struct lvm_property_type prop;
 	struct lvm_property_value v = { 0 };
@@ -69,6 +73,9 @@ struct lvm_property_value get_property(const pv_t pv, const vg_t vg,
 	} else if (pvseg) {
 		if (!pvseg_get_property(pvseg, &prop))
 			return v;
+	} else if (lvcp) {
+		if (!lv_create_param_get_property(lvcp, &prop))
+			return v;
 	} else {
 		log_errno(EINVAL, "Invalid NULL handle passed to library function.");
 		return v;
@@ -87,7 +94,9 @@ struct lvm_property_value get_property(const pv_t pv, const vg_t vg,
 
 
 int set_property(const pv_t pv, const vg_t vg, const lv_t lv,
-		 const char *name, struct lvm_property_value *v)
+		struct lvcreate_params *lvcp,
+		const char *name,
+		struct lvm_property_value *v)
 {
 	struct lvm_property_type prop;
 
@@ -111,6 +120,13 @@ int set_property(const pv_t pv, const vg_t vg, const lv_t lv,
 			v->is_valid = 0;
 			return -1;
 		}
+	} else if (lvcp) {
+		if (!lv_create_param_set_property(lvcp, &prop)) {
+			v->is_valid = 0;
+			return -1;
+		}
+	} else {
+		return -1;
 	}
 	return 0;
 }
liblvm/lvm_misc.h +5 -3
index a0324b8..a84125a 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008,2010 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2008-2013 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -20,8 +20,10 @@
 struct dm_list *tag_list_copy(struct dm_pool *p, struct dm_list *tag_list);
 struct lvm_property_value get_property(const pv_t pv, const vg_t vg,
 				       const lv_t lv, const lvseg_t lvseg,
-				       const pvseg_t pvseg, const char *name);
+				       const pvseg_t pvseg, const struct lvcreate_params *lvcp,
+				       const char *name);
 int set_property(const pv_t pv, const vg_t vg, const lv_t lv,
-		 const char *name, struct lvm_property_value *value);
+			struct lvcreate_params *lvcp, const char *name,
+			struct lvm_property_value *value);
 
 #endif
liblvm/lvm_pv.c +2 -2
index a2e7ef0..2bd0ac0 100644
@@ -53,13 +53,13 @@ uint64_t lvm_pv_get_free(const pv_t pv)
 
 struct lvm_property_value lvm_pv_get_property(const pv_t pv, const char *name)
 {
-	return get_property(pv, NULL, NULL, NULL, NULL, name);
+	return get_property(pv, NULL, NULL, NULL, NULL, NULL, name);
 }
 
 struct lvm_property_value lvm_pvseg_get_property(const pvseg_t pvseg,
 						 const char *name)
 {
-	return get_property(NULL, NULL, NULL, NULL, pvseg, name);
+	return get_property(NULL, NULL, NULL, NULL, pvseg, NULL, name);
 }
 
 struct lvm_list_wrapper
liblvm/lvm_vg.c +3 -3
index 35c7eea..c128ba7 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008,2009 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2008-2013 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -340,7 +340,7 @@ const char *lvm_vg_get_name(const vg_t vg)
 
 struct lvm_property_value lvm_vg_get_property(const vg_t vg, const char *name)
 {
-	return get_property(NULL, vg, NULL, NULL, NULL, name);
+	return get_property(NULL, vg, NULL, NULL, NULL, NULL, name);
 }
 
 int lvm_vg_set_property(const vg_t vg, const char *name,
@@ -357,7 +357,7 @@ int lvm_vg_set_property(const vg_t vg, const char *name,
 				strlen(value->value.string) + 1);
 	}
 
-	return set_property(NULL, vg, NULL, name, value);
+	return set_property(NULL, vg, NULL, NULL, name, value);
 }
 
 struct dm_list *lvm_list_vg_names(lvm_t libh)