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

[lvm-devel] [RFC][PATCH] exit backgrounded polldaemon on completion

If the polldaemon is executed in the background (the child) it will go
on to duplicate the work that poll_daemon() caller (the parent) already
performed.  So for example, "vgchange -ay" will spawn backgrounded
polldaemons that will complete and then go on to spawn additional
polldaemon(s) because it duplicates the parent's "vgchange -ay" work.
The backgrounded polldaemon should exit() on completion.

This is an RFC because if the backgrounded polldaemon is made to exit()
there is some log noise about memory leaks (from memory the child
inherited from the parent, more specific in patch below).  In that we
exit() the leaks aren't a huge probloem; but the user won't know that.

Cleaning up such memory (vg->vgmem) would require specialized calls to
vg_release() from _become_daemon() -- which doesn't have access to the
vg.  So this would seem to warrant further discussion.

diff --git a/tools/polldaemon.c b/tools/polldaemon.c
index b4d6ebb..32fe4b0 100644
--- a/tools/polldaemon.c
+++ b/tools/polldaemon.c
@@ -238,6 +238,7 @@ int poll_daemon(struct cmd_context *cmd, const char *name, const char *uuid,
 		const char *progress_title)
 	struct daemon_parms parms;
+	int ret = ECMD_PROCESSED;
 	parms.aborting = arg_is_set(cmd, abort_ARG);
 	parms.background = background;
@@ -273,10 +274,27 @@ int poll_daemon(struct cmd_context *cmd, const char *name, const char *uuid,
 	if (name) {
 		if (!_wait_for_single_lv(cmd, name, uuid, &parms)) {
-			return ECMD_FAILED;
+			ret = ECMD_FAILED;
 	} else
 		_poll_for_all_vgs(cmd, &parms);
+	if (parms.background) {
+		/*
+		 * background polldaemon must not return to the caller
+		 * because it will redundantly continue performing the
+		 * caller's task (that the parent already performed)
+		 */
+		fin_locking();
+		dm_pool_empty(cmd->mem);
+		lvm_fin(cmd);
+		/*
+		 * FIXME child's memory that was inherited from parent
+		 * (e.g. "lvm2 vg_read" mempool) will leak on exit;
+		 * other than the log_error() noise do we care?
+		 */
+		exit(ret == ECMD_PROCESSED ? 0 : ret);
+	}
+	return ret;

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