public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/daemons/cmirrord functions.c
@ 2010-10-26 10:14 zkabelac
  0 siblings, 0 replies; 7+ messages in thread
From: zkabelac @ 2010-10-26 10:14 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-10-26 10:14:41

Modified files:
	daemons/cmirrord: functions.c 

Log message:
	Add missing return for NULL passed buffer
	
	Function pull_stateo() checks for NULL 'buf' - but return for this error
	path was missing.  cmirror code never calls this function with NULL 'buf',
	so this fix has no effect on current code base, but makes clang happier.

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

--- LVM2/daemons/cmirrord/functions.c	2010/08/30 18:37:42	1.24
+++ LVM2/daemons/cmirrord/functions.c	2010/10/26 10:14:41	1.25
@@ -1809,8 +1809,10 @@
 	int bitset_size;
 	struct log_c *lc;
 
-	if (!buf)
+	if (!buf) {
 		LOG_ERROR("pull_state: buf == NULL");
+		return -EINVAL;
+	}
 
 	lc = get_log(uuid, luid);
 	if (!lc) {


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

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

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

Modified files:
	daemons/cmirrord: functions.c 

Log message:
	Removed unused pointer
	
	Pointer 'duplicate' is unused.

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

--- LVM2/daemons/cmirrord/functions.c	2010/12/20 13:57:19	1.26
+++ LVM2/daemons/cmirrord/functions.c	2010/12/20 13:58:38	1.27
@@ -366,7 +366,6 @@
 	uint64_t region_size;
 	uint64_t region_count;
 	struct log_c *lc = NULL;
-	struct log_c *duplicate;
 	enum sync log_sync = DEFAULTSYNC;
 	uint32_t block_on_error = 0;
 
@@ -448,8 +447,8 @@
 	strncpy(lc->uuid, uuid, DM_UUID_LEN);
 	lc->luid = luid;
 
-	if ((duplicate = get_log(lc->uuid, lc->luid)) ||
-	    (duplicate = get_pending_log(lc->uuid, lc->luid))) {
+	if (get_log(lc->uuid, lc->luid) ||
+	    get_pending_log(lc->uuid, lc->luid)) {
 		LOG_ERROR("[%s/%" PRIu64 "u] Log already exists, unable to create.",
 			  SHORT_UUID(lc->uuid), lc->luid);
 		dm_free(lc);


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

* LVM2/daemons/cmirrord functions.c
@ 2010-06-21 16:07 jbrassow
  0 siblings, 0 replies; 7+ messages in thread
From: jbrassow @ 2010-06-21 16:07 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2010-06-21 16:07:06

Modified files:
	daemons/cmirrord: functions.c 

Log message:
	Add error checking for calls to sprintf - it can fail for more
	reasons than just 'out-of-space'.

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

--- LVM2/daemons/cmirrord/functions.c	2010/06/18 20:58:04	1.19
+++ LVM2/daemons/cmirrord/functions.c	2010/06/21 16:07:06	1.20
@@ -1371,15 +1371,21 @@
 
 static int core_status_info(struct log_c *lc __attribute((unused)), struct dm_ulog_request *rq)
 {
+	int r;
 	char *data = (char *)rq->data;
 
-	rq->data_size = sprintf(data, "1 clustered-core");
+	r = sprintf(data, "1 clustered-core");
+	if (r < 0)
+		return r;
+
+	rq->data_size = r;
 
 	return 0;
 }
 
 static int disk_status_info(struct log_c *lc, struct dm_ulog_request *rq)
 {
+	int r;
 	char *data = (char *)rq->data;
 	struct stat statbuf;
 
@@ -1388,9 +1394,13 @@
 		return -errno;
 	}
 
-	rq->data_size = sprintf(data, "3 clustered-disk %d:%d %c",
-				major(statbuf.st_rdev), minor(statbuf.st_rdev),
-				(lc->log_dev_failed) ? 'D' : 'A');
+	r = sprintf(data, "3 clustered-disk %d:%d %c",
+		    major(statbuf.st_rdev), minor(statbuf.st_rdev),
+		    (lc->log_dev_failed) ? 'D' : 'A');
+	if (r < 0)
+		return r;
+
+	rq->data_size = r;
 
 	return 0;
 }
@@ -1421,18 +1431,24 @@
 
 static int core_status_table(struct log_c *lc, struct dm_ulog_request *rq)
 {
+	int r;
 	char *data = (char *)rq->data;
 
-	rq->data_size = sprintf(data, "clustered-core %u %s%s ",
-				lc->region_size,
-				(lc->sync == DEFAULTSYNC) ? "" :
-				(lc->sync == NOSYNC) ? "nosync " : "sync ",
-				(lc->block_on_error) ? "block_on_error" : "");
+	r = sprintf(data, "clustered-core %u %s%s ",
+		    lc->region_size,
+		    (lc->sync == DEFAULTSYNC) ? "" :
+		    (lc->sync == NOSYNC) ? "nosync " : "sync ",
+		    (lc->block_on_error) ? "block_on_error" : "");
+	if (r < 0)
+		return r;
+
+	rq->data_size = r;
 	return 0;
 }
 
 static int disk_status_table(struct log_c *lc, struct dm_ulog_request *rq)
 {
+	int r;
 	char *data = (char *)rq->data;
 	struct stat statbuf;
 
@@ -1441,12 +1457,16 @@
 		return -errno;
 	}
 
-	rq->data_size = sprintf(data, "clustered-disk %d:%d %u %s%s ",
-				major(statbuf.st_rdev), minor(statbuf.st_rdev),
-				lc->region_size,
-				(lc->sync == DEFAULTSYNC) ? "" :
-				(lc->sync == NOSYNC) ? "nosync " : "sync ",
-				(lc->block_on_error) ? "block_on_error" : "");
+	r = sprintf(data, "clustered-disk %d:%d %u %s%s ",
+		    major(statbuf.st_rdev), minor(statbuf.st_rdev),
+		    lc->region_size,
+		    (lc->sync == DEFAULTSYNC) ? "" :
+		    (lc->sync == NOSYNC) ? "nosync " : "sync ",
+		    (lc->block_on_error) ? "block_on_error" : "");
+	if (r < 0)
+		return r;
+
+	rq->data_size = r;
 	return 0;
 }
 
@@ -1555,6 +1575,11 @@
  * from this function.  However, an inability to successfully
  * perform the request will fill in the 'rq->error' field.
  *
+ * 'rq' (or more correctly, rq->u_rq.data) should be of sufficient
+ * size to hold any returning data.  Currently, local.c uses 2kiB
+ * to hold 'rq' - leaving ~1.5kiB for return data... more than
+ * enough for all the implemented functions here.
+ *
  * Returns: 0 on success, -EXXX on error
  */
 int do_request(struct clog_request *rq, int server)


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

* LVM2/daemons/cmirrord functions.c
@ 2010-01-22  0:43 agk
  0 siblings, 0 replies; 7+ messages in thread
From: agk @ 2010-01-22  0:43 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-01-22 00:43:28

Modified files:
	daemons/cmirrord: functions.c 

Log message:
	missing header

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

--- LVM2/daemons/cmirrord/functions.c	2010/01/20 02:43:19	1.17
+++ LVM2/daemons/cmirrord/functions.c	2010/01/22 00:43:28	1.18
@@ -17,6 +17,7 @@
 #include <fcntl.h>
 #include <linux/kdev_t.h>
 #include <signal.h>
+#include <sys/stat.h>
 #include <time.h>
 #include <unistd.h>
 


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

* LVM2/daemons/cmirrord functions.c
@ 2010-01-19 18:21 agk
  0 siblings, 0 replies; 7+ messages in thread
From: agk @ 2010-01-19 18:21 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-01-19 18:21:04

Modified files:
	daemons/cmirrord: functions.c 

Log message:
	Remove mknod() and add FIXMEs.
	In the udev-world, this function should work differently.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/cmirrord/functions.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16

--- LVM2/daemons/cmirrord/functions.c	2010/01/19 17:24:29	1.15
+++ LVM2/daemons/cmirrord/functions.c	2010/01/19 18:21:03	1.16
@@ -289,6 +289,7 @@
 	return 0;
 }
 
