[Ocfs2-commits] jlbec commits r2064 - in trunk/fs: ocfs2/cluster usysfs

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Mon Mar 28 14:16:40 CST 2005


Author: jlbec
Signed-off-by: zab
Date: 2005-03-28 14:16:38 -0600 (Mon, 28 Mar 2005)
New Revision: 2064

Modified:
   trunk/fs/ocfs2/cluster/nodemanager.c
   trunk/fs/usysfs/bobtest.c
   trunk/fs/usysfs/dir.c
   trunk/fs/usysfs/uobject.h
   trunk/fs/usysfs/usysfs.h
Log:

o Create struct usysfs_subsystem and have usysfs_register_subsystem()
  use it.
o Convert bobtest and ocfs2_nodemanager to usysfs_subsystem.

Signed-off-by: zab



Modified: trunk/fs/ocfs2/cluster/nodemanager.c
===================================================================
--- trunk/fs/ocfs2/cluster/nodemanager.c	2005-03-26 02:23:52 UTC (rev 2063)
+++ trunk/fs/ocfs2/cluster/nodemanager.c	2005-03-28 20:16:38 UTC (rev 2064)
@@ -57,6 +57,7 @@
 #include <linux/bitops.h>
 
 #include <asm/uaccess.h>
+#include <asm/semaphore.h>
 
 #include "uobject.h"
 
@@ -589,7 +590,7 @@
 /* cluster set */
 
 struct nm_cluster_set {
-	struct uset cs_uset;
+	struct usysfs_subsystem cs_subsys;
 	/* some stuff? */
 };
 
@@ -597,7 +598,7 @@
 static struct nm_cluster_set *to_nm_cluster_set(struct uset *uset)
 {
 	return uset ?
-		container_of(uset, struct nm_cluster_set, cs_uset)
+		container_of(to_usysfs_subsystem(uset), struct nm_cluster_set, cs_subsys)
 	       : NULL;
 }
 #endif
