[Ocfs2-commits] zab commits r1982 - in branches/usysfsify/fs: ocfs2/cluster usysfs

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Tue Mar 15 23:50:01 CST 2005


Author: zab
Date: 2005-03-15 23:49:59 -0600 (Tue, 15 Mar 2005)
New Revision: 1982

Modified:
   branches/usysfsify/fs/ocfs2/cluster/heartbeat.c
   branches/usysfsify/fs/ocfs2/cluster/heartbeat.h
   branches/usysfsify/fs/ocfs2/cluster/nodemanager.c
   branches/usysfsify/fs/ocfs2/cluster/nodemanager.h
   branches/usysfsify/fs/usysfs/mount.c
   branches/usysfsify/fs/usysfs/usysfs.h
Log:
o move to uksets in nodemanager; get it building


Modified: branches/usysfsify/fs/ocfs2/cluster/heartbeat.c
===================================================================
--- branches/usysfsify/fs/ocfs2/cluster/heartbeat.c	2005-03-16 04:38:57 UTC (rev 1981)
+++ branches/usysfsify/fs/ocfs2/cluster/heartbeat.c	2005-03-16 05:49:59 UTC (rev 1982)
@@ -61,6 +61,7 @@
 #include <linux/file.h>
 #include <linux/bitops.h>
 #include <linux/kthread.h>
+#include "usysfs.h"
 
 #include <asm/uaccess.h>
 
