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

[lvm-devel] [PATCH mirror 3/13] Add _lv_add_list() to lib/metadata/mirror.c



This is a cosmetic change of adding _lv_add_list()
and removing duplications.
No functional change.

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

Index: LVM2.work/lib/metadata/mirror.c
===================================================================
--- LVM2.work.orig/lib/metadata/mirror.c
+++ LVM2.work/lib/metadata/mirror.c
@@ -56,6 +56,22 @@ uint32_t adjusted_mirror_region_size(uin
 	return region_size;
 }
 
+static int _lv_add_list(struct dm_pool *mem,
+			struct logical_volume *lv, struct list *list)
+{
+	struct lv_list *lvl;
+
+	if (!(lvl = dm_pool_alloc(mem, sizeof(*lvl)))) {
+		log_error("lv_list alloc failed");
+		return 0;
+	}
+
+	lvl->lv = lv;
+	list_add(list, &lvl->list);
+
+	return 1;
+}
+
 static void _move_lv_segments(struct logical_volume *lv_to, struct logical_volume *lv_from)
 {
 	struct lv_segment *seg;
@@ -597,7 +613,6 @@ int insert_pvmove_mirrors(struct cmd_con
 			  struct list *lvs_changed)
 {
 	struct lv_segment *seg;
-	struct lv_list *lvl;
 	struct pv_list *pvl;
 	int lv_used = 0;
 	uint32_t s, extent_count = 0u;
@@ -676,12 +691,8 @@ int insert_pvmove_mirrors(struct cmd_con
 
 				/* First time, add LV to list of LVs affected */
 				if (!lv_used) {
-					if (!(lvl = dm_pool_alloc(cmd->mem, sizeof(*lvl)))) {
-						log_error("lv_list alloc failed");
-						return 0;
-					}
-					lvl->lv = lv;
-					list_add(lvs_changed, &lvl->list);
+					if (!_lv_add_list(cmd->mem, lv, lvs_changed))
+						return_0;
 					lv_used = 1;
 				}
 	
@@ -868,7 +879,7 @@ struct list *lvs_using_lv(struct cmd_con
 {
 	struct list *lvs;
 	struct logical_volume *lv1;
-	struct lv_list *lvl, *lvl1;
+	struct lv_list *lvl1;
 	struct lv_segment *seg;
 	uint32_t s;
 
@@ -891,12 +902,8 @@ struct list *lvs_using_lv(struct cmd_con
 				if (seg_type(seg, s) != AREA_LV ||
 				    seg_lv(seg, s) != lv)
 					continue;
-				if (!(lvl = dm_pool_alloc(cmd->mem, sizeof(*lvl)))) {
-					log_error("lv_list alloc failed");
-					return NULL;
-				}
-				lvl->lv = lv1;
-				list_add(lvs, &lvl->list);
+				if (!_lv_add_list(cmd->mem, lv1, lvs))
+					return_NULL;
 				goto next_lv;
 			}
 		}

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