Skip to contentSkip to conversation

LVM2 daemons/clogd/functions.c include/.symlin ...

PATCH [email protected] 1 participant 1 message Aug 13, 2009

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: jbrassow at sourceware.org 2009-08-13 16:31:02

Modified files:

	daemons/clogd  : functions.c 
	include        : .symlinks 
	libdm          : libdm-deptree.c 

Log message:
Cluster log daemon (clogd): use LVM bitops in place of ext2 bitops

Eliminate dependency on outside library, since the same functionality exists in our tree.

[It is important that the bitops work in the same way, as the bitmaps must remain backwards compatible. I haven't tested every architecture, but the x86* archs work. My test involved using the old ext2fsprogs bitops, memcpy'ing the bits over to the LVM bitset array and ensuring that only the bits set via the old methods were set.]

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clogd/functions.c.diff?cvsroot=lvm2&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/include/.symlinks.diff?cvsroot=lvm2&r1=1.59&r2=1.60
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.55&r2=1.56

daemons/clogd/functions.c +23 -26
@@ -6,13 +6,12 @@
 #include <dirent.h>
 #include <unistd.h>
 #include <signal.h>
-#include <ext2fs/ext2_fs.h>
-#include <ext2fs/ext2fs.h>
 #include <linux/kdev_t.h>
 #define __USE_GNU /* for O_DIRECT */
 #include <fcntl.h>
 #include <time.h>
-#include "linux/dm-log-userspace.h"
+#include "libdevmapper.h"
+#include "dm-log-userspace.h"
 #include "functions.h"
 #include "common.h"
 #include "cluster.h"
@@ -57,8 +56,8 @@
 	uint64_t sync_count;
 	uint32_t bitset_uint32_count;
 
-	uint32_t *clean_bits;
-	uint32_t *sync_bits;
+	dm_bitset_t clean_bits;
+	dm_bitset_t sync_bits;
 	uint32_t recoverer;
 	uint64_t recovering_region; /* -1 means not recovering */
 	uint64_t skip_bit_warning; /* used to warn if region skipped */
@@ -103,43 +102,41 @@
 static DM_LIST_INIT(log_list);
 static DM_LIST_INIT(log_pending_list);
 
-static int log_test_bit(uint32_t *bs, unsigned bit)
+static int log_test_bit(dm_bitset_t bs, int bit)
 {
-	return ext2fs_test_bit(bit, (unsigned int *) bs) ? 1 : 0;
+	return dm_bit(bs, i);
 }
 
-static void log_set_bit(struct log_c *lc, uint32_t *bs, unsigned bit)
+static void log_set_bit(struct log_c *lc, dm_bitset_t bs, int bit)
 {
-	ext2fs_set_bit(bit, (unsigned int *) bs);
+	dm_bit_set(bs, i);
 	lc->touched = 1;
 }
 
-static void log_clear_bit(struct log_c *lc, uint32_t *bs, unsigned bit)
+static void log_clear_bit(struct log_c *lc, dm_bitset_t bs, int bit)
 {
-	ext2fs_clear_bit(bit, (unsigned int *) bs);
+	dm_bit_clear(bs, i);
 	lc->touched = 1;
 }
 
-/* FIXME: Why aren't count and start the same type? */
-static uint64_t find_next_zero_bit(uint32_t *bits, uint32_t count, int start)
+static int find_next_zero_bit(dm_bitset_t bs, int start)
 {
-	for(; (start < count) && log_test_bit(bits, start); start++);
-	return start;
+	while (dm_bit(bs, start++))
+		if (start >= (int)bs[0])
+			return -1;
+
+	return start - 1;
 }
 
-static uint64_t count_bits32(uint32_t *addr, uint32_t count)
+static uint64_t count_bits32(dm_bitset_t bs)
 {
-	int j;
-	uint32_t i;
-	uint64_t rtn = 0;
+	int i, size = ((int)bs[0]/DM_BITS_PER_INT + 1);
+	unsigned count = 0;
 
-	for (i = 0; i < count; i++) {
-		if (!addr[i])
-			continue;
-		for (j = 0; j < 32; j++)
-			rtn += (addr[i] & (1<<j)) ? 1 : 0;
-	}
-	return rtn;
+	for (i = 1; i <= size; i++)
+		count += hweight32(bs[i]);
+
+	return (uint64_t)count;
 }
 
 /*
include/.symlinks +1 -0
@@ -55,6 +55,7 @@
 ../libdm/libdevmapper.h
 ../libdm/misc/dm-ioctl.h
 ../libdm/misc/dm-logging.h
+../libdm/misc/dm-log-userspace.h
 ../libdm/misc/dmlib.h
 ../libdm/misc/kdev_t.h
 ../po/pogen.h
libdm/libdm-deptree.c +120 -41

198 lines not on this page · raw message