[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



Re,

I am attaching an updated patch (since the CVS went conflicting with the
last version). It still does a scan of the LVs for the clear, but you
obviously can't do any better without a major rework of the status flag
system (where the flags would be sets of LVs instead of bits in the
LVs). So we don't.

The patch applies to current CVS and passes tests. Please review (it is
very simple and prerequisite for other patches)...

Index: lib/metadata/metadata-exported.h
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/metadata/metadata-exported.h,v
retrieving revision 1.187
diff -u -p -r1.187 metadata-exported.h
--- lib/metadata/metadata-exported.h	11 Mar 2011 14:56:56 -0000	1.187
+++ lib/metadata/metadata-exported.h	19 Mar 2011 22:34:08 -0000
@@ -764,6 +764,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 {
 	const 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.450
diff -u -p -r1.450 metadata.c
--- lib/metadata/metadata.c	14 Mar 2011 17:00:57 -0000	1.450
+++ lib/metadata/metadata.c	19 Mar 2011 22:34:08 -0000
@@ -2138,11 +2138,16 @@ static int _lv_mark_if_partial_single(st
  * 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 lv_list *lvl;
+
+	if (clear)
+		dm_list_iterate_items(lvl, &vg->lvs)
+			lvl->lv->status &= ~PARTIAL_LV;
+
 	if (!_lv_postorder_vg(vg, _lv_mark_if_partial_single, NULL))
 		return_0;
-
 	return 1;
 }
 
@@ -2827,7 +2832,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 {
@@ -3182,7 +3187,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.242
diff -u -p -r1.242 metadata.h
--- lib/metadata/metadata.h	11 Mar 2011 14:50:15 -0000	1.242
+++ lib/metadata/metadata.h	19 Mar 2011 22:34:08 -0000
@@ -471,7 +471,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.84
diff -u -p -r1.84 mirrored.c
--- lib/mirror/mirrored.c	18 Feb 2011 14:29:40 -0000	1.84
+++ lib/mirror/mirrored.c	19 Mar 2011 22:34:09 -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;
 }
Yours,
   Petr

-- 
id' Ash = Ash; id' Dust = Dust; id' _ = undefined

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