Skip to contentSkip to conversation

Add -f (do not fork) option to clvmd.

PATCH New Milan Broz 1 participant 2 messages Jan 17, 2011

lore
Share & tools
lore

Milan Broz

author
#0 lore raw

PATCH 1/1 Add -f (do not fork) option to clvmd.

Currently -d option is overloaded and controls forking too.

After the patch:
- daemon mode is controlled by f option
- log mode is controlled by -d option.

0 means no debug log, 1 steerr if running in foreground, 2 means syslog.

Patch also removes duplicate global debug variable and uses one defined in clvmd.c.

Patch also fixes documentation, format od -d option is strictly -d[num] (no space allowed).

Also removes some defines from do_postcommand (set_debug missing here) Check for unknown command is already done in pre call, no need to do ti here again.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=596352

---
 daemons/clvmd/clvmd-command.c |   18 ++++------
 daemons/clvmd/clvmd.c         |   68 +++++++++++++++++++++++++++--------------
 daemons/clvmd/clvmd.h         |    3 ++
 man/clvmd.8.in                |   11 +++---
 test/lib/aux.sh               |    2 +-
 5 files changed, 61 insertions(+), 41 deletions(-)
daemons/clvmd/clvmd-command.c +7 -11
index eee5bc3..2576dcf 100644
@@ -63,7 +63,6 @@
 
 #include <sys/utsname.h>
 
-extern debug_t debug;
 extern struct cluster_ops *clops;
 static int restart_clvmd(void);
 
@@ -144,7 +143,7 @@ int do_command(struct local_client *client, struct clvm_header *msg, int msglen,
 		break;
 
 	case CLVMD_CMD_SET_DEBUG:
-		debug = args[0];
+		clvmd_set_debug(args[0]);
 		break;
 
 	case CLVMD_CMD_RESTART:
@@ -310,19 +309,16 @@ int do_post_command(struct local_client *client)
 		client->bits.localsock.private = 0;
 		break;
 
-	case CLVMD_CMD_LOCK_VG:
-	case CLVMD_CMD_VG_BACKUP:
-	case CLVMD_CMD_SYNC_NAMES:
-	case CLVMD_CMD_LOCK_QUERY:
-		/* Nothing to do here */
-		break;
-
 	case CLVMD_CMD_LOCK_LV:
 		lock_cmd = args[0];
 		lock_flags = args[1];
 		lockname = &args[2];
 		status = post_lock_lv(lock_cmd, lock_flags, lockname);
 		break;
+
+	default:
+		/* Nothing to do here */
+		break;
 	}
 	return status;
 }
@@ -381,9 +377,9 @@ static int restart_clvmd(void)
 		goto_out;
 
 	/* Propogate debug options */
-	if (debug) {
+	if (clvmd_get_debug()) {
 		if (!(debug_arg = malloc(16)) ||
-		    dm_snprintf(debug_arg, 16, "-d%d", (int)debug) < 0)
+		    dm_snprintf(debug_arg, 16, "-d%d", (int)clvmd_get_debug()) < 0)
 			goto_out;
 		argv[argc++] = debug_arg;
 	}
daemons/clvmd/clvmd.c +45 -23

135 lines not on this page · raw message

daemons/clvmd/clvmd.h +3 -0
index ccc79cc..95244e1 100644
@@ -117,6 +117,9 @@ extern void process_message(struct local_client *client, const char *buf,
 extern void debuglog(const char *fmt, ... )
   __attribute__ ((format(printf, 1, 2)));
 
+void clvmd_set_debug(debug_t new_de);
+debug_t clvmd_get_debug(void);
+
 int sync_lock(const char *resource, int mode, int flags, int *lockid);
 int sync_unlock(const char *resource, int lockid);
 
man/clvmd.8.in +5 -6
index 53a9113..c6353d3 100644
@@ -3,7 +3,7 @@
 clvmd \- cluster LVM daemon
 .SH SYNOPSIS
 .B clvmd
-[\-d [<value>]] [\-C] [\-h]
+[\-d[<value>]] [\-C] [\-h]
 [\-R]
 [\-S]
 [\-t <timeout>]
@@ -15,19 +15,18 @@ It must be running on all nodes in the cluster and will give an error
 if a node in the cluster does not have this daemon running.
 .SH OPTIONS
 .TP
-.I \-d [<value>]
+.I \-d[<value>]
 Enable debug logging. Value can be 0, 1 or 2.
 .br
-0 disables debug logging in a running clvmd
+0 disables debug logging
 .br
-1 sends debug logs to stderr (clvmd will not fork in this case)
+1 sends debug logs to stderr (to syslog in daemon mode)
 .br
 2 sends debug logs to syslog
 .br
 If 
 .B -d 
-is specified without a value then 1 is assumed if you are starting a
-new clvmd, 2 if you are enabling debug in a running clvmd.
+is specified without a value then 1 is assumed.
 .TP
 .I \-C
 Only valid if 
test/lib/aux.sh +1 -1
index 04367ea..6dc3824 100644
@@ -28,7 +28,7 @@ prepare_clvmd() {
 
 	lvmconf "activation/monitoring = 1"
 
-	clvmd -Isinglenode -d 1 &
+	clvmd -Isinglenode -d 1 -f &
 	LOCAL_CLVMD="$!"
 
 	# check that it is really running now
Signature · 1 line
1.7.2.3
author
#1 lore raw

PATCH 1/1 Remove DEBUGLOG from dmeventd

DEBUGLOG is used only on one line, remove it completely.

---
 daemons/dmeventd/dmeventd.c |   22 +---------------------
 1 files changed, 1 insertions(+), 21 deletions(-)
daemons/dmeventd/dmeventd.c +1 -21
index 2b454f9..4ac5e25 100644
@@ -95,8 +95,6 @@ static pthread_mutex_t _global_mutex;
 
 #define THREAD_STACK_SIZE (300*1024)
 
-#define DEBUGLOG(fmt, args...) _debuglog(fmt, ## args)
-
 int dmeventd_debug = 0;
 static int _foreground = 0;
 static int _restart = 0;
@@ -203,24 +201,6 @@ static DM_LIST_INIT(_timeout_registry);
 static pthread_mutex_t _timeout_mutex = PTHREAD_MUTEX_INITIALIZER;
 static pthread_cond_t _timeout_cond = PTHREAD_COND_INITIALIZER;
 
-static void _debuglog(const char *fmt, ...)
-{
-        time_t P;
-        va_list ap;
- 
-        if (!_foreground)
-                return;
- 
-        va_start(ap,fmt);
-
-        time(&P);
-        fprintf(stderr, "dmeventd[%p]: %.15s ", (void *) pthread_self(), ctime(&P)+4 );
-        vfprintf(stderr, fmt, ap);
-	fprintf(stderr, "\n");
-
-        va_end(ap);
-}
-
 /* Allocate/free the status structure for a monitoring thread. */
 static struct thread_status *_alloc_thread_status(struct message_data *data,
 						  struct dso_data *dso_data)
@@ -1621,7 +1601,7 @@ static int _set_oom_adj(int val)
 
 	if (stat(OOM_ADJ_FILE, &st) == -1) {
 		if (errno == ENOENT)
-			DEBUGLOG(OOM_ADJ_FILE " not found");
+			perror(OOM_ADJ_FILE " not found");
 		else
 			perror(OOM_ADJ_FILE ": stat failed");
 		return 1;
Signature · 1 line
1.7.2.3