public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW daemons/cmirrord/functions.c
@ 2012-02-08 11:34 zkabelac
  0 siblings, 0 replies; 8+ messages in thread
From: zkabelac @ 2012-02-08 11:34 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

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

Modified files:
	.              : WHATS_NEW 
	daemons/cmirrord: functions.c 

Log message:
	Keep page_size as signed number
	
	Since it's return value from sysconf and is checked for <0.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2266&r2=1.2267
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/cmirrord/functions.c.diff?cvsroot=lvm2&r1=1.30&r2=1.31

--- LVM2/WHATS_NEW	2012/02/08 11:31:29	1.2266
+++ LVM2/WHATS_NEW	2012/02/08 11:34:46	1.2267
@@ -1,5 +1,6 @@
 Version 2.02.91 -
 ===================================
+  Use signed long for sysconf() call in cmirrord.
   Do not write in front of log buffer in print_log().
   Add boundary test for number of mirror devs and logs.
   Check that whole locking_dir fits _lock_dir buffer in init_file_locking().
--- LVM2/daemons/cmirrord/functions.c	2011/10/14 14:18:49	1.30
+++ LVM2/daemons/cmirrord/functions.c	2012/02/08 11:34:46	1.31
@@ -375,7 +375,7 @@
 	int disk_log = 0;
 	char disk_path[128];
 	int unlink_path = 0;
-	size_t page_size;
+	long page_size;
 	int pages;
 
 	/* If core log request, then argv[0] will be region_size */


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

* LVM2 ./WHATS_NEW daemons/cmirrord/functions.c
@ 2011-09-06 18:24 zkabelac
  0 siblings, 0 replies; 8+ messages in thread
From: zkabelac @ 2011-09-06 18:24 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-09-06 18:24:27

Modified files:
	.              : WHATS_NEW 
	daemons/cmirrord: functions.c 

Log message:
	Detect sscanf recovering_region input error
	
	Missing check for sscanf found by static analyzer.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2092&r2=1.2093
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/cmirrord/functions.c.diff?cvsroot=lvm2&r1=1.27&r2=1.28

--- LVM2/WHATS_NEW	2011/09/06 18:15:43	1.2092
+++ LVM2/WHATS_NEW	2011/09/06 18:24:27	1.2093
@@ -1,5 +1,6 @@
 Version 2.02.89 - 
 ==================================
+  Detect sscanf recovering_region input error in cmirrord pull_state().
   Fix error path bitmap leak in cmirrord import_checkpoint().
   Log unlink() error in cmirrord remove_lockfile().
   Remove incorrect requirement for -j or -m from lvchange error message.