+/* FIXME Rewrite this function taking advantage of the udev changes (where in use) to improve its efficiency! */
 static int find_disk_path(char *major_minor_str, char *path_rtn, int *unlink_path)
 {
 	int r;
@@ -311,6 +312,7 @@
 	if (r != 2)
 		return -EINVAL;
 
+	/* FIXME dm_dir() */
 	LOG_DBG("Checking /dev/mapper for device %d:%d", major, minor);
 	/* Check /dev/mapper dir */
 	dp = opendir("/dev/mapper");
@@ -340,17 +342,18 @@
 
 	closedir(dp);
 
+	/* FIXME Find out why this was here and deal with underlying problem. */
 	LOG_DBG("Path not found for %d/%d", major, minor);
-	LOG_DBG("Creating /dev/mapper/%d-%d", major, minor);
-	sprintf(path_rtn, "/dev/mapper/%d-%d", major, minor);
-	r = mknod(path_rtn, S_IFBLK | S_IRUSR | S_IWUSR, MKDEV(major, minor));
+	return -ENOENT;
 
+	// LOG_DBG("Creating /dev/mapper/%d-%d", major, minor);
+	// sprintf(path_rtn, "/dev/mapper/%d-%d", major, minor);
+	// r = mknod(path_rtn, S_IFBLK | S_IRUSR | S_IWUSR, MKDEV(major, minor));
 	/*
 	 * If we have to make the path, we unlink it after we open it
 	 */
-	*unlink_path = 1;
-
-	return r ? -errno : 0;
+	// *unlink_path = 1;
+	// return r ? -errno : 0;
 }
 
 static int _clog_ctr(char *uuid, uint64_t luid,


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

* LVM2/daemons/cmirrord functions.c
@ 2010-01-19 17:24 agk
  0 siblings, 0 replies; 7+ messages in thread
From: agk @ 2010-01-19 17:24 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-01-19 17:24:30

Modified files:
	daemons/cmirrord: functions.c 

Log message:
	remove more compiler warnings
	add FIXMEs for incomplete write()s

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/cmirrord/functions.c.diff?cvsroot=lvm2&r1=1.14&r2=1.15

--- LVM2/daemons/cmirrord/functions.c	2010/01/18 21:07:24	1.14
+++ LVM2/daemons/cmirrord/functions.c	2010/01/19 17:24:29	1.15
@@ -121,18 +121,18 @@
 	lc->touched = 1;
 }
 
