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

Re: [lvm-devel] [PATCH] make vg_mark_partial_lvs more robust and export it



Hey again,

Petr Rockai <prockai redhat com> writes:
> the following patch makes vg_mark_partial_lvs also clear existing
> PARTIAL_LV flags, so it can be issued repeatedly on the same VG, keeping
> the PARTIAL_LV flags up to date.
>
> The patch is simple and straightforward.

scratch that. It introduces a bug nevertheless. Attaching a fixed
version.

Index: lib/metadata/metadata-exported.h
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/metadata/metadata-exported.h,v
retrieving revision 1.174
diff -u -p -r1.174 metadata-exported.h
--- lib/metadata/metadata-exported.h	12 Jan 2011 20:42:51 -0000	1.174
+++ lib/metadata/metadata-exported.h	16 Feb 2011 08:56:41 -0000
@@ -721,6 +721,8 @@ int vg_check_write_mode(struct volume_gr
 int lv_has_unknown_segments(const struct logical_volume *lv);
 int vg_has_unknown_segments(const struct volume_group *vg);
 
+int vg_mark_partial_lvs(struct volume_group *vg, int clear);
+
 struct vgcreate_params {
 	char *vg_name;
 	uint32_t extent_size;
Index: lib/metadata/metadata.c
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/metadata/metadata.c,v
retrieving revision 1.421
diff -u -p -r1.421 metadata.c
--- lib/metadata/metadata.c	14 Feb 2011 19:27:05 -0000	1.421
+++ lib/metadata/metadata.c	16 Feb 2011 08:56:42 -0000
@@ -2106,16 +2106,18 @@ static int _lv_mark_if_partial(struct lo
  * propagated transitively, so LVs referencing other LVs are marked
  * partial as well, if any of their referenced LVs are marked partial.
  */
-int vg_mark_partial_lvs(struct volume_group *vg)
+int vg_mark_partial_lvs(struct volume_group *vg, int clear)
 {
-	struct logical_volume *lv;
 	struct lv_list *lvl;
 
-	dm_list_iterate_items(lvl, &vg->lvs) {
-		lv = lvl->lv;
-		if (!_lv_mark_if_partial(lv))
+	if (clear)
+		dm_list_iterate_items(lvl, &vg->lvs)
+			lvl->lv->status &= ~PARTIAL_LV;
+
+	dm_list_iterate_items(lvl, &vg->lvs)
+		if (!_lv_mark_if_partial(lvl->lv))
 			return_0;
-	}
+
 	return 1;
 }
 
@@ -2779,7 +2781,7 @@ static struct volume_group *_vg_read(str
 		if (vg_missing_pv_count(correct_vg)) {
 			log_verbose("There are %d physical volumes missing.",
 				    vg_missing_pv_count(correct_vg));
-			vg_mark_partial_lvs(correct_vg);
+			vg_mark_partial_lvs(correct_vg, 1);
 		}
 		return correct_vg;
 	} else {
@@ -3113,7 +3115,7 @@ static struct volume_group *_vg_read(str
 	if (vg_missing_pv_count(correct_vg)) {
 		log_verbose("There are %d physical volumes missing.",
 			    vg_missing_pv_count(correct_vg));
-		vg_mark_partial_lvs(correct_vg);
+		vg_mark_partial_lvs(correct_vg, 1);
 	}
 
 	if ((correct_vg->status & PVMOVE) && !pvmove_mode()) {
Index: lib/metadata/metadata.h
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/metadata/metadata.h,v
retrieving revision 1.228
diff -u -p -r1.228 metadata.h
--- lib/metadata/metadata.h	10 Jan 2011 13:13:43 -0000	1.228
+++ lib/metadata/metadata.h	16 Feb 2011 08:56:42 -0000
@@ -411,7 +411,6 @@ struct id pv_vgid(const struct physical_
 struct physical_volume *pv_by_path(struct cmd_context *cmd, const char *pv_name);
 int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
 		 struct physical_volume *pv);
-int vg_mark_partial_lvs(struct volume_group *vg);
 int is_mirror_image_removable(struct logical_volume *mimage_lv, void *baton);
 
 uint64_t find_min_mda_size(struct dm_list *mdas);
Index: lib/mirror/mirrored.c
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/mirror/mirrored.c,v
retrieving revision 1.83
diff -u -p -r1.83 mirrored.c
--- lib/mirror/mirrored.c	5 Jan 2011 12:27:56 -0000	1.83
+++ lib/mirror/mirrored.c	16 Feb 2011 08:56:42 -0000
@@ -343,7 +343,7 @@ static int _mirrored_transient_status(st
 
 	/* update PARTIAL_LV flags across the VG */
 	if (failed)
-		vg_mark_partial_lvs(lv->vg);
+		vg_mark_partial_lvs(lv->vg, 0);
 
 	return 1;
 }
-- 
id' Ash = Ash; id' Dust = Dust; id' _ = undefined

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