[Ocfs2-commits] jlbec commits r1739 - branches/kabi/cluster

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Tue Jan 4 20:44:23 CST 2005


Author: jlbec
Date: 2005-01-04 20:44:21 -0600 (Tue, 04 Jan 2005)
New Revision: 1739

Added:
   branches/kabi/cluster/o2cb_kabi.h
Modified:
   branches/kabi/cluster/Makefile
   branches/kabi/cluster/nodemanager.c
   branches/kabi/cluster/nodemanager.h
   branches/kabi/cluster/util.c
   branches/kabi/cluster/util.h
Log:

o Commit first pass ABI stuff.



Modified: branches/kabi/cluster/Makefile
===================================================================
--- branches/kabi/cluster/Makefile	2005-01-05 02:41:55 UTC (rev 1738)
+++ branches/kabi/cluster/Makefile	2005-01-05 02:44:21 UTC (rev 1739)
@@ -33,7 +33,7 @@
 GLOBAL_DEFINES += -DHAVE_NPTL
 endif
 
-CFILES = \
+CFILES = 		\
 	compat_libfs.c	\
 	dlmmaster.c	\
 	dlmmod.c	\
@@ -45,16 +45,20 @@
 	util.c		\
 	test.c			
 
-HFILES = \
-	compat_libfs.h	\
-	dlm_compat.h	\
-	dlmcommon.h	\
-	dlmmod.h	\
-	heartbeat.h	\
-	nodemanager.h	\
-	tcp.h		\
-	util.h		\
-	warning_hack.h
+HFILES = 			\
+	compat_libfs.h		\
+	dlm_compat.h		\
+	dlmcommon.h		\
+	dlmmod.h		\
+	heartbeat.h		\
+	nodemanager.h		\
+	tcp.h			\
+	util.h			\
+	warning_hack.h		\
+	o2cb_kabi.h		\
+	ocfs2_nodemanager.h	\
+	ocfs2_heartbeat.h	\
+	ocfs2_tcp.h
 
 CLEAN_RULES = clean-cluster
 

Modified: branches/kabi/cluster/nodemanager.c
===================================================================
--- branches/kabi/cluster/nodemanager.c	2005-01-05 02:41:55 UTC (rev 1738)
+++ branches/kabi/cluster/nodemanager.c	2005-01-05 02:44:21 UTC (rev 1739)
@@ -68,6 +68,7 @@
 
 #include <asm/uaccess.h>
 
+#include "o2cb_kabi.h"
 #include "tcp.h"
 #include "dlmmod.h"
 #include "nodemanager.h"
@@ -149,7 +150,7 @@
 
 
 static void nm_teardown(void);
-static int nm_create_cluster(char *buf);
+static int nm_create_cluster(void);
 static void nm_init_cluster(nm_cluster *cluster);
 int nm_create_node(char *buf, nm_op *data);
 int nm_name_cluster(char *buf, nm_op *data);
@@ -176,6 +177,7 @@
 static ssize_t write_node(struct file *file, char *buf, size_t size);
 static ssize_t write_group(struct file *file, char *buf, size_t size);
 static ssize_t write_cluster(struct file *file, char *buf, size_t size);
+static ssize_t write_live(struct file *file, char *buf, size_t size);
 
 static struct inode * __nm_get_group_by_num(u16 group_num);
 static struct inode * __nm_get_node_by_num(u16 node_num);
@@ -342,18 +344,16 @@
 /* cluster, node and group transaction files. 
  * here's where the actual work of nm takes place. */
 
