[Cluster-devel] cluster/gfs2/mount mount.gfs2.c util.c util.h

teigland at sourceware.org teigland at sourceware.org
Fri Oct 13 20:01:19 UTC 2006


CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	teigland at sourceware.org	2006-10-13 20:01:19

Modified files:
	gfs2/mount     : mount.gfs2.c util.c util.h 

Log message:
	The corresponding changes to the gfs_controld changes in handling
	mixed mounts and recoveries and failed mounts.  We now tell
	gfs_controld when our mount has completed and the result using the
	same connection that we created when requesting the mount.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/mount/mount.gfs2.c.diff?cvsroot=cluster&r1=1.17&r2=1.18
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/mount/util.c.diff?cvsroot=cluster&r1=1.13&r2=1.14
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/mount/util.h.diff?cvsroot=cluster&r1=1.9&r2=1.10

--- cluster/gfs2/mount/mount.gfs2.c	2006/08/11 16:59:03	1.17
+++ cluster/gfs2/mount/mount.gfs2.c	2006/10/13 20:01:19	1.18
@@ -130,6 +130,13 @@
 	return rv;
 }
 
+static void mount_result_lockproto(char *proto, struct mount_options *mo,
+			     	    struct gen_sb *sb, int result)
+{
+	if (!strcmp(proto, "lock_dlm"))
+		lock_dlm_mount_result(mo, sb, result);
+}
+
 static void umount_lockproto(char *proto, struct mount_options *mo,
 			     struct gen_sb *sb, int mnterr)
 {
@@ -175,14 +182,16 @@
 	rv = mount(mo.dev, mo.dir, fsname, mo.flags, mo.extra_plus);
 	if (rv) {
 		log_debug("mount(2) failed error %d errno %d", rv, errno);
+		mount_result_lockproto(proto, &mo, &sb, rv);
+
 		if (!(mo.flags & MS_REMOUNT))
 			umount_lockproto(proto, &mo, &sb, errno);
 
 		block_signals(SIG_UNBLOCK);
-
 		die("error %d mounting %s on %s\n", errno, mo.dev, mo.dir);
 	}
 	log_debug("mount(2) ok");
+	mount_result_lockproto(proto, &mo, &sb, 0);
 
 	block_signals(SIG_UNBLOCK);
 
--- cluster/gfs2/mount/util.c	2006/08/14 17:22:53	1.13
+++ cluster/gfs2/mount/util.c	2006/10/13 20:01:19	1.14
@@ -11,7 +11,7 @@
 extern char *prog_name;
 extern char *fsname;
 extern int verbose;
-static int mount_error_fd;
+static int gfs_controld_fd;
 
 #define LOCK_DLM_SOCK_PATH "gfs_controld_sock"	/* FIXME: use a header */
 #define MAXLINE 256			/* size of messages with gfs_controld */
@@ -311,6 +311,7 @@
 	return fd;
 }
 
+#if 0
 /* We create a pipe and pass the receiving end to gfs_controld.  If the
    mount fails, we write an error message to this pipe.  gfs_controld monitors
    this fd outside its main poll loop because it may need to detect a mount
@@ -361,6 +362,7 @@
 
 	log_debug("setup_mount_error_fd %d %d", fds[0], fds[1]);
 }
+#endif
 
 int lock_dlm_join(struct mount_options *mo, struct gen_sb *sb)
 {
@@ -370,10 +372,11 @@
 
 	i = 0;
 	do {
-		sleep(1);
 		fd = gfs_controld_connect();
-		if (fd < 0)
+		if (fd < 0) {
 			warn("waiting for gfs_controld to start");
+			sleep(1);
+		}
 	} while (fd < 0 && ++i < 10);
 
 	/* FIXME: should we start the daemon here? */
@@ -415,7 +418,9 @@
 		goto out;
 	}
 
+#if 0
 	setup_mount_error_fd(fd);
+#endif
 
 	/*
 	 * read response from gfs_controld to our join request:
@@ -491,10 +496,38 @@
 	log_debug("lock_dlm_join: extra_plus: \"%s\"", mo->extra_plus);
 	rv = 0;
  out:
+#if 0
 	close(fd);
+#endif
+	gfs_controld_fd = fd;
 	return rv;
 }
 
+void lock_dlm_mount_result(struct mount_options *mo, struct gen_sb *sb,
+			   int result)
+{
+	int rv;
+	char buf[MAXLINE];
+
+	memset(buf, 0, sizeof(buf));
+	rv = snprintf(buf, MAXLINE, "mount_result %s %s %d", mo->dir, fsname,
+		      result);
+	if (rv >= MAXLINE) {
+		warn("lock_dlm_mount_result: message too long: %d \"%s\"\n",
+		     rv, buf);
+		goto out;
+	}
+
+	log_debug("lock_dlm_mount_result: write \"%s\"", buf);
+
+	rv = write(gfs_controld_fd, buf, sizeof(buf));
+	if (rv < 0) {
+		warn("lock_dlm_mount_result: gfs_controld write error: %d", rv);
+	}
+ out:
+	close(gfs_controld_fd);
+}
+
 int lock_dlm_leave(struct mount_options *mo, struct gen_sb *sb, int mnterr)
 {
 	int i, fd, rv;
@@ -502,13 +535,14 @@
 
 	i = 0;
 	do {
-		sleep(1);
 		fd = gfs_controld_connect();
-		if (!fd)
+		if (fd < 0) {
 			warn("waiting for gfs_controld to start");
+			sleep(1);
+		}
 	} while (!fd && ++i < 10);
 
-	if (!fd) {
+	if (fd < 0) {
 		warn("gfs_controld not running");
 		rv = -1;
 		goto out;
@@ -535,10 +569,12 @@
 	log_debug("message to gfs_controld: asking to leave mountgroup:");
 	log_debug("lock_dlm_leave: write \"%s\"", buf);
 
+#if 0
 	if (mnterr && mount_error_fd) {
 		rv = write(mount_error_fd, buf, sizeof(buf));
 		log_debug("lock_dlm_leave: write to mount_error_fd %d", rv);
 	}
+#endif
 
 	rv = write(fd, buf, sizeof(buf));
 	if (rv < 0) {
--- cluster/gfs2/mount/util.h	2006/07/20 20:19:04	1.9
+++ cluster/gfs2/mount/util.h	2006/10/13 20:01:19	1.10
@@ -87,6 +87,7 @@
 void read_proc_mounts(struct mount_options *mo);
 int get_sb(char *device, struct gen_sb *sb_out);
 int lock_dlm_join(struct mount_options *mo, struct gen_sb *sb);
+void lock_dlm_mount_result(struct mount_options *mo, struct gen_sb *sb, int result);
 int lock_dlm_leave(struct mount_options *mo, struct gen_sb *sb, int mnterr);
 int lock_dlm_remount(struct mount_options *mo, struct gen_sb *sb);
 




More information about the Cluster-devel mailing list