@@ -832,7 +833,6 @@
 					   const char *page,
 					   size_t count)
 {
-	struct nm_cluster *cluster = to_nm_cluster(node->nd_kobj.parent);
 	unsigned long long tmp;
 	char *p = (char *)page;
 
@@ -854,7 +854,6 @@
 					   const char *page,
 					   size_t count)
 {
-	struct nm_cluster *cluster = to_nm_cluster(node->nd_kobj.parent);
 	unsigned long long tmp;
 	char *p = (char *)page;
 
@@ -876,7 +875,6 @@
 					   const char *page,
 					   size_t count)
 {
-	struct nm_cluster *cluster = to_nm_cluster(node->nd_kobj.parent);
 	unsigned long long tmp;
 	char *p = (char *)page;
 
@@ -963,11 +961,16 @@
 
 /* heartbeat set */
 
+struct hb_heartbeat_set {
+	struct ukset hs_ukset;
+	/* some stuff? */
 };
 
 static struct hb_heartbeat_set *to_hb_heartbeat_set(struct kset *kset)
 {
-	return kset ? container_of(kset, struct hb_heartbeat_set, hs_kset) : NULL;
+	return kset ?
+		container_of(to_ukset(kset), struct hb_heartbeat_set, hs_ukset)
+		: NULL;
 }
 
 static struct kobject *hb_heartbeat_set_make_object(struct kset *kset,
@@ -1004,7 +1007,7 @@
 	kobject_put(kobj);
 }
 
-static struct ukobj_type hb_heartbeat_set_type = {
+struct ukobj_type hb_heartbeat_set_type = {
 	.ktype = {
 		.sysfs_ops	= NULL, /* no attributes */
 	},
@@ -1013,16 +1016,34 @@
 	.owner		= THIS_MODULE,
 };
 
-struct hb_heartbeat_set hb_heartbeat_set = {
-	.hs_kset = {
-		.kobj = {
-			.name = "heartbeat",
-			.ktype = &hb_heartbeat_set_type.ktype,
-		},
-	},
-};
+/* this is just here to avoid touching ukset in heartbeat.h which the
+ * entire damn world #includes */
+struct kset *hb_alloc_hb_set(void)
+{
+	struct hb_heartbeat_set *hs = NULL;
+	struct kset *ret = NULL;
 
+	hs = kcalloc(1, sizeof(struct hb_heartbeat_set), GFP_KERNEL);
+	if (hs == NULL)
+		goto out;
 
+	ukset_init_type_name(&hs->hs_ukset, "heartbeat",
+			     &hb_heartbeat_set_type.ktype);
+
+	ret = &hs->hs_ukset.kset;
+out:
+	if (ret == NULL)
+		kfree(hs);
+	return ret;
+}
+
+void *hb_free_hb_set(struct kset *kset)
+{
+	struct hb_heartbeat_set *hs = to_hb_heartbeat_set(kset);
+	kfree(hs);
+}
+
+
 /* hb callback registration and issueing */
 
 static struct hb_callback *hbcall_from_type(int type)

Modified: branches/usysfsify/fs/ocfs2/cluster/heartbeat.h
===================================================================
--- branches/usysfsify/fs/ocfs2/cluster/heartbeat.h	2005-03-16 04:38:57 UTC (rev 1981)
+++ branches/usysfsify/fs/ocfs2/cluster/heartbeat.h	2005-03-16 05:49:59 UTC (rev 1982)
@@ -71,11 +71,8 @@
 #define HB_DISK_MARGIN             30
 #define HB_NET_MARGIN              30
 
-struct hb_heartbeat_set {
-	struct kset hs_kset;
-	/* some stuff? */
-};
-extern struct hb_heartbeat_set hb_heartbeat_set;
+struct kset *hb_alloc_hb_set(void);
+void hb_free_hb_set(struct kset *kset);
 
 void hb_setup_callback(struct hb_callback_func *hc, int type, hb_cb_func *func,
 		      void *data, int priority);

Modified: branches/usysfsify/fs/ocfs2/cluster/nodemanager.c
===================================================================
--- branches/usysfsify/fs/ocfs2/cluster/nodemanager.c	2005-03-16 04:38:57 UTC (rev 1981)
+++ branches/usysfsify/fs/ocfs2/cluster/nodemanager.c	2005-03-16 05:49:59 UTC (rev 1982)
@@ -76,11 +76,9 @@
 static DECLARE_MUTEX(nm_cb_sem);
 struct list_head nm_callbacks[NM_NUM_CB];
 
-static int nm_create_cluster(char *buf);
 int nm_create_node(char *buf, nm_op *data);
 int nm_name_cluster(char *buf, nm_op *data);
 int nm_get_node_info(char *buf, nm_op *data);
-static void nm_do_callbacks(int type, void *ptr1, void *ptr2, u8 idx);
 
 #define nmprintk(x, arg...)    printk("(nm:%d) " x, current->pid, ##arg)
 #define nmprintk0(x)           printk("(nm:%d) " x, current->pid)
@@ -89,6 +87,13 @@
 #define nmprintk0(x)
 #endif
 
+struct nm_cluster {
+	struct ukset	cl_ukset;
+	char		cl_name[NM_MAX_NAME_LEN+1];
+	spinlock_t	cl_bitmap_lock;
+	unsigned long	cl_node_bitmap[BITS_TO_LONGS(NM_MAX_NODES)];
+};
+
 static int nm_find_next_slot(spinlock_t *lock, void *bitmap, int max,
 			     int request)
 {
@@ -234,6 +239,7 @@
 }
 EXPORT_SYMBOL(nm_unregister_callback);
 
+#if 0
 static void nm_do_callbacks(int type, void *ptr1, void *ptr2, u8 idx)
 {
 	struct list_head *iter;
@@ -246,12 +252,16 @@
 	}
 	up(&nm_cb_sem);
 }
+#endif
 
 /* node usysfs bits */
 
 static struct nm_cluster *to_nm_cluster(struct kobject *kobj)
 {
-	return kobj ? container_of(kobj, struct nm_cluster, cl_kobj) : NULL;
+	return kobj ?
+		container_of(to_ukset(to_kset(kobj)), struct nm_cluster,
+			     cl_ukset)
+		: NULL;
 }
 
 static struct nm_node *to_nm_node(struct kobject *kobj)
@@ -419,19 +429,22 @@
 		.sysfs_ops	= &nm_node_sysfs_ops,
 		.default_attrs	= nm_node_default_attrs,
 	},
+	.make_object = usysfs_make_no_object,
 	.owner	= THIS_MODULE,
 };
 
 /* node set */
 
 struct nm_node_set {
-	struct kset ns_kset;
+	struct ukset ns_ukset;
 	/* some stuff? */
 };
 
 static struct nm_node_set *to_nm_node_set(struct kset *kset)
 {
-	return kset ? container_of(kset, struct nm_node_set, ns_kset) : NULL;
+	return kset ? 
+		container_of(to_ukset(kset), struct nm_node_set, ns_ukset) 
+		: NULL;
 }
 
 
@@ -506,18 +519,8 @@
 	.owner		= THIS_MODULE,
 };
 