--- LVM2/daemons/cmirrord/functions.c	2010/12/20 13:58:38	1.27
+++ LVM2/daemons/cmirrord/functions.c	2011/09/06 18:24:27	1.28
@@ -1817,8 +1817,11 @@
 	}
 
 	if (!strncmp(which, "recovering_region", 17)) {
-		sscanf(buf, "%llu %u", (unsigned long long *)&lc->recovering_region,
-		       &lc->recoverer);
+		if (sscanf(buf, "%llu %u", (unsigned long long *)&lc->recovering_region,
+			   &lc->recoverer) != 2) {
+			LOG_ERROR("cannot parse recovering region from: %s", buf);
+			return -EINVAL;
+		}
 		LOG_SPRINT(lc, "CKPT INIT - SEQ#=X, UUID=%s, nodeid = X:: "
 			   "recovering_region=%llu, recoverer=%u",
 			   SHORT_UUID(lc->uuid),


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

* LVM2 ./WHATS_NEW daemons/cmirrord/functions.c
@ 2010-12-20 13:57 zkabelac
  0 siblings, 0 replies; 8+ messages in thread
From: zkabelac @ 2010-12-20 13:57 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-12-20 13:57:19

Modified files:
	.              : WHATS_NEW 
	daemons/cmirrord: functions.c 

Log message:
	Use dm_free for dm_malloc-ed areas in _clog_ctr/_clog_dtr (cmirrord).
	
	Use dm_zalloc to obtain zeroed memory block.
	Use dm_free for dm_ allocated memory blocks.
	Test close() for error.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1845&r2=1.1846
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/cmirrord/functions.c.diff?cvsroot=lvm2&r1=1.25&r2=1.26

--- LVM2/WHATS_NEW	2010/12/20 13:53:10	1.1845
+++ LVM2/WHATS_NEW	2010/12/20 13:57:19	1.1846
@@ -1,5 +1,6 @@
 Version 2.02.79 -  
 ===================================
+  Use dm_free for dm_malloc-ed areas in _clog_ctr/_clog_dtr (cmirrord).
   Add checks for allocation errors in config node clonning.
   Fix error path if regex engine cannot be created in _build_matcher().
   Use char* arithmetic in target_version(), _process_all(), _targets().
--- LVM2/daemons/cmirrord/functions.c	2010/10/26 10:14:41	1.25
+++ LVM2/daemons/cmirrord/functions.c	2010/12/20 13:57:19	1.26
@@ -429,13 +429,12 @@
 			block_on_error = 1;
 	}
 
-	lc = malloc(sizeof(*lc));
+	lc = dm_zalloc(sizeof(*lc));
 	if (!lc) {
 		LOG_ERROR("Unable to allocate cluster log context");
 		r = -ENOMEM;
 		goto fail;
 	}
-	memset(lc, 0, sizeof(*lc));
 
 	lc->region_size = region_size;
 	lc->region_count = region_count;
@@ -453,7 +452,7 @@
 	    (duplicate = get_pending_log(lc->uuid, lc->luid))) {
 		LOG_ERROR("[%s/%" PRIu64 "u] Log already exists, unable to create.",
 			  SHORT_UUID(lc->uuid), lc->luid);
-		free(lc);
+		dm_free(lc);
 		return -EINVAL;
 	}
 
@@ -511,15 +510,13 @@
 	return 0;
 fail:
 	if (lc) {
-		if (lc->clean_bits)
-			free(lc->clean_bits);
-		if (lc->sync_bits)
-			free(lc->sync_bits);
-		if (lc->disk_buffer)
-			free(lc->disk_buffer);
-		if (lc->disk_fd >= 0)
-			close(lc->disk_fd);
-		free(lc);
+		if (lc->disk_fd >= 0 && close(lc->disk_fd))
+			LOG_ERROR("Close device error, %s: %s",
+				  disk_path, strerror(errno));
+		free(lc->disk_buffer);
+		dm_free(lc->sync_bits);
+		dm_free(lc->clean_bits);
+		dm_free(lc);
 	}
 	return r;
 }
@@ -634,9 +631,9 @@
 		close(lc->disk_fd);
 	if (lc->disk_buffer)
 		free(lc->disk_buffer);
-	free(lc->clean_bits);
-	free(lc->sync_bits);
-	free(lc);
+	dm_free(lc->clean_bits);
+	dm_free(lc->sync_bits);
+	dm_free(lc);
 
 	return 0;
 }


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

* LVM2 ./WHATS_NEW daemons/cmirrord/functions.c
@ 2010-08-30 18:37 jbrassow
  0 siblings, 0 replies; 8+ messages in thread
From: jbrassow @ 2010-08-30 18:37 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2010-08-30 18:37:42

Modified files:
	.              : WHATS_NEW 
	daemons/cmirrord: functions.c 

Log message:
	This patch fixes an issue where cluster mirror write I/O
	can be opprobriously slow if created with '--nosync'.
	
	One of the ways cluster mirrors coordinate I/O and recovery
	amoung the different machines is by the use of the log
	function 'is_remote_recovering()' which lets nodes know if
	a region they wish to perform a write on is currently being
	recovered on another node.  If the region is being recovered,
	the I/O is delayed.
	
	The 'is_remote_recovering' routine has been optimized to
	avoid the deluge of requests that would be issued to the
	userspace log server by maintaining a marker of how far
	the recovery has gotten.  It can then immediately return
	'not recovering' if the region being inquired about is
	less than this mark.  Additionally, if the region of
	concern is greater than the mark, the function will
	limit the number of transmissions to userspace by assuming
	the region /is/ being recovered when skipping the
	transmission.  This limits the amount of processing
	and updates the mark in 1/4 sec time steps.
	
	This patch fixes a problem where 'the mark' is not being
	updated because of faulty logic in the userspace log
	daemon.  When '--nosync' is used to create a cluster
	mirror, the userspace log daemon never has a chance
	to update the mark in the normal way.  The fix is to set
	the mark to "complete" if the mirror was created with
	the --nosync flag.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1726&r2=1.1727
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/cmirrord/functions.c.diff?cvsroot=lvm2&r1=1.23&r2=1.24

