[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [PATCH LVM2] (5/12) allow preference to small area



This patch allows allocation request to prefer small area.

o _comp_area_inv() is used to reverse the areas[] sorting
  if the allocation request is ALLOC_PREFER_SMALL.

o In _find_parallel_space(), iteration for pv_area didn't work
  work as commented:
                /*
                 * Put the smallest area of each PV that is at least the
                 * size we need into areas array.  If there isn't one
                 * that fits completely and we're allowed more than one
                 * LV segment, then take the largest remaining instead.
                 */
  because of the "goto next_pv" at the end.


$ diffstat -p1 05.prefer_small.patch
 lib/metadata/lv_manip.c |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)


Thanks,
--
Jun'ichi Nomura, NEC Corporation of America
diff -X dontdiff -urp LVM2.04.separate_constraints/lib/metadata/lv_manip.c LVM2.05.prefer_small/lib/metadata/lv_manip.c
--- LVM2.04.separate_constraints/lib/metadata/lv_manip.c	2006-10-13 21:14:37.000000000 -0400
+++ LVM2.05.prefer_small/lib/metadata/lv_manip.c	2006-10-13 21:16:42.000000000 -0400
@@ -923,6 +923,11 @@ static int _comp_area(const void *l, con
 	return 0;
 }
 
+static int _comp_area_inv(const void *l, const void *r)
+{
+	return _comp_area(l, r) * (-1);
+}
+
 /*
  * Search for pvseg that matches condition
  */
@@ -1217,8 +1222,6 @@ static int _find_parallel_space(struct a
 				}
 
 				areas[ix - 1] = pva;
-
-				goto next_pv;
 			}
 		next_pv:
 			if (ix >= areas_size)
@@ -1237,8 +1240,12 @@ static int _find_parallel_space(struct a
 		if (prev_lvseg &&
 		    (alloc == ALLOC_CONTIGUOUS || alloc == ALLOC_CLING))
 			areas_index = req->index;
-		else if (ix > 1)
-			qsort(areas, ix, sizeof(*areas), _comp_area);
+		else if (ix > 1) {
+			if (req->flags & ALLOC_PREFER_SMALL)
+				qsort(areas, ix, sizeof(*areas), _comp_area_inv);
+			else
+				qsort(areas, ix, sizeof(*areas), _comp_area);
+		}
 
 		if (!_alloc_parallel_area(ah, req, req_len, &areas[areas_index])) {
 			stack;

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]