-static int nm_create_cluster(char *buf)
+static int nm_create_cluster(void)
 {
-	int ret = -EINVAL;
+	int ret = O2CB_KE_CLUSTER_ALREADY_LIVE;
 	
 	nmprintk("create cluster...\n");
 	
 	spin_lock(&nm_lock);
-	if (cluster.state == NM_CLUSTER_UP) {
-		ret = sprintf(buf, "%d: cluster already up\n", -EINVAL);
-	} else {
+	if (cluster.state != NM_CLUSTER_UP) {
 		cluster.state = NM_CLUSTER_UP;
-		ret = sprintf(buf, "0: cluster state: UP");
+		ret = 0;
 	}
 	spin_unlock(&nm_lock);
 	return ret;
@@ -883,9 +883,6 @@
 		return -EINVAL;
 
 	switch (data->opcode) {
-		case NM_OP_CREATE_CLUSTER:
-			ret = nm_create_cluster(buf);
-			break;
 		case NM_OP_CREATE_GROUP:
 			ret = nm_create_group(buf, data);
 			break;
@@ -972,8 +969,41 @@
 	return ret;
 }
 
+static ssize_t write_live(struct file *file, char *buf, size_t size)
+{
+	int ret;
+	struct o2cb_kabi_live *kl = (struct o2cb_kabi_live *)buf;
 
+	ret = o2cb_kabi_verify(kl, kl_abi, size);
+	if (ret)
+		return ret;
+	if (kl->kl_abi.ki_status)
+		return size;
 
+	switch (kl->kl_abi.ki_op)
+	{
+		case O2CB_OP_CLUSTER_SET_LIVE:
+			ret = O2CB_KE_NOT_SUPPORTED;
+			if (kl->kl_live)
+				ret = nm_create_cluster();
+			else
+				printk("Teardown of cluster not supported\n");
+			break;
+
+		case O2CB_OP_CLUSTER_IS_LIVE:
+			kl->kl_live = (cluster.state == NM_CLUSTER_UP);
+			break;
+
+		default:
+			ret = O2CB_KE_INVALID_OPERATION;
+			break;
+	}
+
+	kl->kl_abi.ki_status = ret;
+	return size;
+}
+
+
 static struct inode * __nm_get_group_by_num(u16 group_num)
 {
 	struct inode *inode = iget(single_sb, group_num + NM_GROUP_INODE_START);
@@ -1277,6 +1307,7 @@
 		[NM_Cluster] = {".cluster", &transaction_ops, S_IWUSR},
 		[NM_Node] = {".node", &transaction_ops, S_IWUSR},
 		[NM_Group] = {".group", &transaction_ops, S_IWUSR},
+		[NM_Live] = {".live", &transaction_ops, S_IWUSR},
 		/* last one */ {""}
 	};
 	
@@ -1290,6 +1321,7 @@
 	ops->write_op[NM_Cluster] = write_cluster;
 	ops->write_op[NM_Node] = write_node;
 	ops->write_op[NM_Group] = write_group;
+	ops->write_op[NM_Live] = write_live;
 
 	single_sb = NULL;
 	nmprintk("calling simple_fill_super...\n");

Modified: branches/kabi/cluster/nodemanager.h
===================================================================
--- branches/kabi/cluster/nodemanager.h	2005-01-05 02:41:55 UTC (rev 1738)
+++ branches/kabi/cluster/nodemanager.h	2005-01-05 02:44:21 UTC (rev 1739)
@@ -47,11 +47,12 @@
 	NM_GROUP_READY
 };
 
-enum {
+enum nm_fs_ino {
 	NM_Root = 1,
 	NM_Cluster,
 	NM_Node,
 	NM_Group,
+	NM_Live,
 };
 
 typedef struct _nm_cluster

Added: branches/kabi/cluster/o2cb_kabi.h
===================================================================
--- branches/kabi/cluster/o2cb_kabi.h	2005-01-05 02:41:55 UTC (rev 1738)
+++ branches/kabi/cluster/o2cb_kabi.h	2005-01-05 02:44:21 UTC (rev 1739)
@@ -0,0 +1,131 @@
+/* -*- mode: c; c-basic-offset: 8; -*-
+ * vim: noexpandtab sw=8 ts=8 sts=0:
+ *
+ * o2cb_kabi.h
+ *
+ * Header describing the generic interface bits between userspace and 
+ * he kernel for the O2CB stuff.
+ *
+ * Copyright (C) 2004 Oracle.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2
+ * of the License.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 021110-1307, USA.
+ */
+
+#ifndef _O2CB_KABI_H
+#define _O2CB_KABI_H
+
+#define O2CB_KABI_V1		1U
+#define O2CB_KABI_VERSION	O2CB_KABI_V1
+#define O2CB_KABI_MAGIC		0x02CBCA75
+
+enum o2cb_kabi_operations
+{
+	O2CB_OP_NONE = 0,
+	O2CB_OP_CLUSTER_SET_LIVE,
+	O2CB_OP_CLUSTER_IS_LIVE,
+};
+
+enum o2cb_kabi_errors
+{
+	O2CB_KE_NONE = 0,
+	O2CB_KE_BAD_MAGIC,
+	O2CB_KE_INVALID_ABI_VERSION,
+	O2CB_KE_INVALID_REQUEST_SIZE,
+	O2CB_KE_INVALID_OPERATION,
+	O2CB_KE_CLUSTER_ALREADY_LIVE,
+	O2CB_KE_NOT_SUPPORTED,
+};
+
+struct o2cb_kabi_info {
+/*00*/	__u32	ki_magic;	/* O2CB_KABI_MAGIC */
+	__u16	ki_version;	/* ABI version */
+	__u16	ki_op;		/* Operation */
+	__u32	ki_size;	/* Size of passed structure */
+	__u32   ki_status;      /* Returns status code */
+/*10*/
+};
+
+struct o2cb_kabi_live {
+/*00*/	struct o2cb_kabi_info	kl_abi;
+/*10*/	__u32			kl_live;	/* 0 is DOWN */
+/*14*/
+};
+
+/**
+ * o2cb_kabi_verify(k, member, size)
+ * @k:		An O2CB KABI object embedding a struct o2cb_kabi_info.
+ * @member:	The name of the struct o2cb_kabi_info member.
+ * @size:	The expected size passed in to ->write().
+ *
+ * For example, if you had:
+ *
+ * struct o2cb_kabi_start_cluster {
+ * 	struct o2cb_kabi_info	sc_abi;
+ * 	__u32			sc_start;
+ * };
+ *
+ * You would verify this structure with:
+ *
+ * struct o2cb_kabi_start_cluster *sc;
+ * o2cb_kabi_verify(sc, sc_abi, size);
+ *
+ * Along with verifying the magic value in ki_magic and the ABI version
+ * in ki_version, this function verifies that
+ * ki_size == size == sizeof(*k).  Make sure that 'size' is the size
+ * passed to ->write().  If you simply use sizeof(*k), you aren't
+ * getting anything from that verification step.
+ *
+ * If 'size' is bad, -EINVAL is returned.  Otherwise, the caller
+ * must check ki_status for any ABI errors.
+ */
+#define o2cb_kabi_verify(k, member, size) ({ \
+	typeof(k) _k = (k);					\
+	struct o2cb_kabi_info *_i = &(_k->member);		\
+	int _rc = 						\
+	(_i->ki_size != (size)) ? -EINVAL :			\
+	((_i->ki_magic != O2CB_KABI_MAGIC) ?			\
+	 O2CB_KE_BAD_MAGIC :					\
+	 ((_i->ki_version != O2CB_KABI_VERSION) ?		\
+	  O2CB_KE_INVALID_ABI_VERSION :				\
+	  ((_i->ki_size != sizeof(typeof(*_k))) ?		\
+	   O2CB_KE_INVALID_REQUEST_SIZE : 0)));			\
+	if (_rc != -EINVAL) {					\
+		_i->ki_status = _rc;				\
+		_rc = 0;					\
+	}							\
+	_rc;							\
+})
+
+/**
+ * o2cb_kabi_verify(k, member, size)
+ * @k:		An O2CB KABI object embedding a struct o2cb_kabi_info.
+ * @member:	The name of the struct o2cb_kabi_info member.
+ * @op:		The ABI operation.
+ *
+ * Fills the struct o2cb_kabi_info part of the structure with the
+ * appropriate magic numbers and sizes.
+ */
+#define o2cb_kabi_init(k, member, op) ({ \
+	typeof(k) _k = (k);				\
+	struct o2cb_kabi_info *_i = &(_k->member);	\
+	_i->ki_magic = O2CB_KABI_MAGIC;			\
+	_i->ki_version = O2CB_KABI_VERSION;		\
+	_i->ki_op = (op);				\
+	_i->ki_size = sizeof(typeof(*_k));		\
+	_i->ki_status = 0;				\
+})
+
+#endif  /* _O2CB_KABI_H */

