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

[lvm-devel] [LVM2 PATCH] (5/5) Remove ix_offset



In _find_parallel_space(), ix_offset is used as a separator of
the areas[] array:
  - 0--ix_offset : used for contiguous/cling allocation
  - ix_offset--areas_size : used for other allocation

Since the both uses are exclusive, there is no need to use ix_offset.
ix can be used to count the number of areas found suitable for
the allocation.

Thanks,
-- 
Jun'ichi Nomura, NEC Corporation of America


In _find_parallel_space(), ix_offset is used as a separator of
the areas[] array:
  - 0--ix_offset : used for contiguous/cling allocation
  - ix_offset--areas_size : used for other allocation

Since the both uses are exclusive, there is no need to use ix_offset.
ix can be used to count the number of areas found suitable for
the allocation.


Index: LVM2.02.17/lib/metadata/lv_manip.c
===================================================================
--- LVM2.02.17.orig/lib/metadata/lv_manip.c	2007-01-06 01:45:35.000000000 -0500
+++ LVM2.02.17/lib/metadata/lv_manip.c	2007-01-06 01:53:09.000000000 -0500
@@ -895,9 +895,8 @@ static int _find_parallel_space(struct a
 	struct pv_area *pva;
 	struct pv_list *pvl;
 	unsigned already_found_one;
-	unsigned contiguous, cling, preferred_count;
+	unsigned contiguous, cling;
 	unsigned ix;
-	unsigned ix_offset;	/* Offset for non-preferred allocations */
 	uint32_t max_parallel;	/* Maximum extents to allocate */
 	uint32_t next_le;
 	struct seg_pvs *spvs;
@@ -907,7 +906,6 @@ static int _find_parallel_space(struct a
 
       restart: /* when log allocation is done first */
 	contiguous = cling = 0;
-	ix_offset = preferred_count = 0;
 
 	if (allocating_log(ah))
 		needed_areas = ah->log_count;
@@ -925,25 +923,20 @@ static int _find_parallel_space(struct a
 
 	/* Are there any preceding segments we must follow on from? */
 	if (!allocating_log(ah) && prev_lvseg) {
-		ix_offset = prev_lvseg->area_count;
 		if ((alloc == ALLOC_CONTIGUOUS))
 			contiguous = 1;
 		else if ((alloc == ALLOC_CLING))
 			cling = 1;
-		else
-			ix_offset = 0;
 	}
 
-	/* ix_offset, preferred_count, contiguous and cling are non-zero
+	/* contiguous and cling are non-zero
 	   only when prev_lvseg is not NULL */
 
 	/* FIXME This algorithm needs a lot of cleaning up! */
 	/* FIXME anywhere doesn't find all space yet */
-	/* ix_offset holds the number of allocations that must be contiguous */
-	/* ix holds the number of areas found on other PVs */
+	/* ix holds the number of areas found on PVs */
 	do {
 		ix = 0;
-		preferred_count = 0;
 
 		parallel_pvs = NULL;
 		max_parallel = needed;
@@ -1005,7 +998,7 @@ static int _find_parallel_space(struct a
 							      prev_lvseg,
 							      pva, areas,
 							      areas_size)) {
-						preferred_count++;
+						ix++;
 						goto next_pv;
 					}
 					continue;
@@ -1016,7 +1009,7 @@ static int _find_parallel_space(struct a
 							   prev_lvseg,
 							   pva, areas,
 							   areas_size)) {
-						preferred_count++;
+						ix++;
 					}
 					goto next_pv;
 				}
@@ -1045,7 +1038,7 @@ static int _find_parallel_space(struct a
 					already_found_one = 1;
 				}
 
-				areas[ix + ix_offset - 1] = pva;
+				areas[ix - 1] = pva;
 
 				goto next_pv;
 			}
@@ -1054,21 +1047,17 @@ static int _find_parallel_space(struct a
 				break;
 		}
 
-		if ((contiguous || cling) && (preferred_count < ix_offset))
-			break;
-
-		if (ix + ix_offset < needed_areas)
+		if (ix < needed_areas)
 			/* FIXME With ALLOC_ANYWHERE, need to split areas */
 			break;
 
 		/* sort the areas so we allocate from the biggest */
-		if (ix > 1)
-			qsort(areas + ix_offset, ix, sizeof(*areas),
-			      _comp_area);
+		if (ix > 1 && !contiguous && !cling)
+			qsort(areas, ix, sizeof(*areas), _comp_area);
 
 		/* First time around, use smallest area as log_area */
 		if (allocating_log(ah)) {
-			if (!_alloc_log_area(ah, *(areas + ix_offset + ix - 1))) {
+			if (!_alloc_log_area(ah, *(areas + ix - 1))) {
 				stack;
 				return 0;
 			}

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