Skip to contentSkip to conversation

master - thin: lvm2api return origin property for thin LV

PATCH Zdenek Kabelac 1 participant 1 message Oct 12, 2012

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=be291e106458a0ae1024bd517a37d471c032c505
Commit:        be291e106458a0ae1024bd517a37d471c032c505
Parent:        abb07a1b5ee2bbe4def9218c6fdf05b0a5718e12
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Fri Oct 12 12:02:15 2012 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Fri Oct 12 12:20:55 2012 +0200

thin: lvm2api return origin property for thin LV

---
 WHATS_NEW               |    1 +
 lib/metadata/lv.c       |    4 ++++
 test/api/thin_percent.c |    4 ++++
 3 files changed, 9 insertions(+), 0 deletions(-)
WHATS_NEW +1 -0
index e419a46..047e2ed 100644
@@ -1,5 +1,6 @@
 Version 2.02.98 -
 =================================
+  Fix lvm2api origin reporting for thin snapshot volume.
   Add configure --enable-python_bindings for liblvm2app to new python subdir.
   Add implementation of lvm2api function lvm_percent_to_float.
   Allow non power of 2 thin chunk sizes if thin pool driver supports that.
lib/metadata/lv.c +4 -0
index 33e3270..4032f34 100644
@@ -160,6 +160,10 @@ char *lv_origin_dup(struct dm_pool *mem, const struct logical_volume *lv)
 {
 	if (lv_is_cow(lv))
 		return lv_name_dup(mem, origin_from_cow(lv));
+
+	if (lv_is_thin_volume(lv) && first_seg(lv)->origin)
+		return lv_name_dup(mem, first_seg(lv)->origin);
+
 	return NULL;
 }
 
test/api/thin_percent.c +4 -0
index 5338164..2c8b19b 100644
@@ -57,6 +57,10 @@ int main(int argc, char *argv[])
 	assert(v.is_valid);
 	assert(v.value.integer == PERCENT_INVALID);
 
+	v = lvm_lv_get_property(lv, "origin");
+	assert(v.is_valid);
+	assert(strcmp(v.value.string, "thin") == 0);
+
 	lvm_vg_close(vg);
 	lvm_quit(handle);