--- LVM2/WHATS_NEW	2010/08/26 16:29:12	1.1726
+++ LVM2/WHATS_NEW	2010/08/30 18:37:42	1.1727
@@ -1,5 +1,6 @@
 Version 2.02.74 - 
 ==================================
+  Fix opprobriously slow I/O to cluster mirrors created with --nosync.
   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)
--- LVM2/daemons/cmirrord/functions.c	2010/08/17 23:56:24	1.23
+++ LVM2/daemons/cmirrord/functions.c	2010/08/30 18:37:42	1.24
@@ -1268,6 +1268,7 @@
 		LOG_SPRINT(lc, "GET - SEQ#=%u, UUID=%s, nodeid = %u:: "
 			   "Resync work complete.",
 			   rq->seq, SHORT_UUID(lc->uuid), originator);
+		lc->sync_search = lc->region_count + 1;
 		return 0;
 	}
 


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

* LVM2 ./WHATS_NEW daemons/cmirrord/functions.c
@ 2010-08-17 23:56 jbrassow
  0 siblings, 0 replies; 8+ messages in thread
From: jbrassow @ 2010-08-17 23:56 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2010-08-17 23:56:24

Modified files:
	.              : WHATS_NEW 
	daemons/cmirrord: functions.c 

Log message:
	Fix for bug 596453: multiple mirror image failures cause lvm repair...
	
	The lvm repair issues I believe are the superficial symptoms of this
	bug - there are worse issues that are not as clearly seen.  From my
	inline comments:
	* If the mirror was successfully recovered, we want to always
	* force every machine to write to all devices - otherwise,
	* corruption will occur.  Here's how:
	*    Node1 suffers a failure and marks a region out-of-sync
	*    Node2 attempts a write, gets by is_remote_recovering,
	*          and queries the sync status of the region - finding
	*          it out-of-sync.
	*    Node2 thinks the write should be a nosync write, but it
	*          hasn't suffered the drive failure that Node1 has yet.
	*          It then issues a generic_make_request directly to
	*          the primary image only - which is exactly the device
	*          that has suffered the failure.
	*    Node2 suffers a lost write - which completely bypasses the
	*          mirror layer because it had gone through generic_m_r.
	*    The file system will likely explode at this point due to
	*    I/O errors.  If it wasn't the primary that failed, it is
	*    easily possible in this case to issue writes to just one
	*    of the remaining images - also leaving the mirror inconsistent.
	*
	* We let in_sync() return 1 in a cluster regardless of what is
	* in the bitmap once recovery has successfully completed on a
	* mirror.  This ensures the mirroring code will continue to
	* attempt to write to all mirror images.  The worst that can
	* happen for reads is that additional read attempts may be
	* taken.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1709&r2=1.1710
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/cmirrord/functions.c.diff?cvsroot=lvm2&r1=1.22&r2=1.23

--- LVM2/WHATS_NEW	2010/08/17 19:25:05	1.1709
+++ LVM2/WHATS_NEW	2010/08/17 23:56:23	1.1710
@@ -1,5 +1,6 @@
 Version 2.02.73 - 
 ================================
+  Fix potential for corruption during cluster mirror device failure.
   Use 'SINGLENODE' instead of 'dead' in clvmd singlenode messages.
   Ignore snapshots when performing mirror recovery beneath an origin.
   Pass LCK_ORIGIN_ONLY flag around cluster.
--- LVM2/daemons/cmirrord/functions.c	2010/08/04 18:18:18	1.22
+++ LVM2/daemons/cmirrord/functions.c	2010/08/17 23:56:24	1.23
@@ -54,6 +54,7 @@
 
 	time_t delay; /* limits how fast a resume can happen after suspend */
 	int touched;
