public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW tools/polldaemon.c
@ 2009-09-30 17:43 agk
  0 siblings, 0 replies; 6+ messages in thread
From: agk @ 2009-09-30 17:43 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2009-09-30 17:43:52

Modified files:
	.              : WHATS_NEW 
	tools          : polldaemon.c 

Log message:
	Factor out poll_mirror_progress and introduce progress_t.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1283&r2=1.1284
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/polldaemon.c.diff?cvsroot=lvm2&r1=1.24&r2=1.25

--- LVM2/WHATS_NEW	2009/09/30 14:19:00	1.1283
+++ LVM2/WHATS_NEW	2009/09/30 17:43:51	1.1284
@@ -1,5 +1,6 @@
 Version 2.02.54 -
 =====================================
+  Factor out poll_mirror_progress and introduce progress_t.
   Distinguish between powers of 1000 and powers of 1024 in unit suffixes.
   Restart lvconverts in vgchange by sharing lv_spawn_background_polling.
   Generalise polldaemon code by changing mirror-specific variable names.
--- LVM2/tools/polldaemon.c	2009/09/29 19:35:26	1.24
+++ LVM2/tools/polldaemon.c	2009/09/30 17:43:51	1.25
@@ -63,6 +63,43 @@
 	return 1;
 }
 
+typedef enum {
+	PROGRESS_CHECK_FAILED = 0,
+	PROGRESS_UNFINISHED = 1,
+	PROGRESS_FINISHED_SEGMENT = 2,
+	PROGRESS_FINISHED_ALL = 3
+} progress_t;
+
+progress_t poll_mirror_progress(struct cmd_context *cmd,
+				struct logical_volume *lv, const char *name,
+				struct daemon_parms *parms)
+{
+	float segment_percent = 0.0, overall_percent = 0.0;
+	uint32_t event_nr = 0;
+
+	if (!lv_mirror_percent(cmd, lv, !parms->interval, &segment_percent,
+			       &event_nr)) {
+		log_error("ABORTING: Mirror percentage check failed.");
+		return PROGRESS_CHECK_FAILED;
+	}
+
+	overall_percent = copy_percent(lv);
+	if (parms->progress_display)
+		log_print("%s: %s: %.1f%%", name, parms->progress_title,
+			  overall_percent);
+	else
+		log_verbose("%s: %s: %.1f%%", name, parms->progress_title,
+			    overall_percent);
+
+	if (segment_percent < 100.0)
+		return PROGRESS_UNFINISHED;
+
+	if (overall_percent >= 100.0)
+		return PROGRESS_FINISHED_ALL;
+
+	return PROGRESS_FINISHED_SEGMENT;
+}
+
 static int _check_lv_status(struct cmd_context *cmd,
 			    struct volume_group *vg,
 			    struct logical_volume *lv,
@@ -70,8 +107,7 @@
 			    int *finished)
 {
 	struct dm_list *lvs_changed;
-	float segment_percent = 0.0, overall_percent = 0.0;
-	uint32_t event_nr = 0;
+	progress_t progress;
 
 	/* By default, caller should not retry */
 	*finished = 1;
@@ -86,21 +122,11 @@
 		return 0;
 	}
 
-	if (!lv_mirror_percent(cmd, lv, !parms->interval, &segment_percent,
-			       &event_nr)) {
-		log_error("ABORTING: Mirror percentage check failed.");
-		return 0;
-	}
-
-	overall_percent = copy_percent(lv);
-	if (parms->progress_display)
-		log_print("%s: %s: %.1f%%", name, parms->progress_title,
-			  overall_percent);
-	else
-		log_verbose("%s: %s: %.1f%%", name, parms->progress_title,
-			    overall_percent);
+	progress = poll_mirror_progress(cmd, lv, name, parms);
+	if (progress == PROGRESS_CHECK_FAILED)
+		return_0;
 
