[Cluster-devel] cluster/group/gfs_controld lock_dlm.h main.c p ...

teigland at sourceware.org teigland at sourceware.org
Tue Nov 21 17:28:10 UTC 2006


CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	teigland at sourceware.org	2006-11-21 17:28:09

Modified files:
	group/gfs_controld: lock_dlm.h main.c plock.c 

Log message:
	handle errors or short reads when reading /dev/misc/lock_dlm_plock

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/gfs_controld/lock_dlm.h.diff?cvsroot=cluster&r1=1.22&r2=1.23
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/gfs_controld/main.c.diff?cvsroot=cluster&r1=1.21&r2=1.22
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/gfs_controld/plock.c.diff?cvsroot=cluster&r1=1.29&r2=1.30

--- cluster/group/gfs_controld/lock_dlm.h	2006/11/20 21:07:18	1.22
+++ cluster/group/gfs_controld/lock_dlm.h	2006/11/21 17:28:08	1.23
@@ -253,6 +253,7 @@
 	char buf[0];
 };
 
+int do_read(int fd, void *buf, size_t count);
 int do_write(int fd, void *buf, size_t count);
 struct mountgroup *find_mg(char *name);
 struct mountgroup *find_mg_id(uint32_t id);
--- cluster/group/gfs_controld/main.c	2006/11/15 14:32:01	1.21
+++ cluster/group/gfs_controld/main.c	2006/11/21 17:28:09	1.22
@@ -42,6 +42,22 @@
 int no_plock;
 uint32_t plock_rate_limit = DEFAULT_PLOCK_RATE_LIMIT;
 
+int do_read(int fd, void *buf, size_t count)
+{
+	int rv, off = 0;
+
+	while (off < count) {
+		rv = read(fd, buf + off, count - off);
+		if (rv == 0)
+			return -1;
+		if (rv == -1 && errno == EINTR)
+			continue;
+		if (rv == -1)
+			return -1;
+		off += rv;
+	}
+	return 0;
+}
 
 int do_write(int fd, void *buf, size_t count)
 {
@@ -597,7 +613,7 @@
 	printf("  -P	       Enable plock debugging\n");
 	printf("  -p	       Disable plocks\n");
 	printf("  -l <limit>   Limit the rate of plock operations\n");
-	printf("               Default is %d, set to 0 for no limit\n", DEFAULT_PLOCK_RATE_LIMIT);
+	printf("	       Default is %d, set to 0 for no limit\n", DEFAULT_PLOCK_RATE_LIMIT);
 	printf("  -w	       Disable withdraw\n");
 	printf("  -h	       Print this help, then exit\n");
 	printf("  -V	       Print program version information, then exit\n");
--- cluster/group/gfs_controld/plock.c	2006/11/20 21:28:53	1.29
+++ cluster/group/gfs_controld/plock.c	2006/11/21 17:28:09	1.30
@@ -350,7 +350,12 @@
 
 	memset(&info, 0, sizeof(info));
 
-	rv = read(control_fd, &info, sizeof(info));
+	rv = do_read(control_fd, &info, sizeof(info));
+	if (rv < 0) {
+		log_debug("process_plocks: read error %d fd %d\n",
+			  errno, control_fd);
+		return 0;
+	}
 
 	if (!plocks_online) {
 		rv = -ENOSYS;




More information about the Cluster-devel mailing list