cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] cluster/group/gfs_controld lock_dlm.h main.c p ...
@ 2006-11-21 17:28 teigland
  0 siblings, 0 replies; 4+ messages in thread
From: teigland @ 2006-11-21 17:28 UTC (permalink / raw)
  To: cluster-devel.redhat.com

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;



^ permalink raw reply	[flat|nested] 4+ messages in thread
* [Cluster-devel] cluster/group/gfs_controld lock_dlm.h main.c p ...
@ 2006-11-21 17:28 teigland
  0 siblings, 0 replies; 4+ messages in thread
From: teigland @ 2006-11-21 17:28 UTC (permalink / raw)
  To: cluster-devel.redhat.com

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

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&only_with_tag=RHEL50&r1=1.21.4.1&r2=1.21.4.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/gfs_controld/main.c.diff?cvsroot=cluster&only_with_tag=RHEL50&r1=1.18.4.2&r2=1.18.4.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/gfs_controld/plock.c.diff?cvsroot=cluster&only_with_tag=RHEL50&r1=1.25.4.4&r2=1.25.4.5

--- cluster/group/gfs_controld/lock_dlm.h	2006/11/20 21:10:36	1.21.4.1
+++ cluster/group/gfs_controld/lock_dlm.h	2006/11/21 17:28:52	1.21.4.2
@@ -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:44:15	1.18.4.2
+++ cluster/group/gfs_controld/main.c	2006/11/21 17:28:52	1.18.4.3
@@ -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:29:50	1.25.4.4
+++ cluster/group/gfs_controld/plock.c	2006/11/21 17:28:52	1.25.4.5
@@ -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;



^ permalink raw reply	[flat|nested] 4+ messages in thread
* [Cluster-devel] cluster/group/gfs_controld lock_dlm.h main.c p ...
@ 2006-11-21 17:28 teigland
  0 siblings, 0 replies; 4+ messages in thread
From: teigland @ 2006-11-21 17:28 UTC (permalink / raw)
  To: cluster-devel.redhat.com

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

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&only_with_tag=RHEL5&r1=1.21.2.1&r2=1.21.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/gfs_controld/main.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.18.2.3&r2=1.18.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/gfs_controld/plock.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.25.2.4&r2=1.25.2.5

--- cluster/group/gfs_controld/lock_dlm.h	2006/11/20 21:10:28	1.21.2.1
+++ cluster/group/gfs_controld/lock_dlm.h	2006/11/21 17:28:45	1.21.2.2
@@ -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:44:02	1.18.2.3
+++ cluster/group/gfs_controld/main.c	2006/11/21 17:28:45	1.18.2.4
@@ -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:29:40	1.25.2.4
+++ cluster/group/gfs_controld/plock.c	2006/11/21 17:28:46	1.25.2.5
@@ -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;



^ permalink raw reply	[flat|nested] 4+ messages in thread
* [Cluster-devel] cluster/group/gfs_controld lock_dlm.h main.c p ...
@ 2006-08-31 19:13 teigland
  0 siblings, 0 replies; 4+ messages in thread
From: teigland @ 2006-08-31 19:13 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	teigland at sourceware.org	2006-08-31 19:13:02

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

Log message:
	convert write(2) calls to use do_write() which handles EINTR and
	short writes

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/gfs_controld/lock_dlm.h.diff?cvsroot=cluster&r1=1.16&r2=1.17
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/gfs_controld/main.c.diff?cvsroot=cluster&r1=1.12&r2=1.13
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/gfs_controld/plock.c.diff?cvsroot=cluster&r1=1.19&r2=1.20

--- cluster/group/gfs_controld/lock_dlm.h	2006/08/21 17:46:19	1.16
+++ cluster/group/gfs_controld/lock_dlm.h	2006/08/31 19:13:02	1.17
@@ -243,6 +243,7 @@
 	char buf[0];
 };
 
+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/08/31 18:46:24	1.12
+++ cluster/group/gfs_controld/main.c	2006/08/31 19:13:02	1.13
@@ -35,6 +35,28 @@
 extern struct list_head withdrawn_mounts;
 int no_withdraw;
 
+
+int do_write(int fd, void *buf, size_t count)
+{
+	int rv, off = 0;
+
+ retry:
+	rv = write(fd, buf + off, count);
+	if (rv == -1 && errno == EINTR)
+		goto retry;
+	if (rv < 0) {
+		log_error("write errno %d", errno);
+		return rv;
+	}
+
+	if (rv != count) {
+		count -= rv;
+		off += rv;
+		goto retry;
+	}
+	return 0;
+}
+
 #if 0
 static void make_args(char *buf, int *argc, char **argv, char sep)
 {
@@ -134,24 +156,20 @@
 
 int client_send(int ci, char *buf, int len)
 {
-	return write(client[ci].fd, buf, len);
+	return do_write(client[ci].fd, buf, len);
 }
 
 static int dump_debug(int ci)
 {
-	int rv, len;
+	int len;
 
 	if (dump_wrap) {
 		len = DUMP_SIZE - dump_point;
-		rv = write(client[ci].fd, dump_buf + dump_point, len);
-		if (rv != len)
-			log_debug("write error %d errno %d", rv, errno);
+		do_write(client[ci].fd, dump_buf + dump_point, len);
 	}
 	len = dump_point;
 
-	rv = write(client[ci].fd, dump_buf, len);
-	if (rv != len)
-		log_debug("write error %d errno %d", rv, errno);
+	do_write(client[ci].fd, dump_buf, len);
 	return 0;
 }
 
--- cluster/group/gfs_controld/plock.c	2006/08/21 17:46:19	1.19
+++ cluster/group/gfs_controld/plock.c	2006/08/31 19:13:02	1.20
@@ -1451,7 +1451,7 @@
 			      po->start, po->end,
 			      po->nodeid, po->pid, po->owner);
 
-			rv = write(fd, line, strlen(line));
+			rv = do_write(fd, line, strlen(line));
 		}
 
 		list_for_each_entry(w, &r->waiters, list) {
@@ -1462,7 +1462,7 @@
 			      w->info.start, w->info.end,
 			      w->info.nodeid, w->info.pid, w->info.owner);
 
-			rv = write(fd, line, strlen(line));
+			rv = do_write(fd, line, strlen(line));
 		}
 	}
 



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

end of thread, other threads:[~2006-11-21 17:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-21 17:28 [Cluster-devel] cluster/group/gfs_controld lock_dlm.h main.c p teigland
  -- strict thread matches above, loose matches on Subject: below --
2006-11-21 17:28 teigland
2006-11-21 17:28 teigland
2006-08-31 19:13 teigland

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 NNTP newsgroup(s).