-static int find_next_zero_bit(dm_bitset_t bs, int start)
+static uint64_t find_next_zero_bit(dm_bitset_t bs, unsigned start)
 {
 	for (; dm_bit(bs, start); start++)
 		if (start >= *bs)
-			return -1;
+			return (uint64_t)-1;
 
 	return start;
 }
 
 static uint64_t count_bits32(dm_bitset_t bs)
 {
-	int i, size = ((int)bs[0]/DM_BITS_PER_INT + 1);
+	unsigned i, size = bs[0]/(unsigned)DM_BITS_PER_INT + 1;
 	unsigned count = 0;
 
 	for (i = 1; i <= size; i++)
@@ -192,7 +192,7 @@
 {
 	int r;
 
-	r = lseek(lc->disk_fd, 0, SEEK_SET);
+	r = (int)lseek(lc->disk_fd, 0, SEEK_SET);
 	if (r < 0) {
 		LOG_ERROR("[%s] rw_log:  lseek failure: %s",
 			  SHORT_UUID(lc->uuid), strerror(errno));
@@ -200,6 +200,7 @@
 	}
 
 	if (do_write) {
+		/* FIXME Cope with full set of non-error conditions */
 		r = write(lc->disk_fd, lc->disk_buffer, lc->disk_size);
 		if (r < 0) {
 			LOG_ERROR("[%s] rw_log:  write failure: %s",
@@ -210,6 +211,7 @@
 	}
 
 	/* Read */
+	/* FIXME Cope with full set of non-error conditions */
 	r = read(lc->disk_fd, lc->disk_buffer, lc->disk_size);
 	if (r < 0)
 		LOG_ERROR("[%s] rw_log:  read failure: %s",
@@ -1219,8 +1221,7 @@
 		}
 	}
 
-	pkg->r = find_next_zero_bit(lc->sync_bits,
-				    lc->sync_search);
+	pkg->r = find_next_zero_bit(lc->sync_bits, lc->sync_search);
 
 	if (pkg->r >= lc->region_count) {
 		LOG_SPRINT(lc, "GET - SEQ#=%u, UUID=%s, nodeid = %u:: "
@@ -1796,9 +1797,10 @@
 
 	lc = get_log(rq->uuid, rq->luid);
 	if (!lc)
+		/* FIXME Callers are ignoring this */
 		return -EINVAL;
 
-	return lc->state;
+	return (int)lc->state;
 }
 
 /*
@@ -1834,9 +1836,8 @@
 
 	dm_list_iterate_items(lc, &log_list) {
 		LOG_ERROR("%s", lc->uuid);
-		LOG_ERROR("  recoverer        : %u", lc->recoverer);
-		LOG_ERROR("  recovering_region: %llu",
-			  (unsigned long long)lc->recovering_region);
+		LOG_ERROR("  recoverer        : %" PRIu32, lc->recoverer);
+		LOG_ERROR("  recovering_region: %" PRIu64, lc->recovering_region);
 		LOG_ERROR("  recovery_halted  : %s", (lc->recovery_halted) ?
 			  "YES" : "NO");
 		LOG_ERROR("sync_bits:");
@@ -1846,12 +1847,9 @@
 
 		LOG_ERROR("Validating %s::", SHORT_UUID(lc->uuid));
 		r = find_next_zero_bit(lc->sync_bits, 0);
-		LOG_ERROR("  lc->region_count = %llu",
-			  (unsigned long long)lc->region_count);
-		LOG_ERROR("  lc->sync_count = %llu",
-			  (unsigned long long)lc->sync_count);
-		LOG_ERROR("  next zero bit  = %llu",
-			  (unsigned long long)r);
+		LOG_ERROR("  lc->region_count = %" PRIu32, lc->region_count);
+		LOG_ERROR("  lc->sync_count = %" PRIu64, lc->sync_count);
+		LOG_ERROR("  next zero bit  = %" PRIu64, r);
 		if ((r > lc->region_count) ||
 		    ((r == lc->region_count) && (lc->sync_count > lc->region_count))) {
 			LOG_ERROR("ADJUSTING SYNC_COUNT");


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2010-01-15 16:03:19

Modified files:
	daemons/cmirrord: functions.c 

Log message:
	At some point "clustered_[core|disk]" was changed to "clustered-[core|disk]".
	
	This patch makes the log server recognise the new format.
	
	Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>

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

--- LVM2/daemons/cmirrord/functions.c	2009/08/28 05:27:09	1.9
+++ LVM2/daemons/cmirrord/functions.c	2010/01/15 16:03:19	1.10
@@ -382,7 +382,7 @@
 		disk_log = 1;
 
 		if ((argc < 2) || (argc > 4)) {
-			LOG_ERROR("Too %s arguments to clustered_disk log type",
+			LOG_ERROR("Too %s arguments to clustered-disk log type",
 				  (argc < 3) ? "few" : "many");
 			r = -EINVAL;
 			goto fail;
@@ -398,7 +398,7 @@
 		disk_log = 0;
 
 		if ((argc < 1) || (argc > 3)) {
-			LOG_ERROR("Too %s arguments to clustered_core log type",
+			LOG_ERROR("Too %s arguments to clustered-core log type",
 				  (argc < 2) ? "few" : "many");
 			r = -EINVAL;
 			goto fail;
@@ -406,7 +406,7 @@
 	}
 
 	if (!(region_size = strtoll(argv[disk_log], &p, 0)) || *p) {
-		LOG_ERROR("Invalid region_size argument to clustered_%s log type",
+		LOG_ERROR("Invalid region_size argument to clustered-%s log type",
 			  (disk_log) ? "disk" : "core");
 		r = -EINVAL;
 		goto fail;
@@ -572,8 +572,8 @@
 	for (i = 0; i < argc; i++, p = p + strlen(p) + 1)
 		argv[i] = p;
 
-	if (strcmp(argv[0], "clustered_disk") &&
-	    strcmp(argv[0], "clustered_core")) {
+	if (strcmp(argv[0], "clustered-disk") &&
+	    strcmp(argv[0], "clustered-core")) {
 		LOG_ERROR("Unsupported userspace log type, \"%s\"", argv[0]);
 		free(argv);
 		return -EINVAL;
@@ -1374,7 +1374,7 @@
 {
 	char *data = (char *)rq->data;
 
-	rq->data_size = sprintf(data, "1 clustered_core");
+	rq->data_size = sprintf(data, "1 clustered-core");
 
 	return 0;
 }
@@ -1389,7 +1389,7 @@
 		return -errno;
 	}
 
-	rq->data_size = sprintf(data, "3 clustered_disk %d:%d %c",
+	rq->data_size = sprintf(data, "3 clustered-disk %d:%d %c",
 				major(statbuf.st_rdev), minor(statbuf.st_rdev),
 				(lc->log_dev_failed) ? 'D' : 'A');
 
@@ -1424,7 +1424,7 @@
 {
 	char *data = (char *)rq->data;
 
-	rq->data_size = sprintf(data, "clustered_core %u %s%s ",
+	rq->data_size = sprintf(data, "clustered-core %u %s%s ",
 				lc->region_size,
 				(lc->sync == DEFAULTSYNC) ? "" :
 				(lc->sync == NOSYNC) ? "nosync " : "sync ",
@@ -1442,7 +1442,7 @@
 		return -errno;
 	}
 
-	rq->data_size = sprintf(data, "clustered_disk %d:%d %u %s%s ",
+	rq->data_size = sprintf(data, "clustered-disk %d:%d %u %s%s ",
 				major(statbuf.st_rdev), minor(statbuf.st_rdev),
 				lc->region_size,
 				(lc->sync == DEFAULTSYNC) ? "" :


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

end of thread, other threads:[~2010-12-20 13:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-26 10:14 LVM2/daemons/cmirrord functions.c zkabelac
  -- strict thread matches above, loose matches on Subject: below --
2010-12-20 13:58 zkabelac
2010-06-21 16:07 jbrassow
2010-01-22  0:43 agk
2010-01-19 18:21 agk
2010-01-19 17:24 agk
2010-01-15 16:03 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).