+	int in_sync;  /* An in-sync that stays set until suspend/resume */
 	uint32_t region_size;
 	uint32_t region_count;
 	uint64_t sync_count;
@@ -720,6 +721,7 @@
 	if (!lc)
 		return -EINVAL;
 
+	lc->in_sync = 0;
 	switch (lc->resume_override) {
 	case 1000:
 		LOG_ERROR("[%s] Additional resume issued before suspend",
@@ -963,6 +965,42 @@
 		return -EINVAL;
 
 	*rtn = log_test_bit(lc->sync_bits, region);
+
+	/*
+	 * If the mirror was successfully recovered, we want to always
+	 * force every machine to write to all devices - otherwise,
+	 * corruption will occur.  Here's how:
+	 *    Node1 suffers a failure and marks a region out-of-sync
+	 *    Node2 attempts a write, gets by is_remote_recovering,
+   	 *          and queries the sync status of the region - finding
+	 *	    it out-of-sync.
+	 *    Node2 thinks the write should be a nosync write, but it
+	 *          hasn't suffered the drive failure that Node1 has yet.
+	 *          It then issues a generic_make_request directly to
+	 *          the primary image only - which is exactly the device
+	 *          that has suffered the failure.
+	 *    Node2 suffers a lost write - which completely bypasses the
+	 *          mirror layer because it had gone through generic_m_r.
+	 *    The file system will likely explode at this point due to
+	 *    I/O errors.  If it wasn't the primary that failed, it is
+	 *    easily possible in this case to issue writes to just one
+	 *    of the remaining images - also leaving the mirror inconsistent.
+	 *
+	 * We let in_sync() return 1 in a cluster regardless of what is
+	 * in the bitmap once recovery has successfully completed on a
+	 * mirror.  This ensures the mirroring code will continue to
+	 * attempt to write to all mirror images.  The worst that can
+	 * happen for reads is that additional read attempts may be
+	 * taken.
+	 *
+	 * Futher investigation may be required to determine if there are
+	 * similar possible outcomes when the mirror is in the process of
+	 * recovering.  In that case, lc->in_sync would not have been set
+	 * yet.
+	 */
+	if (!*rtn && lc->in_sync)
+		*rtn = 1;
+
 	if (*rtn)
 		LOG_DBG("[%s] Region is in-sync: %llu",
 			SHORT_UUID(lc->uuid), (unsigned long long)region);
@@ -1282,7 +1320,7 @@
 				lc->skip_bit_warning = lc->region_count;
 
 			if (pkg->region > (lc->skip_bit_warning + 5)) {
-				LOG_ERROR("*** Region #%llu skipped during recovery ***",
+				LOG_SPRINT(lc, "*** Region #%llu skipped during recovery ***",
 					  (unsigned long long)lc->skip_bit_warning);
 				lc->skip_bit_warning = lc->region_count;
 #ifdef DEBUG
@@ -1324,6 +1362,9 @@
 			   "(lc->sync_count > lc->region_count) - this is bad",
 			   rq->seq, SHORT_UUID(lc->uuid), originator);
 
+	if (lc->sync_count == lc->region_count)
+		lc->in_sync = 1;
+
 	rq->data_size = 0;
 	return 0;
 }


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

* LVM2 ./WHATS_NEW daemons/cmirrord/functions.c
@ 2010-08-04 18:18 jbrassow
  0 siblings, 0 replies; 8+ messages in thread
From: jbrassow @ 2010-08-04 18:18 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2010-08-04 18:18:18

Modified files:
	.              : WHATS_NEW 
	daemons/cmirrord: functions.c 

Log message:
	A misunderstanding of the return value of 'dm_bit' has been causing a data
	corruption bug in cmirror.  'dm_bit' is only ever used as a boolean operation
	within LVM, but it can return a range of values.  If the bit is set, a power of
	2 is returned.  If the bit is unset, 0 is returned.
	
	'log_test_bit' (a function in the cluster mirror log daemon code) has switched
	to using the dm bit operations in rhel6.  There are two places in the daemon
	code where 'log_test_bit' is not used merely as a boolean, but rather the
	return value is used as the return value for the log functions 'is_clean' and
	'in_sync' - having assumed that 'dm_bit' was returning 0 or 1 only.
	
	One place the 'in_sync' function is utilized is in 'dm_rh_get_state' - a
	function that informs the mirroring code how to treat I/O and which devices to
	read/write from.  'dm_rh_get_state' was checking if the return value of
	'in_sync' was 1 to determine if the region was DM_RH_CLEAN.  Since 'dm_bit'
	(and by extension 'log_test_bit' and 'in_sync') was returning powers of 2,
	DM_RH_CLEAN was rarely being reported as it should have been.  Thinking the
	region was out-of-sync, the mirroring code would write only to the primary
	device.  When the primary device was failed, all of those writes were lost -
	leaving the entire mirror corrupted.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1695&r2=1.1696
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/cmirrord/functions.c.diff?cvsroot=lvm2&r1=1.21&r2=1.22

--- LVM2/WHATS_NEW	2010/08/03 20:22:31	1.1695
+++ LVM2/WHATS_NEW	2010/08/04 18:18:18	1.1696
@@ -1,5 +1,6 @@
 Version 2.02.73 - 
 ================================
+  Fix data corruption bug in cluster mirrors.
   Require logical volume(s) to be explicitly named for lvconvert --merge.
   Avoid changing aligned pe_start as a side-effect of very verbose logging.
   Fix 'void*' arithmetic warnings in dbg_malloc.c.
--- LVM2/daemons/cmirrord/functions.c	2010/07/09 15:34:41	1.21
+++ LVM2/daemons/cmirrord/functions.c	2010/08/04 18:18:18	1.22
@@ -106,7 +106,7 @@
 
 static int log_test_bit(dm_bitset_t bs, int bit)
 {
-	return dm_bit(bs, bit);
+	return dm_bit(bs, bit) ? 1 : 0;
 }
 
 static void log_set_bit(struct log_c *lc, dm_bitset_t bs, int bit)


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

* LVM2 ./WHATS_NEW daemons/cmirrord/functions.c
@ 2010-06-18 20:58 jbrassow
  0 siblings, 0 replies; 8+ messages in thread
From: jbrassow @ 2010-06-18 20:58 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2010-06-18 20:58:04

Modified files:
	.              : WHATS_NEW 
	daemons/cmirrord: functions.c 

Log message:
	daemons/cmirrord/functions.c (part of cmirrord) was referencing
	linux/kdev_t.h even though it wasn't needed.  Strangely, it seems
	to be causing problems on various architectures (i686) in the
	function daemons/cmirrord/functions.c:disk_status_info()->sprintf.
	
	I'm not sure why this is a problem since none of the macros in
	kdev_t.h are used in that code, but it certainly doesn't hurt to
	pull an unnecessary header and it seems to fix the problem.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1618&r2=1.1619
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/cmirrord/functions.c.diff?cvsroot=lvm2&r1=1.18&r2=1.19

--- LVM2/WHATS_NEW	2010/06/18 10:19:29	1.1618
+++ LVM2/WHATS_NEW	2010/06/18 20:58:04	1.1619
@@ -1,5 +1,6 @@
 Version 2.02.68 -
 ===============================
+  Unneeded kdev_t.h reference causing harm for cmirrord on some archs.
   Add man pages for lvmconf and unsupported lvmsadc and lvmsar tools.
   Fix exit code when requesting help using documented -o help option.
   Do not use internal DLM lock definitions in generic LVM2 clvmd code.
--- LVM2/daemons/cmirrord/functions.c	2010/01/22 00:43:28	1.18
+++ LVM2/daemons/cmirrord/functions.c	2010/06/18 20:58:04	1.19
@@ -15,7 +15,6 @@
 #include <dirent.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <linux/kdev_t.h>
 #include <signal.h>
 #include <sys/stat.h>
 #include <time.h>


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

* LVM2 ./WHATS_NEW daemons/cmirrord/functions.c
@ 2010-01-15 18:48 jbrassow
  0 siblings, 0 replies; 8+ messages in thread
From: jbrassow @ 2010-01-15 18:48 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2010-01-15 18:48:24

Modified files:
	.              : WHATS_NEW 
	daemons/cmirrord: functions.c 

Log message:
	When moving the cluster log server into the LVM tree, the in memory
	bitmap tracking was switched from the e2fsprogs implementation to
	the device-mapper implementation (dm_bitset_t).  The latter has a
	leading uin32_t field designed to hold the number of bits that are
	being tracked.  The code was not properly handling this change in
	all places.  Specifically, when getting the bitmap to/from disk.
	
	Endian adjustments will likely need to be made on the accounting
	field as well, since bitmaps are passed between machines on
	start-up.
	
	Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1390&r2=1.1391
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/cmirrord/functions.c.diff?cvsroot=lvm2&r1=1.10&r2=1.11

--- LVM2/WHATS_NEW	2010/01/15 16:35:26	1.1390
+++ LVM2/WHATS_NEW	2010/01/15 18:48:24	1.1391
@@ -1,5 +1,6 @@
 Version 2.02.59 - 
 ===================================
+  Fix cluster log issues with in-memory bitmaps.
   Improve target type compatibility checking in _percent_run().
   Add 'target_status_compatible' method to 'struct segtype_handler'.
   Fix difference between CTR table built and expected for cluster log.
--- LVM2/daemons/cmirrord/functions.c	2010/01/15 16:03:19	1.10
+++ LVM2/daemons/cmirrord/functions.c	2010/01/15 18:48:24	1.11
@@ -134,11 +134,11 @@
 
 static int find_next_zero_bit(dm_bitset_t bs, int start)
 {
-	while (dm_bit(bs, start++))
-		if (start >= (int)bs[0])
+	for (; dm_bit(bs, start); start++)
+		if (start >= *bs)
 			return -1;
 
-	return start - 1;
+	return start;
 }
 
 static uint64_t count_bits32(dm_bitset_t bs)
@@ -260,7 +260,9 @@
 	/* Read disk bits into sync_bits */
 	bitset_size = lc->region_count / 8;
 	bitset_size += (lc->region_count % 8) ? 1 : 0;
-	memcpy(lc->clean_bits, lc->disk_buffer + 1024, bitset_size);
+
+	/* 'lc->clean_bits + 1' becasue dm_bitset_t leads with a uint32_t */
+	memcpy(lc->clean_bits + 1, lc->disk_buffer + 1024, bitset_size);
 
 	return 0;
 }
@@ -285,7 +287,9 @@
 	/* Write disk bits from clean_bits */
 	bitset_size = lc->region_count / 8;
 	bitset_size += (lc->region_count % 8) ? 1 : 0;
-	memcpy(lc->disk_buffer + 1024, lc->clean_bits, bitset_size);
+
+	/* 'lc->clean_bits + 1' becasue dm_bitset_t leads with a uint32_t */
+	memcpy(lc->disk_buffer + 1024, lc->clean_bits + 1, bitset_size);
 
 	if (rw_log(lc, 1)) {
 		lc->log_dev_failed = 1;
@@ -477,10 +481,11 @@
 		dm_bit_set_all(lc->sync_bits);
 
 	lc->sync_count = (sync == NOSYNC) ? region_count : 0;
+
 	if (disk_log) {
 		page_size = sysconf(_SC_PAGESIZE);
-		pages = ((int)lc->clean_bits[0])/page_size;
-		pages += ((int)lc->clean_bits[0])%page_size ? 1 : 0;
+		pages = *(lc->clean_bits) / page_size;
+		pages += *(lc->clean_bits) % page_size ? 1 : 0;
 		pages += 1; /* for header */
 
 		r = open(disk_path, O_RDWR | O_DIRECT);
@@ -1639,10 +1644,14 @@
 	return 0;
 }
 
-static void print_bits(char *buf, int size, int print)
+static void print_bits(dm_bitset_t bs, int print)
 {
-	int i;
+	int i, size;
 	char outbuf[128];
+	unsigned char *buf = bs + 1;
+
+	size = (*bs % 8) ? 1 : 0;
+	size += (*bs / 8);
 
 	memset(outbuf, 0, sizeof(outbuf));
 
@@ -1700,7 +1709,7 @@
 	}
 
 	/* Size in 'int's */
-	bitset_size = ((int)lc->clean_bits[0]/DM_BITS_PER_INT) + 1;
+	bitset_size = (*(lc->clean_bits) / DM_BITS_PER_INT) + 1;
 
 	/* Size in bytes */
 	bitset_size *= 4;
@@ -1714,14 +1723,18 @@
 
 	if (!strncmp(which, "sync_bits", 9)) {
 		memcpy(*buf, lc->sync_bits + 1, bitset_size);
+
 		LOG_DBG("[%s] storing sync_bits (sync_count = %llu):",
 			SHORT_UUID(uuid), (unsigned long long)
 			count_bits32(lc->sync_bits));
-		print_bits(*buf, bitset_size, 0);
+
+		print_bits(lc->sync_bits, 0);
 	} else if (!strncmp(which, "clean_bits", 9)) {
 		memcpy(*buf, lc->clean_bits + 1, bitset_size);
+
 		LOG_DBG("[%s] storing clean_bits:", SHORT_UUID(lc->uuid));
-		print_bits(*buf, bitset_size, 0);
+
+		print_bits(lc->clean_bits, 0);
 	}
 
 	return bitset_size;
@@ -1754,7 +1767,7 @@
 	}
 
 	/* Size in 'int's */
-	bitset_size = ((int)lc->clean_bits[0]/DM_BITS_PER_INT) + 1;
+	bitset_size = (*(lc->clean_bits) /DM_BITS_PER_INT) + 1;
 
 	/* Size in bytes */
 	bitset_size *= 4;
@@ -1768,15 +1781,19 @@
 	if (!strncmp(which, "sync_bits", 9)) {
 		lc->resume_override += 1;
 		memcpy(lc->sync_bits + 1, buf, bitset_size);
+
 		LOG_DBG("[%s] loading sync_bits (sync_count = %llu):",
 			SHORT_UUID(lc->uuid),(unsigned long long)
 			count_bits32(lc->sync_bits));
-		print_bits((char *)lc->sync_bits, bitset_size, 0);
+
+		print_bits(lc->sync_bits, 0);
 	} else if (!strncmp(which, "clean_bits", 9)) {
 		lc->resume_override += 2;
 		memcpy(lc->clean_bits + 1, buf, bitset_size);
+
 		LOG_DBG("[%s] loading clean_bits:", SHORT_UUID(lc->uuid));
-		print_bits((char *)lc->clean_bits, bitset_size, 0);
+
+		print_bits(lc->sync_bits, 0);
 	}
 
 	return 0;
@@ -1819,9 +1836,9 @@
 	dm_list_iterate_items(lc, &log_pending_list) {
 		LOG_ERROR("%s", lc->uuid);
 		LOG_ERROR("sync_bits:");
-		print_bits((char *)lc->sync_bits, (int)lc->sync_bits[0], 1);
+		print_bits(lc->sync_bits, 1);
 		LOG_ERROR("clean_bits:");
-		print_bits((char *)lc->clean_bits, (int)lc->sync_bits[0], 1);
+		print_bits(lc->clean_bits, 1);
 	}
 
 	dm_list_iterate_items(lc, &log_list) {
@@ -1832,9 +1849,9 @@
 		LOG_ERROR("  recovery_halted  : %s", (lc->recovery_halted) ?
 			  "YES" : "NO");
 		LOG_ERROR("sync_bits:");
-		print_bits((char *)lc->sync_bits, (int)lc->sync_bits[0], 1);
+		print_bits(lc->sync_bits, 1);
 		LOG_ERROR("clean_bits:");
-		print_bits((char *)lc->clean_bits, (int)lc->sync_bits[0], 1);
+		print_bits(lc->clean_bits, 1);
 
 		LOG_ERROR("Validating %s::", SHORT_UUID(lc->uuid));
 		r = find_next_zero_bit(lc->sync_bits, 0);


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

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

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-08 11:34 LVM2 ./WHATS_NEW daemons/cmirrord/functions.c zkabelac
  -- strict thread matches above, loose matches on Subject: below --
2011-09-06 18:24 zkabelac
2010-12-20 13:57 zkabelac
2010-08-30 18:37 jbrassow
2010-08-17 23:56 jbrassow
2010-08-04 18:18 jbrassow
2010-06-18 20:58 jbrassow
2010-01-15 18:48 jbrassow

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