This is the mail archive of the cluster-cvs@sourceware.org mailing list for the cluster.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

master - libdlm: remove device node creation/removal


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=896e77208f01a4d8d98424fa05fabd72406c0ad2
Commit:        896e77208f01a4d8d98424fa05fabd72406c0ad2
Parent:        0232430c40a2d9d19a6ea94a83b8c1046c26e983
Author:        David Teigland <teigland@redhat.com>
AuthorDate:    Fri Aug 8 11:56:57 2008 -0500
Committer:     David Teigland <teigland@redhat.com>
CommitterDate: Fri Aug 8 12:09:04 2008 -0500

libdlm: remove device node creation/removal

It's unnecessary as udev has been doing it for quite a long time.
(Doing this ourselves also won't work correctly in the future with a
pending dlm patch that will allow multiple creates and only the final
release actually releases the lockspace.)

Signed-off-by: David Teigland <teigland@redhat.com>
---
 dlm/libdlm/libdlm.c |   65 ++++----------------------------------------------
 dlm/libdlm/libdlm.h |    2 +
 2 files changed, 8 insertions(+), 59 deletions(-)

diff --git a/dlm/libdlm/libdlm.c b/dlm/libdlm/libdlm.c
index b16f54f..f88d824 100644
--- a/dlm/libdlm/libdlm.c
+++ b/dlm/libdlm/libdlm.c
@@ -1290,12 +1290,8 @@ static int create_lockspace_v6(const char *name, uint32_t flags)
 static dlm_lshandle_t create_lockspace(const char *name, mode_t mode,
 				       uint32_t flags)
 {
-	int status;
-	int minor;
-	int i;
+	int minor, i;
 	struct stat st;
-	int stat_ret;
-	int create_dev = 1;
 	char dev_name[PATH_MAX];
 	struct dlm_ls_info *newls;
 
@@ -1314,57 +1310,20 @@ static dlm_lshandle_t create_lockspace(const char *name, mode_t mode,
 	else
 		minor = create_lockspace_v6(name, flags);
 
-	if (minor < 0 && errno != EEXIST) {
+	if (minor < 0) {
 		free(newls);
 		return NULL;
 	}
 
-	/*
-	 * If the lockspace already exists, we don't get the minor
-	 * number returned, so we need to get it the hard way.
-	 */
-
-	if (minor <= 0)
-		minor = find_minor_from_proc(DLM_PREFIX,name);
-
 	/* Wait for udev to create the device */
-	for (i=1; i<10; i++) {
+	for (i = 1; i < 10; i++) {
 		if (stat(dev_name, &st) == 0)
 			break;
 		sleep(1);
 	}
 
-	/*
-	 * If the device exists we check the minor number.
-	 * If the device doesn't exist then we have to look in /proc/misc
-	 * to find the minor number.
-	 */
-	stat_ret = stat(dev_name, &st);
-
-	/* Check if the device exists and has the right modes */
-	if (!stat_ret &&
-	    S_ISCHR(st.st_mode) && st.st_rdev == makedev(MISC_MAJOR, minor)) {
-		create_dev = 0;
-	}
-
-	if (create_dev) {
-		unlink(dev_name);
-
-		/* Now try to create the device, EEXIST is OK cos it must have
-	   	  been devfs or udev that created it */
-		status = mknod(dev_name, S_IFCHR | mode,
-			       makedev(MISC_MAJOR, minor));
-		if (status == -1 && errno != EEXIST) {
-			release_lockspace(minor, 0);
-			free(newls);
-			return NULL;
-		}
-#ifdef HAVE_SELINUX
-		set_selinux_context(dev_name);
-#endif
-	}
-
 	/* Open it and return the struct as a handle */
+
 	newls->fd = open(dev_name, O_RDWR);
 	if (newls->fd == -1) {
 		int saved_errno = errno;
@@ -1423,8 +1382,6 @@ static int release_lockspace(uint32_t minor, uint32_t flags)
 
 int dlm_release_lockspace(const char *name, dlm_lshandle_t ls, int force)
 {
-	int status;
-	char dev_name[PATH_MAX];
 	struct stat st;
 	struct dlm_ls_info *lsinfo = (struct dlm_ls_info *)ls;
 	uint32_t flags = 0;
@@ -1442,17 +1399,8 @@ int dlm_release_lockspace(const char *name, dlm_lshandle_t ls, int force)
 	if (force)
 		flags = DLM_USER_LSFLG_FORCEFREE;
 
-	status = release_lockspace(minor(st.st_rdev), flags);
-
-	/* Remove the device */
-	ls_dev_name(name, dev_name, sizeof(dev_name));
-
-	status = unlink(dev_name);
-
-	/* ENOENT is OK here if devfs has cleaned up */
-	if (status == 0 || (status == -1 && errno == ENOENT))
-		return 0;
-	return -1;
+	release_lockspace(minor(st.st_rdev), flags);
+	return 0;
 }
 
 /*
@@ -1485,7 +1433,6 @@ dlm_lshandle_t dlm_open_lockspace(const char *name)
 		return NULL;
 	}
 	fcntl(newls->fd, F_SETFD, 1);
-
 	return (dlm_lshandle_t)newls;
 }
 
diff --git a/dlm/libdlm/libdlm.h b/dlm/libdlm/libdlm.h
index d77764a..c1cdf9b 100644
--- a/dlm/libdlm/libdlm.h
+++ b/dlm/libdlm/libdlm.h
@@ -35,6 +35,8 @@ struct dlm_lksb {
 /* dlm_new_lockspace flags */
 #define DLM_LSFL_NODIR          0x00000001
 #define DLM_LSFL_TIMEWARN       0x00000002
+#define DLM_LSFL_FS             0x00000004
+/* #define DLM_LSFL_NEWEXCL        0x00000008 (expected in 2.6.28-rc) */
 
 #endif
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]