-static struct nm_node_set nm_node_set = {
-	.ns_kset = {
-		.kobj = {
-			.name = "cluster",
-			.ktype = &nm_node_set_type.ktype,
-		},
-	},
-};
-
 /* cluster */
 
-
 static void nm_cluster_release(struct kobject *kobj)
 {
 	struct nm_cluster *cluster = to_nm_cluster(kobj);
@@ -529,52 +532,69 @@
 		.release	= nm_cluster_release,
 		.sysfs_ops	= NULL, /* no attributes */
 	},
+	.make_object = usysfs_make_no_object,
 	.owner	= THIS_MODULE,
 };
 
 /* cluster set */
 
 struct nm_cluster_set {
-	struct kset cs_kset;
+	struct ukset cs_ukset;
 	/* some stuff? */
 };
 
 static struct nm_cluster_set *to_nm_cluster_set(struct kset *kset)
 {
-	return kset ? container_of(kset, struct nm_cluster_set, cs_kset) : NULL;
+	return kset ?
+		container_of(to_ukset(kset), struct nm_cluster_set, cs_ukset)
+	       : NULL;
 }
 
-static struct kset *nm_cluster_default_sets[] = {
-	&nm_node_set,
-	&nm_heartbeat_set,
-	NULL,
-};
-
-static struct kobject *nm_cluster_set_make_object(struct kset *kset,
-					      const char *name)
+static struct kset *nm_cluster_set_make_kset(struct kset *kset,
+					     const char *name)
 {
-	struct nm_cluster *cluster;
+	struct nm_cluster *cluster = NULL;
+	struct nm_node_set *ns = NULL;
+	struct kset *hb_kset = NULL, *ret = NULL;
+	void *defs = NULL;
 
 	printk("trying to make a cluster object\n");
 
 	cluster = kcalloc(1, sizeof(struct nm_cluster), GFP_KERNEL);
-	if (!cluster)
-		return NULL;
+	ns = kcalloc(1, sizeof(struct nm_node_set), GFP_KERNEL);
+	defs = kcalloc(3, sizeof(struct kset *), GFP_KERNEL);
+	hb_kset = hb_alloc_hb_set();
+	if (cluster == NULL || ns == NULL || hb_kset == NULL || defs == NULL)
+		goto out;
 
-	spin_lock_init(&cluster->bitmap_lock);
+	ukset_init_type_name(&cluster->cl_ukset, name, &nm_cluster_type.ktype);
+	ukset_init_type_name(&ns->ns_ukset, "node", &nm_node_set_type.ktype);
 
-	kobject_set_name(&cluster->cl_kobj, name);
-	cluster->cl_kobj.ktype = &nm_cluster_type.ktype;
-	kobject_init(&cluster->cl_kobj);
+	spin_lock_init(&cluster->cl_bitmap_lock);
+	cluster->cl_ukset.default_sets = defs;
+	cluster->cl_ukset.default_sets[0] = &ns->ns_ukset.kset;
+	cluster->cl_ukset.default_sets[1] = hb_kset;
+	cluster->cl_ukset.default_sets[2] = NULL;
 
-	return &cluster->kobj;
+	ret = &cluster->cl_ukset.kset;
+
+out:
+	if (ret == NULL) {
+		kfree(cluster);
+		kfree(ns);
+		hb_free_hb_set(hb_kset);
+		kfree(defs);
+	}
+
+	return ret;
 }
 
 static void nm_cluster_set_drop_object(struct kset *kset, struct kobject *kobj)
 {
 	struct nm_cluster_set *cs = to_nm_cluster_set(kset);
 
-	printk("dropping nm_cluster_set %p\n", cs);
+	printk("dropping cluster obj set %p from nm_cluster_set %p\n",
+	       kset, cs);
 	kobject_put(kobj);
 }
 
@@ -582,17 +602,18 @@
 	.ktype = {
 		.sysfs_ops	= NULL, /* no attributes */
 	},
-	.make_object	= nm_cluster_set_make_object,
+	.make_kset	= nm_cluster_set_make_kset,
 	.drop_object	= nm_cluster_set_drop_object,