@@ -678,10 +679,12 @@
 };
 
 static struct nm_cluster_set nm_cluster_set = {
-	.cs_uset = {
-		.uobj = {
-			.name = "cluster",
-			.ktype = &nm_cluster_set_type,
+	.cs_subsys = {
+		.su_set = {
+			.uobj = {
+				.name = "cluster",
+				.ktype = &nm_cluster_set_type,
+			},
 		},
 	},
 };
@@ -691,7 +694,7 @@
 	nmprintk("unloading nm module\n");
 	/* XXX sync with hb callbacks and shut down hb? */
 	net_unregister_hb_callbacks();
-	usysfs_unregister_subsystem(&nm_cluster_set.cs_uset);
+	usysfs_unregister_subsystem(&nm_cluster_set.cs_subsys);
 }
 
 static int __init init_nm(void)
@@ -701,8 +704,9 @@
 	hb_init();
 	ret = net_register_hb_callbacks();
 	if (!ret) {
-		uset_init(&nm_cluster_set.cs_uset);
-		ret = usysfs_register_subsystem(&nm_cluster_set.cs_uset);
+		uset_init(&nm_cluster_set.cs_subsys.su_set);
+		init_MUTEX(&nm_cluster_set.cs_subsys.su_sem);
+		ret = usysfs_register_subsystem(&nm_cluster_set.cs_subsys);
 		if (ret) {
 			printk(KERN_ERR "nodemanager: Registration returned %d\n", ret);
 			net_unregister_hb_callbacks();

Modified: trunk/fs/usysfs/bobtest.c
===================================================================
--- trunk/fs/usysfs/bobtest.c	2005-03-26 02:23:52 UTC (rev 2063)
+++ trunk/fs/usysfs/bobtest.c	2005-03-28 20:16:38 UTC (rev 2064)
@@ -233,7 +233,7 @@
 
 
 struct bobset {
-	struct uset uset;
+	struct usysfs_subsystem subsys;
 	int n_bobs;
 };
 
@@ -245,7 +245,7 @@
 static inline struct bobset *to_bobset(struct uset *uset)
 {
 	return uset ?
-		container_of(uset, struct bobset, uset) :
+		container_of(to_usysfs_subsystem(uset), struct bobset, subsys) :
 		NULL;
 }
 
@@ -329,12 +329,14 @@
 };
 
 static struct bobset bobset = {
-	.uset = {
-		.uobj = {
-			.name = "bobset",
-			.ktype = &uktype_bobset,
+	.subsys = {
+		.su_set = {
+			.uobj = {
+				.name = "bobset",
+				.ktype = &uktype_bobset,
+			},
+			.default_sets = bobset_sets,
 		},
-		.default_sets = bobset_sets,
 	},
 	.n_bobs = 0,
 };
@@ -592,7 +594,7 @@
 
 
 struct tomset {
-	struct uset uset;
+	struct usysfs_subsystem subsys;
 	int n_toms;
 };
 
@@ -604,7 +606,7 @@
 static inline struct tomset *to_tomset(struct uset *uset)
 {
 	return uset ?
-		container_of(uset, struct tomset, uset) :
+		container_of(to_usysfs_subsystem(uset), struct tomset, subsys) :
 		NULL;
 }
 
@@ -709,10 +711,12 @@
 };
 
 static struct tomset tomset = {
-	.uset = {
-		.uobj = {
-			.name = "tomset",
-			.ktype = &uktype_tomset,
+	.subsys = {
+		.su_set = {
+			.uobj = {
+				.name = "tomset",
+				.ktype = &uktype_tomset,
+			},
 		},
 	},
 	.n_toms = 0,
@@ -722,12 +726,14 @@
 {
 	int ret;
 
-	uset_init(&bobset.uset);
+	uset_init(&bobset.subsys.su_set);
+	init_MUTEX(&bobset.subsys.su_sem);
 	uset_init(&robert.uset);
-	uset_init(&tomset.uset);
-	ret = usysfs_register_subsystem(&bobset.uset);
+	uset_init(&tomset.subsys.su_set);
+	init_MUTEX(&tomset.subsys.su_sem);
+	ret = usysfs_register_subsystem(&bobset.subsys);
 	if (!ret)
-		ret = usysfs_register_subsystem(&tomset.uset);
+		ret = usysfs_register_subsystem(&tomset.subsys);
 	if (ret)
 		printk(KERN_ERR "bobtest: Registration returned %d\n", ret);
 
@@ -736,8 +742,8 @@
 
 static void __exit bobtest_exit(void)
 {
-	usysfs_unregister_subsystem(&tomset.uset);
-	usysfs_unregister_subsystem(&bobset.uset);
+	usysfs_unregister_subsystem(&tomset.subsys);
+	usysfs_unregister_subsystem(&bobset.subsys);
 }
 
 module_init(bobtest_init);

Modified: trunk/fs/usysfs/dir.c
===================================================================
--- trunk/fs/usysfs/dir.c	2005-03-26 02:23:52 UTC (rev 2063)
+++ trunk/fs/usysfs/dir.c	2005-03-28 20:16:38 UTC (rev 2064)
@@ -927,9 +927,10 @@
 	.readdir	= usysfs_readdir,
 };
 
-int usysfs_register_subsystem(struct uset *k)
+int usysfs_register_subsystem(struct usysfs_subsystem *subsys)
 {
 	int err;
+	struct uset *set = &subsys->su_set;
 	struct qstr name;
 	struct dentry *dentry;
 	struct usysfs_dirent *sd;
@@ -938,13 +939,13 @@
 	if (err)
 		return err;
 
-	k->uobj.uset = k;
-	if (!k->uobj.k_name)
-		k->uobj.k_name = k->uobj.name;
+	set->uobj.uset = set;
+	if (!set->uobj.k_name)
+		set->uobj.k_name = set->uobj.name;
 
 	down(&usysfs_sb->s_root->d_inode->i_sem);
 
-	name.name = k->uobj.k_name;
+	name.name = set->uobj.k_name;
 	name.len = strlen(name.name);
 	name.hash = full_name_hash(name.name, name.len);
 
@@ -956,7 +957,7 @@
 	d_add(dentry, NULL);
 
 	sd = usysfs_sb->s_root->d_fsdata;
-	err = usysfs_instantiate_set(sd->s_element, &k->uobj, dentry);
+	err = usysfs_instantiate_set(sd->s_element, &set->uobj, dentry);
 	if (!err)
 		dentry = NULL;
 	else
@@ -973,9 +974,10 @@
 	return err;
 }
 
-void usysfs_unregister_subsystem(struct uset *k)
+void usysfs_unregister_subsystem(struct usysfs_subsystem *subsys)
 {
-	struct dentry *dentry = k->uobj.dentry;
+	struct uset *set = &subsys->su_set;
+	struct dentry *dentry = set->uobj.dentry;
 
 	if (dentry->d_parent != usysfs_sb->s_root) {
 		printk(KERN_ERR "usysfs: Tried to unregister non-subsystem!\n");
@@ -987,7 +989,7 @@
 	if (usysfs_empty_dir(dentry)) {
 		printk(KERN_ERR "usysfs: Tried to unregister non-empty subsystem!\n");
 	}
-	usysfs_drop_set(&k->uobj);
+	usysfs_drop_set(&set->uobj);
 	dentry->d_inode->i_flags |= S_DEAD;
 	up(&dentry->d_inode->i_sem);
 

Modified: trunk/fs/usysfs/uobject.h
===================================================================
--- trunk/fs/usysfs/uobject.h	2005-03-26 02:23:52 UTC (rev 2063)
+++ trunk/fs/usysfs/uobject.h	2005-03-28 20:16:38 UTC (rev 2064)
@@ -44,6 +44,7 @@
 struct usysfs_set_operations;
 struct usysfs_attribute;
 struct usysfs_attribute_operations;
+struct usysfs_subsystem;
 
 struct uobject {
 	char			*k_name;
@@ -86,6 +87,7 @@
 struct uset {
 	struct uobject		uobj;
 	struct list_head	list;
+	struct usysfs_subsystem *subsys;
 	struct uset		**default_sets;
 };
 

Modified: trunk/fs/usysfs/usysfs.h
===================================================================
--- trunk/fs/usysfs/usysfs.h	2005-03-26 02:23:52 UTC (rev 2063)
+++ trunk/fs/usysfs/usysfs.h	2005-03-28 20:16:38 UTC (rev 2064)
@@ -30,6 +30,7 @@
 #define _USYSFS_H_
 
 #include <asm/atomic.h>
+#include <asm/semaphore.h>
 
 #include "uobject.h"
 
@@ -102,7 +103,19 @@
 	ssize_t	(*store)(struct uobject *,struct usysfs_attribute *,const char *, size_t);
 };
 
-int usysfs_register_subsystem(struct uset *k);
-void usysfs_unregister_subsystem(struct uset *k);
+struct usysfs_subsystem {
+	struct uset		su_set;
+	struct semaphore	su_sem;
+};
 
+static inline struct usysfs_subsystem *to_usysfs_subsystem(struct uset *uset)
+{
+	return uset ?
+		container_of(uset, struct usysfs_subsystem, su_set) :
+		NULL;
+}
+
+int usysfs_register_subsystem(struct usysfs_subsystem *subsys);
+void usysfs_unregister_subsystem(struct usysfs_subsystem *subsys);
+
 #endif /* _USYSFS_H_ */



More information about the Ocfs2-commits mailing list