public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 daemons/dmeventd/plugins/mirror/dmeventd_ ...
@ 2012-02-08 11:29 zkabelac
  0 siblings, 0 replies; 2+ messages in thread
From: zkabelac @ 2012-02-08 11:29 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-02-08 11:29:14

Modified files:
	daemons/dmeventd/plugins/mirror: dmeventd_mirror.c 
	lib/mirror     : mirrored.c 

Log message:
	Add boundary test for number of mirror devs and logs
	
	As atoi may return negative value - test for both limits.
	Test log_args for limits before calling alloca().
	Code from dmeventd mirror plugin should probably share same code as
	we have in mirrored.c.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c.diff?cvsroot=lvm2&r1=1.38&r2=1.39
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.92&r2=1.93

--- LVM2/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c	2011/12/22 16:37:02	1.38
+++ LVM2/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c	2012/02/08 11:29:13	1.39
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2011 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2005-2012 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -18,6 +18,7 @@
 #include "errors.h"
 #include "libdevmapper-event.h"
 #include "dmeventd_lvm.h"
+#include "defaults.h"
 
 #include <syslog.h> /* FIXME Replace syslog with multilog */
 /* FIXME Missing openlog? */
@@ -81,7 +82,8 @@
 	if (!dm_split_words(params, 1, 0, &p))
 		goto out_parse;
 
-	if (!(num_devs = atoi(p)))
+	if (!(num_devs = atoi(p)) ||
+	    (num_devs > DEFAULT_MIRROR_MAX_IMAGES) || (num_devs < 0))
 		goto out_parse;
 	p += strlen(p) + 1;
 
@@ -90,6 +92,7 @@
 	if (!args || dm_split_words(p, num_devs + 7, 0, args) < num_devs + 5)
 		goto out_parse;
 
+	/* FIXME: Code differs from lib/mirror/mirrored.c */
 	dev_status_str = args[2 + num_devs];
 	log_argc = atoi(args[3 + num_devs]);
 	log_status_str = args[3 + num_devs + log_argc];
--- LVM2/lib/mirror/mirrored.c	2011/11/28 20:37:52	1.92
+++ LVM2/lib/mirror/mirrored.c	2012/02/08 11:29:14	1.93
@@ -248,7 +248,7 @@
 
 	p += strlen(p) + 1;
 
-	if (num_devs > DEFAULT_MIRROR_MAX_IMAGES) {
+	if (num_devs > DEFAULT_MIRROR_MAX_IMAGES || num_devs < 0) {
 		log_error("Unexpectedly many (%d) mirror images in %s.",
 			  num_devs, lv->name);
 		return_0;
@@ -261,14 +261,14 @@
 		return_0;
 
 	log_argc = atoi(args[3 + num_devs]);
-	log_args = alloca(log_argc * sizeof(char *));
 
-	if (log_argc > 16) {
+	if (log_argc > 16 || log_argc < 0) {
 		log_error("Unexpectedly many (%d) log arguments in %s.",
 			  log_argc, lv->name);
 		return_0;
 	}
 
+	log_args = alloca(log_argc * sizeof(char *));
 
 	if (dm_split_words(args[3 + num_devs] + strlen(args[3 + num_devs]) + 1,
 			   log_argc, 0, log_args) < log_argc)


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

* LVM2 daemons/dmeventd/plugins/mirror/dmeventd_ ...
@ 2009-06-15 14:47 mornfall
  0 siblings, 0 replies; 2+ messages in thread
From: mornfall @ 2009-06-15 14:47 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2009-06-15 14:47:40

Modified files:
	daemons/dmeventd/plugins/mirror: dmeventd_mirror.c 
	tools          : lvconvert.c vgreduce.c 

Log message:
	- Ignore suspended devices during repair (Milan).
	- Call vgreduce --removemissing (without --force) automatically to clean up bad
	PVs (Milan).

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c.diff?cvsroot=lvm2&r1=1.23&r2=1.24
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.81&r2=1.82
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgreduce.c.diff?cvsroot=lvm2&r1=1.91&r2=1.92

--- LVM2/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c	2009/06/04 12:01:15	1.23
+++ LVM2/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c	2009/06/15 14:47:39	1.24
@@ -161,6 +161,12 @@
 
 	r = lvm2_run(_lvm_handle, cmd_str);
 
+	if (r == 1) {
+		snprintf(cmd_str, CMD_SIZE, "vgreduce --removemissing %s", vg);
+		if (lvm2_run(_lvm_handle, cmd_str) != 1)
+			syslog(LOG_ERR, "Unable to remove failed PVs from VG %s", vg);
+	}
+
 	dm_pool_empty(_mem_pool);  /* FIXME: not safe with multiple threads */
 	return (r == 1) ? 0 : -1;
 }
--- LVM2/tools/lvconvert.c	2009/06/15 13:43:16	1.81
+++ LVM2/tools/lvconvert.c	2009/06/15 14:47:39	1.82
@@ -926,18 +926,22 @@
 	struct lvconvert_params lp;
 	int ret = ECMD_FAILED;
 	struct lvinfo info;
+	int saved_ignore_suspended_devices = ignore_suspended_devices();
 
 	if (!_read_params(&lp, cmd, argc, argv)) {
 		stack;
 		return EINVALID_CMD_LINE;
 	}
 
+	if (arg_count(cmd, repair_ARG))
+		init_ignore_suspended_devices(1);
+
 	log_verbose("Checking for existing volume group \"%s\"", lp.vg_name);
 
 	if (!(vg = vg_lock_and_read(cmd, lp.vg_name, NULL, LCK_VG_WRITE,
 				    CLUSTERED | EXPORTED_VG | LVM_WRITE,
 				    CORRECT_INCONSISTENT)))
-		return ECMD_FAILED;
+		goto out;
 
 	if (!(lvl = find_lv_in_vg(vg, lp.lv_name))) {
 		log_error("Logical volume \"%s\" not found in "
@@ -966,6 +970,7 @@
 				     lp.wait_completion ? 0 : 1U);
 	}
 out:
+	init_ignore_suspended_devices(saved_ignore_suspended_devices);
 	vg_release(vg);
 	return ret;
 }
--- LVM2/tools/vgreduce.c	2009/05/21 03:04:54	1.91
+++ LVM2/tools/vgreduce.c	2009/06/15 14:47:40	1.92
@@ -466,6 +466,7 @@
 	int consistent = 1;
 	int fixed = 1;
 	int repairing = arg_count(cmd, removemissing_ARG);
+	int saved_ignore_suspended_devices = ignore_suspended_devices();
 
 	if (!argc && !repairing) {
 		log_error("Please give volume group name and "
@@ -515,6 +516,9 @@
 		return ECMD_FAILED;
 	}
 
+	if (repairing)
+		init_ignore_suspended_devices(1);
+
 	if ((!(vg = vg_read_internal(cmd, vg_name, NULL, &consistent)) || !consistent)
 	    && !repairing) {
 		log_error("Volume group \"%s\" doesn't exist", vg_name);
@@ -574,6 +578,7 @@
 
 	}
 out:
+	init_ignore_suspended_devices(saved_ignore_suspended_devices);
 	unlock_and_release_vg(cmd, vg, vg_name);
 
 	return ret;


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

end of thread, other threads:[~2012-02-08 11:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-08 11:29 LVM2 daemons/dmeventd/plugins/mirror/dmeventd_ zkabelac
  -- strict thread matches above, loose matches on Subject: below --
2009-06-15 14:47 mornfall

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).