Modified: branches/kabi/cluster/util.c
===================================================================
--- branches/kabi/cluster/util.c	2005-01-05 02:41:55 UTC (rev 1738)
+++ branches/kabi/cluster/util.c	2005-01-05 02:44:21 UTC (rev 1739)
@@ -35,6 +35,7 @@
 #include <linux/slab.h>
 
 #include "util.h"
+#include "ocfs2_nodemanager.h"
 
 static void util_timeout_func(unsigned long data);
 

Modified: branches/kabi/cluster/util.h
===================================================================
--- branches/kabi/cluster/util.h	2005-01-05 02:41:55 UTC (rev 1738)
+++ branches/kabi/cluster/util.h	2005-01-05 02:44:21 UTC (rev 1739)
@@ -28,7 +28,6 @@
 #ifndef CLUSTER_UTIL_H
 #define CLUSTER_UTIL_H
 
-#ifdef __KERNEL__
 #define SHUTDOWN_SIGS   (sigmask(SIGKILL) | sigmask(SIGHUP) | \
 			 sigmask(SIGINT) | sigmask(SIGQUIT))
 
@@ -59,7 +58,6 @@
 	return ret;
 }
 
-#endif  /* __KERNEL__ */
 
 /* resizable array */
 typedef struct _util_rarray
@@ -85,7 +83,6 @@
 void * util_rarray_idx_to_slot(util_rarray *arr, int idx);
 int util_resize_rarray(util_rarray *arr, int newelem);
 
-#ifdef __KERNEL__
 typedef struct _util_thread_info
 {
 	wait_queue_head_t thread_wq;
@@ -104,6 +101,8 @@
 	info->pid = -1;
 	init_completion(&info->complete);
 }
-#endif /* __KERNEL__ */
 
+struct o2cb_abi_response;
+void o2cb_abi_response_fill(struct o2cb_abi_response *response, int status);
+int o2cb_abi_response_printf(struct o2cb_abi_response *response, int status, const char *s, ...);
 #endif /* CLUSTER_UTIL_H */



More information about the Ocfs2-commits mailing list