Skip to contentSkip to conversation

LVM2/lib/metadata lv_manip.c

PATCH [email protected] 1 participant 1 message Nov 10, 2011

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac at sourceware.org 2011-11-10 12:42:15

Modified files:
lib/metadata : lv_manip.c

Log message:
Thin align volume size on chunk boundary size

If the extent_size is smaller then the chunk_size we may try to find better aligment (wasting less space).

i.e. using 4KB extent_size and 64KB chunk size will lead to creation of 64KB aligned thin volume.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.327&r2=1.328

lib/metadata/lv_manip.c +12 -0
@@ -2051,6 +2051,7 @@
 	struct lv_segment *seg;
 	struct logical_volume *thin_pool_lv = NULL;
 	struct lv_list *lvl;
+	uint32_t size;
 
 	if (thin_pool_name) {
 		if (!(lvl = find_lv_in_vg(lv->vg, thin_pool_name))) {
@@ -2059,6 +2060,17 @@
 			return 0;
 		}
 		thin_pool_lv = lvl->lv;
+		size = first_seg(thin_pool_lv)->data_block_size;
+		if (lv->vg->extent_size < size) {
+			/* Align extents on chunk boundary size */
+			size = ((uint64_t)lv->vg->extent_size * extents + size - 1) /
+				size * size / lv->vg->extent_size;
+			if (size != extents) {
+				log_print("Rounding size (%d extents) up to chunk boundary "
+					  "size (%d extents).", extents, size);
+				extents = size;
+			}
+		}
 	}
 
 	if ((seg = last_seg(lv)) && (seg->segtype == segtype)) {