public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW_DM daemons/dmeventd/dmeventd. ...
@ 2012-03-14 15:51 prajnoha
0 siblings, 0 replies; 3+ messages in thread
From: prajnoha @ 2012-03-14 15:51 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: prajnoha@sourceware.org 2012-03-14 15:51:52
Modified files:
. : WHATS_NEW_DM
daemons/dmeventd: dmeventd.c
libdaemon/server: daemon-server.c
scripts : dm_event_systemd_red_hat.service.in
lvm2_lvmetad_systemd_red_hat.service.in
Log message:
Use SD_ACTIVATION env. var. in systemd units to better detect systemd in use.
LISTEN_PID and LISTEN_FDS environment variables are defined only during systemd
"start" action. But we still need to know whether we're activated during
"reload" action as well - we use the reload action to call "dmeventd -R"/"lvmetad -R"
for statefull daemon restart. We can't use normal "restart" as that is simply
composed of "stop" and "start" and we would lose any state the daemon has.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.593&r2=1.594
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/dmeventd.c.diff?cvsroot=lvm2&r1=1.97&r2=1.98
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdaemon/server/daemon-server.c.diff?cvsroot=lvm2&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/dm_event_systemd_red_hat.service.in.diff?cvsroot=lvm2&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/lvm2_lvmetad_systemd_red_hat.service.in.diff?cvsroot=lvm2&r1=1.4&r2=1.5
--- LVM2/WHATS_NEW_DM 2012/03/14 11:16:00 1.593
+++ LVM2/WHATS_NEW_DM 2012/03/14 15:51:51 1.594
@@ -1,5 +1,6 @@
Version 1.02.75 -
================================
+ Use SD_ACTIVATION env. var. in systemd units to better detect systemd in use.
Do not run a new dmeventd instance on restart if there's no existing one.
Make the time window for reading fifo longer 5sec (1.02.73).
--- LVM2/daemons/dmeventd/dmeventd.c 2012/03/14 11:16:01 1.97
+++ LVM2/daemons/dmeventd/dmeventd.c 2012/03/14 15:51:51 1.98
@@ -56,6 +56,7 @@
# define OOM_SCORE_ADJ_MIN (-1000)
/* Systemd on-demand activation support */
+# define SD_ACTIVATION_ENV_VAR_NAME "SD_ACTIVATION"
# define SD_LISTEN_PID_ENV_VAR_NAME "LISTEN_PID"
# define SD_LISTEN_FDS_ENV_VAR_NAME "LISTEN_FDS"
# define SD_LISTEN_FDS_START 3
@@ -1698,6 +1699,10 @@
memset(fifos, 0, sizeof(*fifos));
+ /* SD_ACTIVATION must be set! */
+ if (!(e = getenv(SD_ACTIVATION_ENV_VAR_NAME)) || strcmp(e, "1"))
+ goto out;
+
/* LISTEN_PID must be equal to our PID! */
if (!(e = getenv(SD_LISTEN_PID_ENV_VAR_NAME)))
goto out;
@@ -1729,6 +1734,7 @@
}
out:
+ unsetenv(SD_ACTIVATION_ENV_VAR_NAME);
unsetenv(SD_LISTEN_PID_ENV_VAR_NAME);
unsetenv(SD_LISTEN_FDS_ENV_VAR_NAME);
return r;
--- LVM2/libdaemon/server/daemon-server.c 2012/03/08 14:54:05 1.4
+++ LVM2/libdaemon/server/daemon-server.c 2012/03/14 15:51:52 1.5
@@ -69,6 +69,7 @@
# define OOM_SCORE_ADJ_MIN (-1000)
/* Systemd on-demand activation support */
+# define SD_ACTIVATION_ENV_VAR_NAME "SD_ACTIVATION"
# define SD_LISTEN_PID_ENV_VAR_NAME "LISTEN_PID"
# define SD_LISTEN_FDS_ENV_VAR_NAME "LISTEN_FDS"
# define SD_LISTEN_FDS_START 3
@@ -164,6 +165,10 @@
unsigned long env_pid, env_listen_fds;
int r = 0;
+ /* SD_ACTIVATION must be set! */
+ if (!(e = getenv(SD_ACTIVATION_ENV_VAR_NAME)) || strcmp(e, "1"))
+ goto out;
+
/* LISTEN_PID must be equal to our PID! */
if (!(e = getenv(SD_LISTEN_PID_ENV_VAR_NAME)))
goto out;
@@ -188,6 +193,7 @@
ds->socket_fd = SD_FD_SOCKET_SERVER;
out:
+ unsetenv(SD_ACTIVATION_ENV_VAR_NAME);
unsetenv(SD_LISTEN_PID_ENV_VAR_NAME);
unsetenv(SD_LISTEN_FDS_ENV_VAR_NAME);
return r;
--- LVM2/scripts/dm_event_systemd_red_hat.service.in 2012/02/01 13:08:39 1.3
+++ LVM2/scripts/dm_event_systemd_red_hat.service.in 2012/03/14 15:51:52 1.4
@@ -9,6 +9,7 @@
Type=forking
ExecStart=@sbindir@/dmeventd
ExecReload=@sbindir@/dmeventd -R
+Environment=SD_ACTIVATION=1
PIDFile=@DMEVENTD_PIDFILE@
OOMScoreAdjust=-1000
--- LVM2/scripts/lvm2_lvmetad_systemd_red_hat.service.in 2012/03/08 09:49:09 1.4
+++ LVM2/scripts/lvm2_lvmetad_systemd_red_hat.service.in 2012/03/14 15:51:52 1.5
@@ -11,6 +11,7 @@
ExecStart=@sbindir@/lvmetad
ExecStartPost=@sbindir@/vgscan
ExecReload=@sbindir@/lvmetad -R
+Environment=SD_ACTIVATION=1
Restart=on-abort
PIDFile=@DEFAULT_RUN_DIR@/lvmetad.pid
^ permalink raw reply [flat|nested] 3+ messages in thread
* LVM2 ./WHATS_NEW_DM daemons/dmeventd/dmeventd. ...
@ 2010-08-16 18:19 agk
0 siblings, 0 replies; 3+ messages in thread
From: agk @ 2010-08-16 18:19 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2010-08-16 18:19:46
Modified files:
. : WHATS_NEW_DM
daemons/dmeventd: dmeventd.c libdevmapper-event.c
daemons/dmeventd/plugins/mirror: dmeventd_mirror.c
Log message:
Remove superfluous NULL pointer tests before dm_free from dmeventd.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.408&r2=1.409
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/dmeventd.c.diff?cvsroot=lvm2&r1=1.64&r2=1.65
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/libdevmapper-event.c.diff?cvsroot=lvm2&r1=1.32&r2=1.33
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c.diff?cvsroot=lvm2&r1=1.36&r2=1.37
--- LVM2/WHATS_NEW_DM 2010/08/16 11:22:08 1.408
+++ LVM2/WHATS_NEW_DM 2010/08/16 18:19:46 1.409
@@ -1,5 +1,6 @@
Version 1.02.54 -
================================
+ Remove superfluous NULL pointer tests before dm_free from dmeventd.
Assume dm-mod autoloading support is in kernel 2.6.36 and higher, not 2.6.35.
Fix udev rules to support udev database content generated by older rules.
Reinstate detection of inappropriate uevent with DISK_RO set and suppress it.
--- LVM2/daemons/dmeventd/dmeventd.c 2010/07/13 13:51:02 1.64
+++ LVM2/daemons/dmeventd/dmeventd.c 2010/08/16 18:19:46 1.65
@@ -327,13 +327,10 @@
/* Free message memory. */
static void _free_message(struct message_data *message_data)
{
- if (message_data->id)
- dm_free(message_data->id);
- if (message_data->dso_name)
- dm_free(message_data->dso_name);
+ dm_free(message_data->id);
+ dm_free(message_data->dso_name);
- if (message_data->device_uuid)
- dm_free(message_data->device_uuid);
+ dm_free(message_data->device_uuid);
}
@@ -1051,8 +1048,7 @@
&& (thread->events)) ? thread->events : thread->
events | DM_EVENT_REGISTRATION_PENDING;
- if (msg->data)
- dm_free(msg->data);
+ dm_free(msg->data);
msg->size = dm_asprintf(&(msg->data), fmt, id, dso, dev, events);
@@ -1162,8 +1158,7 @@
struct thread_status *thread;
struct dm_event_daemon_message *msg = message_data->msg;
- if (msg->data)
- dm_free(msg->data);
+ dm_free(msg->data);
_lock_mutex();
if ((thread = _lookup_thread_status(message_data))) {
@@ -1287,8 +1282,7 @@
}
if (bytes != size) {
- if (msg->data)
- dm_free(msg->data);
+ dm_free(msg->data);
msg->data = NULL;
msg->size = 0;
}
@@ -1416,8 +1410,7 @@
if (!_client_write(fifos, &msg))
stack;
- if (msg.data)
- dm_free(msg.data);
+ dm_free(msg.data);
}
static void _cleanup_unused_threads(void)
--- LVM2/daemons/dmeventd/libdevmapper-event.c 2010/04/14 13:01:42 1.32
+++ LVM2/daemons/dmeventd/libdevmapper-event.c 2010/08/16 18:19:46 1.33
@@ -47,10 +47,8 @@
static void _dm_event_handler_clear_dev_info(struct dm_event_handler *dmevh)
{
- if (dmevh->dev_name)
- dm_free(dmevh->dev_name);
- if (dmevh->uuid)
- dm_free(dmevh->uuid);
+ dm_free(dmevh->dev_name);
+ dm_free(dmevh->uuid);
dmevh->dev_name = dmevh->uuid = NULL;
dmevh->major = dmevh->minor = 0;
}
@@ -73,8 +71,7 @@
void dm_event_handler_destroy(struct dm_event_handler *dmevh)
{
_dm_event_handler_clear_dev_info(dmevh);
- if (dmevh->dso)
- dm_free(dmevh->dso);
+ dm_free(dmevh->dso);
dm_free(dmevh);
}
@@ -82,8 +79,7 @@
{
if (!path) /* noop */
return 0;
- if (dmevh->dso)
- dm_free(dmevh->dso);
+ dm_free(dmevh->dso);
dmevh->dso = dm_strdup(path);
if (!dmevh->dso)
@@ -259,8 +255,7 @@
}
if (bytes != size) {
- if (msg->data)
- dm_free(msg->data);
+ dm_free(msg->data);
msg->data = NULL;
}
@@ -366,8 +361,7 @@
do {
- if (msg->data)
- dm_free(msg->data);
+ dm_free(msg->data);
msg->data = 0;
if (!_daemon_read(fifos, msg)) {
@@ -564,8 +558,7 @@
ret = _daemon_talk(&fifos, msg, DM_EVENT_CMD_HELLO, 0, 0, 0, 0);
- if (msg->data)
- dm_free(msg->data);
+ dm_free(msg->data);
msg->data = 0;
if (!ret)
@@ -600,8 +593,7 @@
ret = 0;
}
- if (msg.data)
- dm_free(msg.data);
+ dm_free(msg.data);
dm_task_destroy(dmt);
@@ -630,8 +622,7 @@
ret = 0;
}
- if (msg.data)
- dm_free(msg.data);
+ dm_free(msg.data);
dm_task_destroy(dmt);
@@ -711,10 +702,8 @@
dm_task_destroy(dmt);
dmt = NULL;
- if (msg.data) {
- dm_free(msg.data);
- msg.data = NULL;
- }
+ dm_free(msg.data);
+ msg.data = NULL;
_dm_event_handler_clear_dev_info(dmevh);
dmevh->uuid = dm_strdup(reply_uuid);
@@ -731,15 +720,11 @@
dm_event_handler_set_dso(dmevh, reply_dso);
dm_event_handler_set_event_mask(dmevh, reply_mask);
- if (reply_dso) {
- dm_free(reply_dso);
- reply_dso = NULL;
- }
+ dm_free(reply_dso);
+ reply_dso = NULL;
- if (reply_uuid) {
- dm_free(reply_uuid);
- reply_uuid = NULL;
- }
+ dm_free(reply_uuid);
+ reply_uuid = NULL;
dmevh->dev_name = dm_strdup(dm_task_get_name(dmt));
if (!dmevh->dev_name) {
@@ -760,12 +745,9 @@
return ret;
fail:
- if (msg.data)
- dm_free(msg.data);
- if (reply_dso)
- dm_free(reply_dso);
- if (reply_uuid)
- dm_free(reply_uuid);
+ dm_free(msg.data);
+ dm_free(reply_dso);
+ dm_free(reply_uuid);
_dm_event_handler_clear_dev_info(dmevh);
if (dmt)
dm_task_destroy(dmt);
--- LVM2/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c 2010/07/09 15:34:41 1.36
+++ LVM2/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c 2010/08/16 18:19:46 1.37
@@ -119,13 +119,11 @@
goto out_parse;
out:
- if (args)
- dm_free(args);
+ dm_free(args);
return r;
out_parse:
- if (args)
- dm_free(args);
+ dm_free(args);
syslog(LOG_ERR, "Unable to parse mirror status string.");
return ME_IGNORE;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* LVM2 ./WHATS_NEW_DM daemons/dmeventd/dmeventd. ...
@ 2010-05-14 14:56 agk
0 siblings, 0 replies; 3+ messages in thread
From: agk @ 2010-05-14 14:56 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2010-05-14 14:56:40
Modified files:
. : WHATS_NEW_DM
daemons/dmeventd: dmeventd.c
daemons/dmeventd/plugins/lvm2: dmeventd_lvm.c
daemons/dmeventd/plugins/mirror: dmeventd_mirror.c
test : test-utils.sh
Log message:
Use -d to control level of messages sent to syslog by dmeventd.
Change -d to -f to run dmeventd in foreground.
(mornfall)
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.368&r2=1.369
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/dmeventd.c.diff?cvsroot=lvm2&r1=1.61&r2=1.62
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/plugins/lvm2/dmeventd_lvm.c.diff?cvsroot=lvm2&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c.diff?cvsroot=lvm2&r1=1.34&r2=1.35
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/test-utils.sh.diff?cvsroot=lvm2&r1=1.42&r2=1.43
--- LVM2/WHATS_NEW_DM 2010/05/13 13:31:30 1.368
+++ LVM2/WHATS_NEW_DM 2010/05/14 14:56:39 1.369
@@ -1,5 +1,7 @@
Version 1.02.48 -
=================================
+ Use -d to control level of messages sent to syslog by dmeventd.
+ Change -d to -f to run dmeventd in foreground.
Do not print encryption key in message debug output (cryptsetup luksResume).
Version 1.02.47 - 30th April 2010
--- LVM2/daemons/dmeventd/dmeventd.c 2010/04/14 18:54:37 1.61
+++ LVM2/daemons/dmeventd/dmeventd.c 2010/05/14 14:56:39 1.62
@@ -54,7 +54,6 @@
static volatile sig_atomic_t _exit_now = 0; /* set to '1' when signal is given to exit */
static volatile sig_atomic_t _thread_registries_empty = 1; /* registries are empty initially */
-static int _debug = 0;
/* List (un)link macros. */
#define LINK(x, head) dm_list_add(head, &(x)->list)
@@ -98,6 +97,9 @@
#define DEBUGLOG(fmt, args...) _debuglog(fmt, ## args)
+int dmeventd_debug = 0;
+static int _foreground = 0;
+
/* Data kept about a DSO. */
struct dso_data {
struct dm_list list;
@@ -204,7 +206,7 @@
time_t P;
va_list ap;
- if (!_debug)
+ if (!_foreground)
return;
va_start(ap,fmt);
@@ -1662,11 +1664,12 @@
static void usage(char *prog, FILE *file)
{
fprintf(file, "Usage:\n");
- fprintf(file, "%s [Vhd]\n", prog);
+ fprintf(file, "%s [-V] [-h] [-d] [-d] [-d] [-f]\n", prog);
fprintf(file, "\n");
fprintf(file, " -V Show version of dmeventd\n");
fprintf(file, " -h Show this help information\n");
- fprintf(file, " -d Don't fork, run in the foreground\n");
+ fprintf(file, " -d Log debug messages to syslog (-d, -dd, -ddd)\n");
+ fprintf(file, " -f Don't fork, run in the foreground\n");
fprintf(file, "\n");
}
@@ -1680,7 +1683,7 @@
opterr = 0;
optind = 0;
- while ((opt = getopt(argc, argv, "?hVd")) != EOF) {
+ while ((opt = getopt(argc, argv, "?fhVd")) != EOF) {
switch (opt) {
case 'h':
usage(argv[0], stdout);
@@ -1688,8 +1691,11 @@
case '?':
usage(argv[0], stderr);
exit(0);
+ case 'f':
+ _foreground++;
+ break;
case 'd':
- _debug++;
+ dmeventd_debug++;
break;
case 'V':
printf("dmeventd version: %s\n", DM_LIB_VERSION);
@@ -1706,7 +1712,7 @@
if (setenv("LANG", "C", 1))
perror("Cannot set LANG to C");
- if (!_debug)
+ if (!_foreground)
_daemonize();
openlog("dmeventd", LOG_PID, LOG_DAEMON);
@@ -1738,7 +1744,7 @@
exit(EXIT_FIFO_FAILURE);
/* Signal parent, letting them know we are ready to go. */
- if (!_debug)
+ if (!_foreground)
kill(getppid(), SIGTERM);
syslog(LOG_NOTICE, "dmeventd ready for processing.");
--- LVM2/daemons/dmeventd/plugins/lvm2/dmeventd_lvm.c 2010/03/30 14:38:56 1.2
+++ LVM2/daemons/dmeventd/plugins/lvm2/dmeventd_lvm.c 2010/05/14 14:56:39 1.3
@@ -13,6 +13,7 @@
*/
#include "lib.h"
+#include "log.h"
#include "lvm2cmd.h"
#include "errors.h"
@@ -22,6 +23,8 @@
#include <pthread.h>
#include <syslog.h>
+extern int dmeventd_debug;
+
/*
* register_device() is called first and performs initialisation.
* Only one device may be registered or unregistered at a time.
@@ -40,19 +43,41 @@
*/
static pthread_mutex_t _event_mutex = PTHREAD_MUTEX_INITIALIZER;
-/* FIXME Remove this: Pass messages back to dmeventd core for processing. */
+/*
+ * FIXME Do not pass things directly to syslog, rather use the existing logging
+ * facilities to sort logging ... however that mechanism needs to be somehow
+ * configurable and we don't have that option yet
+ */
static void _temporary_log_fn(int level,
const char *file __attribute((unused)),
int line __attribute((unused)),
int dm_errno __attribute((unused)),
- const char *format)
+ const char *message)
{
- level &= ~_LOG_STDERR;
+ level &= ~(_LOG_STDERR | _LOG_ONCE);
- if (!strncmp(format, "WARNING: ", 9) && (level < 5))
- syslog(LOG_CRIT, "%s", format);
- else
- syslog(LOG_DEBUG, "%s", format);
+ switch (level) {
+ case _LOG_DEBUG:
+ if (dmeventd_debug >= 3)
+ syslog(LOG_DEBUG, "%s", message);
+ break;
+ case _LOG_INFO:
+ if (dmeventd_debug >= 2)
+ syslog(LOG_INFO, "%s", message);
+ break;
+ case _LOG_NOTICE:
+ if (dmeventd_debug >= 1)
+ syslog(LOG_NOTICE, "%s", message);
+ break;
+ case _LOG_WARN:
+ syslog(LOG_WARNING, "%s", message);
+ break;
+ case _LOG_ERR:
+ syslog(LOG_ERR, "%s", message);
+ break;
+ default:
+ syslog(LOG_CRIT, "%s", message);
+ }
}
void dmeventd_lvm2_lock(void)
--- LVM2/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c 2010/05/11 08:32:22 1.34
+++ LVM2/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c 2010/05/14 14:56:39 1.35
@@ -160,7 +160,8 @@
r = dmeventd_lvm2_run(cmd_str);
- syslog(LOG_INFO, "Repair of mirrored LV %s/%s %s.", vg, lv, (r == ECMD_PROCESSED) ? "finished successfully" : "failed");
+ syslog(LOG_INFO, "Repair of mirrored LV %s/%s %s.", vg, lv,
+ (r == ECMD_PROCESSED) ? "finished successfully" : "failed");
return (r == ECMD_PROCESSED) ? 0 : -1;
}
--- LVM2/test/test-utils.sh 2010/05/12 11:58:51 1.42
+++ LVM2/test/test-utils.sh 2010/05/14 14:56:40 1.43
@@ -87,9 +87,8 @@
trap_teardown
- dmeventd -d &
+ dmeventd -f &
LOCAL_DMEVENTD="$!"
- strace -p $LOCAL_DMEVENTD &
}
prepare_testroot() {
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-03-14 15:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-14 15:51 LVM2 ./WHATS_NEW_DM daemons/dmeventd/dmeventd. prajnoha
-- strict thread matches above, loose matches on Subject: below --
2010-08-16 18:19 agk
2010-05-14 14:56 agk
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).