-	.default_sets	= nm_cluster_default_sets,
 	.owner	= THIS_MODULE,
 };
 
 static struct nm_cluster_set nm_cluster_set = {
-	.cs_kset = {
-		.kobj = {
-			.name = "cluster",
-			.ktype = &nm_cluster_set_type.ktype,
+	.cs_ukset = {
+		.kset = {
+			.kobj = {
+				.name = "cluster",
+				.ktype = &nm_cluster_set_type.ktype,
+			},
 		},
 	},
 };
@@ -600,16 +621,9 @@
 static void __exit exit_nm(void)
 {
 	nmprintk("unloading nm module\n");
-	usysfs_unregister_subsystem(&nm_cluster_set.cs_kset);
-	nm_destroy_ip_hash();
+	usysfs_unregister_subsystem(&nm_cluster_set.cs_ukset.kset);
 }
 
-static void kset_init(struct kset *k)
-{
-	kobject_init(&k->kobj);
-	INIT_LIST_HEAD(&k->list);
-}
-
 static int __init init_nm(void)
 {
 	int ret;
@@ -618,22 +632,13 @@
 	for (i = 0; i <= ARRAY_SIZE(nm_callbacks); i++)
 		INIT_LIST_HEAD(&nm_callbacks[i]);
 
-	kset_init(&nm_cluster_set.cs_kset);
-	kset_init(&nm_node_set.ns_kset);
-	kset_init(&hb_heartbeat_set.hs_kset);
-	ret = usysfs_register_subsystem(&nm_cluster_set.cs_kset);
+	ukset_init(&nm_cluster_set.cs_ukset);
+	ret = usysfs_register_subsystem(&nm_cluster_set.cs_ukset.kset);
 	if (ret) {
 		printk(KERN_ERR "nodemanager: Registration returned %d\n", ret);
 		goto out;
 	}
 
-	ret = nm_init_ip_hash();
-	if (ret) {
-		printk(KERN_ERR "nodemanager: IP hash initialization "
-			"returned %d\n", ret);
-		goto out;
-	}
-
 out:
 	if (ret)
 		exit_nm();

Modified: branches/usysfsify/fs/ocfs2/cluster/nodemanager.h
===================================================================
--- branches/usysfsify/fs/ocfs2/cluster/nodemanager.h	2005-03-16 04:38:57 UTC (rev 1981)
+++ branches/usysfsify/fs/ocfs2/cluster/nodemanager.h	2005-03-16 05:49:59 UTC (rev 1982)
@@ -32,12 +32,6 @@
 
 #include "ocfs2_nodemanager.h"
 
-struct nm_cluster {
-	struct kobject	cl_kobj;
-	char		cl_name[NM_MAX_NAME_LEN+1];
-	spinlock_t	cl_bitmap_lock;
-	unsigned long	cl_node_bitmap[BITS_TO_LONGS(NM_MAX_NODES)];
-};
 
 /* TODO: move this */
 struct sock;

Modified: branches/usysfsify/fs/usysfs/mount.c
===================================================================
--- branches/usysfsify/fs/usysfs/mount.c	2005-03-16 04:38:57 UTC (rev 1981)
+++ branches/usysfsify/fs/usysfs/mount.c	2005-03-16 05:49:59 UTC (rev 1982)
@@ -67,6 +67,14 @@
 	kset_init_copy(&ukset->kset);
 }
 
+void ukset_init_type_name(struct ukset *ukset, const char *name,
+			  struct ktype *ktype)
+{
+	kobject_set_name(&ukset->kobj, name);
+	ukset->kset.kobj.ktype = ktype;
+	ukset_init(ukset);
+}
+
 EXPORT_SYMBOL_GPL(ukset_init);
 
 static int usysfs_fill_super(struct super_block *sb, void *data, int silent)

Modified: branches/usysfsify/fs/usysfs/usysfs.h
===================================================================
--- branches/usysfsify/fs/usysfs/usysfs.h	2005-03-16 04:38:57 UTC (rev 1981)
+++ branches/usysfsify/fs/usysfs/usysfs.h	2005-03-16 05:49:59 UTC (rev 1982)
@@ -85,7 +85,9 @@
 	return kset ? container_of(kset, struct ukset, kset) : NULL;
 }
 
-extern void ukset_init(struct ukset *ukset);
+void ukset_init(struct ukset *ukset);
+void ukset_init_type_name(struct ukset *ukset, const char *name,
+			  struct kobj_type *ktype);
 
 
 /**



More information about the Ocfs2-commits mailing list