Skip to contentSkip to conversation

update vgchange's handling of -a, --refresh, --monitor and --poll

RFC PATCH New Mike Snitzer 1 participant 2 messages Oct 25, 2010

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 update vgchange's handling of -a, --refresh, --monitor and --poll

Update vgchange to have nearly comparable processing of -a, --refresh, --monitor and --poll

This was motivated because vgchange disallows combining --monitor and --poll but lvm2-monitor uses: vgchange --monitor y --poll y $VGNAME

---
 tools/lvchange.c |    2 +-
 tools/vgchange.c |   35 +++++++++++++++++++++++++++++------
 2 files changed, 30 insertions(+), 7 deletions(-)
tools/lvchange.c +1 -1
index 5ac223a..4c7578f 100644
@@ -715,7 +715,7 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
 
 int lvchange(struct cmd_context *cmd, int argc, char **argv)
 {
-	int update = /* options other than -a, --refresh or --monitor */
+	int update = /* options other than -a, --refresh, --monitor or --poll */
 		arg_count(cmd, contiguous_ARG) || arg_count(cmd, permission_ARG) ||
 		arg_count(cmd, readahead_ARG) || arg_count(cmd, persistent_ARG) ||
 		arg_count(cmd, addtag_ARG) || arg_count(cmd, deltag_ARG) ||
tools/vgchange.c +29 -6
index 92f32db..1bf4004 100644
@@ -592,14 +592,40 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
 						arg_int_value(cmd, poll_ARG,
 						DEFAULT_BACKGROUND_POLLING));
 
-	if (arg_count(cmd, available_ARG))
+	if (arg_count(cmd, available_ARG)) {
 		r = _vgchange_available(cmd, vg);
+		if (r != ECMD_PROCESSED)
+			return r;
+	}
 
-	else if (arg_count(cmd, monitor_ARG))
+	/* FIXME: disallow -a and --refresh (unlike lvchange)? */
+	if (arg_count(cmd, refresh_ARG)) {
+		/* refreshes the visible LVs (which starts polling) */
+		r = _vgchange_refresh(cmd, vg);
+		if (r != ECMD_PROCESSED)
+			return r;
+	}
+
+	if (!arg_count(cmd, available_ARG) &&
+	    !arg_count(cmd, refresh_ARG) &&
+	    arg_count(cmd, monitor_ARG)) {
+		/* -ay will have already done monitoring changes */
+		/* FIXME: unlike lvchange, allow --refresh and --monitor ? */
 		r = _vgchange_monitoring(cmd, vg);
+		if (r != ECMD_PROCESSED)
+			return r;
+	}
 
-	else if (arg_count(cmd, poll_ARG))
+	if (!arg_count(cmd, available_ARG) &&
+	    !arg_count(cmd, refresh_ARG) &&
+	    arg_count(cmd, poll_ARG)) {
+		/* avoid polling visible LVs multiple times (via refresh) */
+		/*
+		 * FIXME: allow --poll in conjunction with -a?
+		 * for reference: lvchange -ay also controls polling
+		 */
 		r = _vgchange_background_polling(cmd, vg);
+	}
 
 	else if (arg_count(cmd, resizeable_ARG))
 		r = _vgchange_resizeable(cmd, vg);
@@ -628,9 +654,6 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
 	else if (arg_count(cmd, clustered_ARG))
 		r = _vgchange_clustered(cmd, vg);
 
-	else if (arg_count(cmd, refresh_ARG))
-		r = _vgchange_refresh(cmd, vg);
-
 	else if (arg_count(cmd, vgmetadatacopies_ARG) ||
 		 arg_count(cmd, metadatacopies_ARG))
 		r = _vgchange_metadata_copies(cmd, vg);
#1 lore raw

RFC PATCH 1/1 update vgchange's handling of -a, --refresh, --monitor and --poll

Quoted 2 lines · Mike Snitzer

Update vgchange to have nearly comparable processing of -a, --refresh, --monitor and --poll

Meant to say:

Update vgchange to have lvchange like processing of -a, --refresh, --monitor and --poll

(I said "nearly comparable" before because I didn't make vgchange -ay control polling like lvchange -ay does, like noted in this patch's last FIXME)

Mike