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

[lvm-devel] [LVM2 PATCH] (1/5) Separate mirror log allocation from _alloc_parallel_areas()



This patch moves the log allocation part from _alloc_parallel_area().
Preparation for the following patches.
No functional change.

  - _alloc_parallel_area() doesn't need to allocate struct alloced_area
    for log_area because it's pre-allocated in struct alloc_handle.

  - consume_pv_area() has been done in the separate loop from
    the loop for struct alloced_area setup.
    However, consume_pv_area() just updates given pv_area and
    pv_areas in areas[] are different each other.
    So it can be done in the same loop with the struct alloced_area setup.

  - ah->total_area_len, area_len, *ix and ah->area_multiple are not
    used/updated in log_area allocation.
    So operation on them can be moved before _alloc_log_area().

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

This patch moves the log allocation part from _alloc_parallel_area().
Preparation for the following patches.
No functional change.

  - _alloc_parallel_area() doesn't need to allocate struct alloced_area
    for log_area because it's pre-allocated in struct alloc_handle.

  - consume_pv_area() has been done in the separate loop from
    the loop for struct alloced_area setup.
    However, consume_pv_area() just updates given pv_area and
    pv_areas in areas[] are different each other.
    So it can be done in the same loop with the struct alloced_area setup.

  - ah->total_area_len, area_len, *ix and ah->area_multiple are not
    used/updated in log_area allocation.
    So operation on them can be moved before _alloc_log_area().


Index: LVM2.02.17/lib/metadata/lv_manip.c
===================================================================
--- LVM2.02.17.orig/lib/metadata/lv_manip.c	2007-01-05 20:41:52.000000000 -0500
+++ LVM2.02.17/lib/metadata/lv_manip.c	2007-01-05 21:24:25.000000000 -0500
@@ -628,6 +628,16 @@ static int _setup_alloced_segments(struc
 	return 1;
 }
 
+static int _alloc_log_area(struct alloc_handle *ah, struct pv_area *log_area)
+{
+	ah->log_area.pv = log_area->map->pv;
+	ah->log_area.pe = log_area->start;
+	ah->log_area.len = MIRROR_LOG_SIZE;	/* FIXME Calculate & check this */
+	consume_pv_area(log_area, ah->log_area.len);
+
+	return 1;
+}
+
 /*
  * This function takes a list of pv_areas and adds them to allocated_areas.
  * If the complete area is not needed then it gets split.
@@ -649,8 +659,7 @@ static int _alloc_parallel_area(struct a
 		if (area_len > areas[s]->count)
 			area_len = areas[s]->count;
 
-	if (!(aa = dm_pool_alloc(ah->mem, sizeof(*aa) *
-			      (ah->area_count + (log_area ? 1 : 0))))) {
+	if (!(aa = dm_pool_alloc(ah->mem, sizeof(*aa) * ah->area_count))) {
 		log_error("alloced_area allocation failed");
 		return 0;
 	}
@@ -660,22 +669,15 @@ static int _alloc_parallel_area(struct a
 		aa[s].pe = areas[s]->start;
 		aa[s].len = area_len;
 		list_add(&ah->alloced_areas[s], &aa[s].list);
-	}
-
-	ah->total_area_len += area_len;
-
-	for (s = 0; s < ah->area_count; s++)
 		consume_pv_area(areas[s], area_len);
-
-	if (log_area) {
-		ah->log_area.pv = log_area->map->pv;
-		ah->log_area.pe = log_area->start;
-		ah->log_area.len = MIRROR_LOG_SIZE;	/* FIXME Calculate & check this */
-		consume_pv_area(log_area, ah->log_area.len);
 	}
 
+	ah->total_area_len += area_len;
 	*ix += area_len * ah->area_multiple;
 
+	if (log_area)
+		_allocate_log_area(ah, log_area);
+
 	return 1;
 }
 

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