-	if (segment_percent < 100.0) {
+	if (progress == PROGRESS_UNFINISHED) {
 		/* The only case the caller *should* try again later */
 		*finished = 0;
 		return 1;
@@ -112,7 +138,7 @@
 	}
 
 	/* Finished? Or progress to next segment? */
-	if (overall_percent >= 100.0) {
+	if (progress == PROGRESS_FINISHED_ALL) {
 		if (!parms->poll_fns->finish_copy(cmd, vg, lv, lvs_changed))
 			return 0;
 	} else {


^ permalink raw reply	[flat|nested] 6+ messages in thread

* LVM2 ./WHATS_NEW tools/polldaemon.c
@ 2012-02-28 10:06 zkabelac
  0 siblings, 0 replies; 6+ messages in thread
From: zkabelac @ 2012-02-28 10:06 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-02-28 10:06:54

Modified files:
	.              : WHATS_NEW 
	tools          : polldaemon.c 

Log message:
	Duplicate standard in/out descriptors for daemon
	
	Addressing somewhat tricky bug here.
	Since stdin,stdout,stderr were closed it's been occasionally possible to
	see some unexpected messages to be flowing into a clvmd and generating some
	randomly sized allocation of many megabytes. Since the message was not
	being generated by standard send_message() construction, after some more
	testing it apperead to be a debug log message - thus something has flown
	to local socket opened on strandard out descriptor.
	
	To fix the issue - use standard file descriptor duplication code for daemons.
	
	For making easier debugging of polling daemon - developer might want to recompile
	without modifition of standard file descriptors.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2320&r2=1.2321
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/polldaemon.c.diff?cvsroot=lvm2&r1=1.46&r2=1.47

--- LVM2/WHATS_NEW	2012/02/28 09:58:19	1.2320
+++ LVM2/WHATS_NEW	2012/02/28 10:06:53	1.2321
@@ -1,5 +1,6 @@
 Version 2.02.94 - 
 ====================================
+  For polling daemon reopen stdin,stdout,stderr to /dev/null.
   Limit the max size of processed clvmd message to ~8KB.
   Do not send uninitilised bytes in cluster error reply messages.
   Use unsigned type for bitmask instead of enum type for lvm properties.
--- LVM2/tools/polldaemon.c	2011/09/06 18:49:32	1.46
+++ LVM2/tools/polldaemon.c	2012/02/28 10:06:54	1.47
@@ -32,6 +32,8 @@
  */
 static int _become_daemon(struct cmd_context *cmd)
 {
+	static const char devnull[] = "/dev/null";
+	int null_fd;
 	pid_t pid;
 	struct sigaction act = {
 		{_sigchld_handler},
@@ -57,12 +59,27 @@
 	if (setsid() == -1)
 		log_error("Background process failed to setsid: %s",
 			  strerror(errno));
-	init_verbose(VERBOSE_BASE_LEVEL);
 
-	close(STDIN_FILENO);
-	close(STDOUT_FILENO);
-	close(STDERR_FILENO);
+	/* For poll debugging it's best to disable for compilation */
+#if 1
+	if ((null_fd = open(devnull, O_RDWR)) == -1) {
+		log_sys_error("open", devnull);
+		_exit(ECMD_FAILED);
+	}
+
+	if (dup2(null_fd, STDIN_FILENO)  || /* reopen stdin */
+	    dup2(null_fd, STDOUT_FILENO) || /* reopen stdout */
+	    dup2(null_fd, STDERR_FILENO)) { /* reopen stderr */
+		log_sys_error("dup2", "redirect");
+		(void) close(null_fd);
+		_exit(ECMD_FAILED);
+	}
 
+	if (null_fd > STDERR_FILENO)
+		(void) close(null_fd);
+
+	init_verbose(VERBOSE_BASE_LEVEL);
+#endif
 	strncpy(*cmd->argv, "(lvm2)", strlen(*cmd->argv));
 
 	reset_locking();


^ permalink raw reply	[flat|nested] 6+ messages in thread

* LVM2 ./WHATS_NEW tools/polldaemon.c
@ 2011-01-19 23:11 mbroz
  0 siblings, 0 replies; 6+ messages in thread
From: mbroz @ 2011-01-19 23:11 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2011-01-19 23:11:40

Modified files:
	.              : WHATS_NEW 
	tools          : polldaemon.c 

Log message:
	If other process finishes (or aborts) pvmove operation and
	polling function cannot find any lv with PVMOVE flag, return
	success and do not print  "aborting" message.
	
	Fixes https://bugzilla.redhat.com/show_bug.cgi?id=602389

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1885&r2=1.1886
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/polldaemon.c.diff?cvsroot=lvm2&r1=1.42&r2=1.43

--- LVM2/WHATS_NEW	2011/01/19 23:09:31	1.1885
+++ LVM2/WHATS_NEW	2011/01/19 23:11:39	1.1886
@@ -2,6 +2,7 @@
 ===================================
   Add -f (don't fork) option to clvmd and fix clvmd -d<num> description.
   Fix possible clvmd DLM lockspace increasing reference count.
+  Do not fail polling if pvmove finished in another process.
 
 Version 2.02.81 - 17th January 2011
 ===================================
--- LVM2/tools/polldaemon.c	2011/01/12 20:42:51	1.42
+++ LVM2/tools/polldaemon.c	2011/01/19 23:11:39	1.43
@@ -193,8 +193,16 @@
 			return 0;
 		}
 
-		if (!(lv = parms->poll_fns->get_copy_lv(cmd, vg, name, uuid,
-							parms->lv_type))) {
+		lv = parms->poll_fns->get_copy_lv(cmd, vg, name, uuid, parms->lv_type);
+
+		if (!lv && parms->lv_type == PVMOVE) {
+			log_print("%s: no pvmove in progress - already finished or aborted.",
+				  name);
+			unlock_and_free_vg(cmd, vg, vg->name);
+			return 1;
+		}
+
+		if (!lv) {
 			log_error("ABORTING: Can't find LV in %s for %s",
 				  vg->name, name);
 			unlock_and_free_vg(cmd, vg, vg->name);


^ permalink raw reply	[flat|nested] 6+ messages in thread

* LVM2 ./WHATS_NEW tools/polldaemon.c
@ 2011-01-05 12:59 zkabelac
  0 siblings, 0 replies; 6+ messages in thread
From: zkabelac @ 2011-01-05 12:59 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-01-05 12:59:47

Modified files:
	.              : WHATS_NEW 
	tools          : polldaemon.c 

Log message:
	Fail deamonization if lvmcache_init fail
	
	FIXME Add proper cleanup

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1858&r2=1.1859
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/polldaemon.c.diff?cvsroot=lvm2&r1=1.39&r2=1.40

--- LVM2/WHATS_NEW	2011/01/05 12:33:51	1.1858
+++ LVM2/WHATS_NEW	2011/01/05 12:59:46	1.1859
@@ -1,5 +1,6 @@
 Version 2.02.80 - 
 ====================================
+  Fail poll daemon creation when lvmcache_init() fails.
   Return defined value for errors in _copy_percent() and _snap_percent().
   Correct return code of cmirrord when issuing 'start' when already running.
   Fix wrongly paired unlocking of global lock in pvchange. (2.02.66)
--- LVM2/tools/polldaemon.c	2010/12/08 20:50:51	1.39
+++ LVM2/tools/polldaemon.c	2011/01/05 12:59:47	1.40
@@ -64,7 +64,9 @@
 	strncpy(*cmd->argv, "(lvm2)", strlen(*cmd->argv));
 
 	reset_locking();
-	lvmcache_init();
+	if (!lvmcache_init())
+		/* FIXME Clean up properly here */
+		_exit(ECMD_FAILED);
 	dev_close_all();
 
 	return 1;


^ permalink raw reply	[flat|nested] 6+ messages in thread

* LVM2 ./WHATS_NEW tools/polldaemon.c
@ 2010-08-26 16:29 jbrassow
  0 siblings, 0 replies; 6+ messages in thread
From: jbrassow @ 2010-08-26 16:29 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2010-08-26 16:29:13

Modified files:
	.              : WHATS_NEW 
	tools          : polldaemon.c 

Log message:
	This patch fixes a problem where the mirror polling process
	may never complete.
	
	If you convert from a linear to a mirror and then convert that
	mirror back to linear /while/ the previous (up)convert is
	taking place, the mirror polling process will never complete.
	This is because the function that polls the mirror for
	completion doesn't check if it is still polling a mirror and
	the copy_percent that it gets back from the linear device is
	certainly never 100%.
	
	The fix is simply to check if the daemon is still looking at
	a mirror device - if not, return PROGRESS_CHECK_FAILED.
	
	The user sees the following output from the first (up)convert
	if someone else sneaks in and does a down-convert shortly
	after their convert:
	[root@bp-01 ~]# lvconvert -m1 vg/lv
	vg/lv: Converted: 43.4%
	ABORTING: Mirror percentage check failed.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1725&r2=1.1726
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/polldaemon.c.diff?cvsroot=lvm2&r1=1.36&r2=1.37

--- LVM2/WHATS_NEW	2010/08/26 14:21:50	1.1725
+++ LVM2/WHATS_NEW	2010/08/26 16:29:12	1.1726
@@ -1,5 +1,6 @@
 Version 2.02.74 - 
 ==================================
+  Make poll_mirror_progress report PROGRESS_CHECK_FAILED if LV is not a mirror.
   Like mirrors, don't scan origins if ignore_suspended_devices() is set.
   Fix return type qualifier to avoid compiler warning. (2.02.69)
   Automatically generate LSB Requires-Start for clvmd init script.
--- LVM2/tools/polldaemon.c	2010/08/23 11:34:41	1.36
+++ LVM2/tools/polldaemon.c	2010/08/26 16:29:12	1.37
@@ -78,7 +78,8 @@
 	percent_range_t percent_range, overall_percent_range;
 	uint32_t event_nr = 0;
 
-	if (!lv_mirror_percent(cmd, lv, !parms->interval, &segment_percent,
+	if (!lv_is_mirrored(lv) ||
+	    !lv_mirror_percent(cmd, lv, !parms->interval, &segment_percent,
 			       &percent_range, &event_nr) ||
 	    (percent_range == PERCENT_INVALID)) {
 		log_error("ABORTING: Mirror percentage check failed.");


^ permalink raw reply	[flat|nested] 6+ messages in thread

* LVM2 ./WHATS_NEW tools/polldaemon.c
@ 2010-08-23 11:34 mbroz
  0 siblings, 0 replies; 6+ messages in thread
From: mbroz @ 2010-08-23 11:34 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2010-08-23 11:34:43

Modified files:
	.              : WHATS_NEW 
	tools          : polldaemon.c 

Log message:
	Fix pvmove --abort <dev> return code
	
	It prints error code even if abort operation succeeds:
	
	pvmove --abort /dev/sdb
	Command failed with status code 5.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1721&r2=1.1722
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/polldaemon.c.diff?cvsroot=lvm2&r1=1.35&r2=1.36

--- LVM2/WHATS_NEW	2010/08/23 11:34:10	1.1721
+++ LVM2/WHATS_NEW	2010/08/23 11:34:40	1.1722
@@ -1,5 +1,6 @@
 Version 2.02.74 - 
 ==================================
+  Fix return code of pvmove --abort PV.
   Fix pvmove --abort to remove even for empty pvmove LV.
   Add configure --with-default-data-alignment.
   Update heuristic used for default and detected data alignment.
--- LVM2/tools/polldaemon.c	2010/08/23 11:34:10	1.35
+++ LVM2/tools/polldaemon.c	2010/08/23 11:34:41	1.36
@@ -120,8 +120,10 @@
 				  "can't abort.");
 			return 0;
 		}
-		parms->poll_fns->finish_copy(cmd, vg, lv, lvs_changed);
-		return 0;
+		if (!parms->poll_fns->finish_copy(cmd, vg, lv, lvs_changed))
+			return_0;
+
+		return 1;
 	}
 
 	progress = parms->poll_fns->poll_progress(cmd, lv, name, parms);


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-02-28 10:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-30 17:43 LVM2 ./WHATS_NEW tools/polldaemon.c agk
2010-08-23 11:34 mbroz
2010-08-26 16:29 jbrassow
2011-01-05 12:59 zkabelac
2011-01-19 23:11 mbroz
2012-02-28 10:06 zkabelac

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).