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

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Thu Mar 24 17:38:28 CST 2005


Author: jlbec
Signed-off-by: zab
Date: 2005-03-24 17:38:26 -0600 (Thu, 24 Mar 2005)
New Revision: 2047

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

o Get rid of the uuset.uset nesting.
o Fix a bug with symlink() trying to dereference non-usysfs targets.

Signed-off-by: zab



Modified: trunk/fs/ocfs2/cluster/heartbeat.c
===================================================================
--- trunk/fs/ocfs2/cluster/heartbeat.c	2005-03-24 22:00:16 UTC (rev 2046)
+++ trunk/fs/ocfs2/cluster/heartbeat.c	2005-03-24 23:38:26 UTC (rev 2047)
@@ -711,14 +711,14 @@
 /* heartbeat set */
 
 struct hb_heartbeat_set {
-	struct uuset hs_uuset;
+	struct uset hs_uset;
 	/* some stuff? */
 };
 
 static struct hb_heartbeat_set *to_hb_heartbeat_set(struct uset *uset)
 {
 	return uset ?
-		container_of(to_uuset(uset), struct hb_heartbeat_set, hs_uuset)
+		container_of(uset, struct hb_heartbeat_set, hs_uset)
 		: NULL;
 }
 
@@ -776,7 +776,7 @@
 	.owner		= THIS_MODULE,
 };
 
-/* this is just here to avoid touching uuset in heartbeat.h which the
+/* this is just here to avoid touching uset in heartbeat.h which the
  * entire damn world #includes */
 struct uset *hb_alloc_hb_set(void)
 {
@@ -787,10 +787,10 @@
 	if (hs == NULL)
 		goto out;
 
-	uuset_init_type_name(&hs->hs_uuset, "heartbeat",
-			     &hb_heartbeat_set_type.ktype);
+	uset_init_type_name(&hs->hs_uset, "heartbeat",
+			    &hb_heartbeat_set_type.ktype);
 
-	ret = &hs->hs_uuset.uset;
+	ret = &hs->hs_uset;
 out:
 	if (ret == NULL)
 		kfree(hs);

Modified: trunk/fs/ocfs2/cluster/nodemanager.c
===================================================================
--- trunk/fs/ocfs2/cluster/nodemanager.c	2005-03-24 22:00:16 UTC (rev 2046)
+++ trunk/fs/ocfs2/cluster/nodemanager.c	2005-03-24 23:38:26 UTC (rev 2047)
@@ -84,7 +84,7 @@
 #endif
 
 struct nm_cluster {
-	struct uuset	cl_uuset;
+	struct uset	cl_uset;
 	unsigned	cl_has_local:1;
 	u8		cl_local_node;
 	rwlock_t	cl_nodes_lock;
@@ -200,8 +200,8 @@
 static struct nm_cluster *to_nm_cluster(struct uobject *uobj)
 {
 	return uobj ?
-		container_of(to_uuset(to_uset(uobj)), struct nm_cluster,
-			     cl_uuset)
+		container_of(to_uset(uobj), struct nm_cluster,
+			     cl_uset)
 		: NULL;
 }
 
@@ -454,7 +454,7 @@
 /* node set */
 
 struct nm_node_set {
-	struct uuset ns_uuset;
+	struct uset ns_uset;
 	/* some stuff? */
 };
 
@@ -462,7 +462,7 @@
 static struct nm_node_set *to_nm_node_set(struct uset *uset)
 {
 	return uset ? 
-		container_of(to_uuset(uset), struct nm_node_set, ns_uuset) 
+		container_of(uset, struct nm_node_set, ns_uset) 
 		: NULL;
 }
 #endif
@@ -565,7 +565,7 @@
 
 	printk("releasing cluster %p\n", cluster);
 
-	kfree(cluster->cl_uuset.default_sets);
+	kfree(cluster->cl_uset.default_sets);
 	kfree(cluster);
 }
 
@@ -581,7 +581,7 @@
 /* cluster set */
 
 struct nm_cluster_set {
-	struct uuset cs_uuset;
+	struct uset cs_uset;
 	/* some stuff? */
 };
 
@@ -589,7 +589,7 @@
 static struct nm_cluster_set *to_nm_cluster_set(struct uset *uset)
 {
 	return uset ?
-		container_of(to_uuset(uset), struct nm_cluster_set, cs_uuset)
+		container_of(uset, struct nm_cluster_set, cs_uset)
 	       : NULL;
 }
 #endif
@@ -616,17 +616,17 @@
 	if (cluster == NULL || ns == NULL || hb_uset == NULL || defs == NULL)
 		goto out;
 
-	uuset_init_type_name(&cluster->cl_uuset, name, &nm_cluster_type.ktype);
-	uuset_init_type_name(&ns->ns_uuset, "node", &nm_node_set_type.ktype);
+	uset_init_type_name(&cluster->cl_uset, name, &nm_cluster_type.ktype);
+	uset_init_type_name(&ns->ns_uset, "node", &nm_node_set_type.ktype);
 
-	cluster->cl_uuset.default_sets = defs;
-	cluster->cl_uuset.default_sets[0] = &ns->ns_uuset.uset;
-	cluster->cl_uuset.default_sets[1] = hb_uset;
-	cluster->cl_uuset.default_sets[2] = NULL;
+	cluster->cl_uset.default_sets = defs;
+	cluster->cl_uset.default_sets[0] = &ns->ns_uset;
+	cluster->cl_uset.default_sets[1] = hb_uset;
+	cluster->cl_uset.default_sets[2] = NULL;
 	rwlock_init(&cluster->cl_nodes_lock);
 	cluster->cl_node_ip_tree = RB_ROOT;
 
-	ret = &cluster->cl_uuset.uset;
+	ret = &cluster->cl_uset;
 	nm_single_cluster = cluster;
 
 out:
@@ -660,12 +660,10 @@
 };
 
 static struct nm_cluster_set nm_cluster_set = {
-	.cs_uuset = {
-		.uset = {
-			.uobj = {
-				.name = "cluster",
-				.ktype = &nm_cluster_set_type.ktype,
-			},
+	.cs_uset = {
+		.uobj = {
+			.name = "cluster",
+			.ktype = &nm_cluster_set_type.ktype,
 		},
 	},
 };
@@ -675,7 +673,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_uuset.uset);
+	usysfs_unregister_subsystem(&nm_cluster_set.cs_uset);
 }
 
 static int __init init_nm(void)
@@ -687,8 +685,8 @@
 	if (ret)
 		goto out;
 
-	uuset_init(&nm_cluster_set.cs_uuset);
-	ret = usysfs_register_subsystem(&nm_cluster_set.cs_uuset.uset);
+	uset_init(&nm_cluster_set.cs_uset);
+	ret = usysfs_register_subsystem(&nm_cluster_set.cs_uset);
 	if (ret) {
 		printk(KERN_ERR "nodemanager: Registration returned %d\n", ret);
 		goto out;

Modified: trunk/fs/usysfs/bobtest.c
===================================================================
--- trunk/fs/usysfs/bobtest.c	2005-03-24 22:00:16 UTC (rev 2046)
+++ trunk/fs/usysfs/bobtest.c	2005-03-24 23:38:26 UTC (rev 2047)
@@ -36,7 +36,7 @@
  * Bobs - default_set as part of subsystem.
  */
 struct robert {
-	struct uuset uuset;
+	struct uset uset;
 };
 
 struct robert_attribute {
@@ -47,7 +47,7 @@
 static inline struct robert *to_robert(struct uobject *uobj)
 {
 	return uobj ?
-		container_of(to_uuset(to_uset(uobj)), struct robert, uuset) :
+		container_of(to_uset(uobj), struct robert, uset) :
 		NULL;
 }
 
@@ -104,12 +104,10 @@
 };
 
 static struct robert robert = {
-	.uuset = {
-		.uset = {
-			.uobj = {
-				.name = "robert",
-				.ktype = &uktype_robert.ktype,
-			},
+	.uset = {
+		.uobj = {
+			.name = "robert",
+			.ktype = &uktype_robert.ktype,
 		},
 	},
 };
@@ -231,7 +229,7 @@
 
 
 struct bobset {
-	struct uuset uuset;
+	struct uset uset;
 	int n_bobs;
 };
 
@@ -243,7 +241,7 @@
 static inline struct bobset *to_bobset(struct uset *uset)
 {
 	return uset ?
-		container_of(to_uuset(uset), struct bobset, uuset) :
+		container_of(uset, struct bobset, uset) :
 		NULL;
 }
 
@@ -281,7 +279,7 @@
 };
 
 static struct uset *bobset_sets[] = {
-	&robert.uuset.uset,
+	&robert.uset,
 	NULL,
 };
 
@@ -325,12 +323,10 @@
 };
 
 static struct bobset bobset = {
-	.uuset = {
-		.uset = {
-			.uobj = {
-				.name = "bobset",
-				.ktype = &uktype_bobset.ktype,
-			},
+	.uset = {
+		.uobj = {
+			.name = "bobset",
+			.ktype = &uktype_bobset.ktype,
 		},
 		.default_sets = bobset_sets,
 	},
@@ -341,7 +337,7 @@
  * Toms - default_set as part of a created set.
  */
 struct jerry {
-	struct uuset uuset;
+	struct uset uset;
 	int showme;
 	int storeme;
 };
@@ -355,7 +351,7 @@
 static inline struct jerry *to_jerry(struct uobject *uobj)
 {
 	return uobj ?
-		container_of(to_uuset(to_uset(uobj)), struct jerry, uuset) :
+		container_of(to_uset(uobj), struct jerry, uset) :
 		NULL;
 }
 
@@ -468,7 +464,7 @@
 
 
 struct tom {
-	struct uuset uuset;
+	struct uset uset;
 	int showme;
 	int storeme;
 };
@@ -482,7 +478,7 @@
 static inline struct tom *to_tom(struct uobject *uobj)
 {
 	return uobj ?
-		container_of(to_uuset(to_uset(uobj)), struct tom, uuset) :
+		container_of(to_uset(uobj), struct tom, uset) :
 			NULL;
 }
 
@@ -572,7 +568,7 @@
 	struct tom *tom = to_tom(uobj);
 
 	printk("Oooh, that's gonna leave a mark!\n");
-	kfree(to_jerry(&tom->uuset.default_sets[0]->uobj));
+	kfree(to_jerry(&tom->uset.default_sets[0]->uobj));
 	kfree(tom);
 }
 
@@ -588,7 +584,7 @@
 
 
 struct tomset {
-	struct uuset uuset;
+	struct uset uset;
 	int n_toms;
 };
 
@@ -600,7 +596,7 @@
 static inline struct tomset *to_tomset(struct uset *uset)
 {
 	return uset ?
-		container_of(to_uuset(uset), struct tomset, uuset) :
+		container_of(uset, struct tomset, uset) :
 		NULL;
 }
 
@@ -648,38 +644,38 @@
 		return NULL;
 
 	memset(tom, 0, sizeof(struct tom));
-	tom->uuset.default_sets = kmalloc(sizeof(struct uset *) * 2,
+	tom->uset.default_sets = kmalloc(sizeof(struct uset *) * 2,
 		       			  GFP_KERNEL);
-	if (!tom->uuset.default_sets) {
+	if (!tom->uset.default_sets) {
 		kfree(tom);
 		return NULL;
 	}
 
 	jerry = kmalloc(sizeof(struct jerry), GFP_KERNEL);
 	if (!jerry) {
-		kfree(tom->uuset.default_sets);
+		kfree(tom->uset.default_sets);
 		kfree(tom);
 		return NULL;
 	}
 
 	memset(jerry, 0, sizeof(struct jerry));
 
-	uobject_set_name(&tom->uuset.uset.uobj, name);
-	tom->uuset.uset.uobj.ktype = &uktype_tom.ktype;
-	uuset_init(&tom->uuset);
+	uobject_set_name(&tom->uset.uobj, name);
+	tom->uset.uobj.ktype = &uktype_tom.ktype;
+	uset_init(&tom->uset);
 
 	tom->showme = 0;
 	tom->storeme = 0;
 	tomset->n_toms++;
 
-	uobject_set_name(&jerry->uuset.uset.uobj, "jer");
-	jerry->uuset.uset.uobj.ktype = &uktype_jerry.ktype;
-	uuset_init(&jerry->uuset);
+	uobject_set_name(&jerry->uset.uobj, "jer");
+	jerry->uset.uobj.ktype = &uktype_jerry.ktype;
+	uset_init(&jerry->uset);
 
-	tom->uuset.default_sets[0] = &jerry->uuset.uset;
-	tom->uuset.default_sets[1] = NULL;
+	tom->uset.default_sets[0] = &jerry->uset;
+	tom->uset.default_sets[1] = NULL;
 
-	return &tom->uuset.uset;
+	return &tom->uset;
 }
 
 static void drop_tom(struct uset *uset, struct uobject *uobj)
@@ -700,12 +696,10 @@
 };
 
 static struct tomset tomset = {
-	.uuset = {
-		.uset = {
-			.uobj = {
-				.name = "tomset",
-				.ktype = &uktype_tomset.ktype,
-			},
+	.uset = {
+		.uobj = {
+			.name = "tomset",
+			.ktype = &uktype_tomset.ktype,
 		},
 	},
 	.n_toms = 0,
@@ -715,12 +709,12 @@
 {
 	int ret;
 
-	uuset_init(&bobset.uuset);
-	uuset_init(&robert.uuset);
-	uuset_init(&tomset.uuset);
-	ret = usysfs_register_subsystem(&bobset.uuset.uset);
+	uset_init(&bobset.uset);
+	uset_init(&robert.uset);
+	uset_init(&tomset.uset);
+	ret = usysfs_register_subsystem(&bobset.uset);
 	if (!ret)
-		ret = usysfs_register_subsystem(&tomset.uuset.uset);
+		ret = usysfs_register_subsystem(&tomset.uset);
 	if (ret)
 		printk(KERN_ERR "bobtest: Registration returned %d\n", ret);
 
@@ -729,8 +723,8 @@
 
 static void __exit bobtest_exit(void)
 {
-	usysfs_unregister_subsystem(&tomset.uuset.uset);
-	usysfs_unregister_subsystem(&bobset.uuset.uset);
+	usysfs_unregister_subsystem(&tomset.uset);
+	usysfs_unregister_subsystem(&bobset.uset);
 }
 
 module_init(bobtest_init);

Modified: trunk/fs/usysfs/dir.c
===================================================================
--- trunk/fs/usysfs/dir.c	2005-03-24 22:00:16 UTC (rev 2046)
+++ trunk/fs/usysfs/dir.c	2005-03-24 23:38:26 UTC (rev 2047)
@@ -465,13 +465,12 @@
 
 static int populate_sets(struct uset *uset)
 {
-	struct uuset *uuset = to_uuset(uset);
 	struct uset *new_set;
 	struct dentry *dentry = uset->uobj.dentry;
 	int ret = 0;
 	int i;
 
-	if (uuset && uuset->default_sets) {
+	if (uset && uset->default_sets) {
 		/* FYI, we're faking mkdir here
 		 * I'm not sure we need this semaphore, as we're called
 		 * from our parent's mkdir.  That holds our parent's
@@ -481,8 +480,8 @@
 		 * emulation, and shouldn't hurt. */
 		down(&dentry->d_inode->i_sem);
 
-		for (i = 0; uuset->default_sets[i]; i++) {
-			new_set = uuset->default_sets[i];
+		for (i = 0; uset->default_sets[i]; i++) {
+			new_set = uset->default_sets[i];
 
 			ret = create_default_set(uset, new_set);
 			if (ret)

Modified: trunk/fs/usysfs/mount.c
===================================================================
--- trunk/fs/usysfs/mount.c	2005-03-24 22:00:16 UTC (rev 2046)
+++ trunk/fs/usysfs/mount.c	2005-03-24 23:38:26 UTC (rev 2047)
@@ -52,42 +52,34 @@
 #endif
 };
 
-static struct uuset usysfs_root_set = {
-	.uset = {
-		.uobj = {
-			.name	= "root",
-			.k_name	= usysfs_root_set.uset.uobj.name,
-		},
+static struct uset usysfs_root_set = {
+	.uobj = {
+		.name	= "root",
+		.k_name	= usysfs_root_set.uobj.name,
 	},
 };
 
 int usysfs_is_root(struct uobject *uobj)
 {
-	return uobj == &usysfs_root_set.uset.uobj;
+	return uobj == &usysfs_root_set.uobj;
 }
 
 static struct usysfs_dirent usysfs_root = {
 	.s_sibling	= LIST_HEAD_INIT(usysfs_root.s_sibling),
 	.s_children	= LIST_HEAD_INIT(usysfs_root.s_children),
-	.s_element	= &usysfs_root_set.uset.uobj,
+	.s_element	= &usysfs_root_set.uobj,
 	.s_type		= USYSFS_ROOT,
 };
 
-void uuset_init(struct uuset *uuset)
+void uset_init_type_name(struct uset *uset, const char *name,
+			 struct uobj_type *ktype)
 {
-	uset_init(&uuset->uset);
+	uobject_set_name(&uset->uobj, name);
+	uset->uobj.ktype = ktype;
+	uset_init(uset);
 }
-EXPORT_SYMBOL_GPL(uuset_init);
+EXPORT_SYMBOL(uset_init_type_name);
 
-void uuset_init_type_name(struct uuset *uuset, const char *name,
-			  struct uobj_type *ktype)
-{
-	uobject_set_name(&uuset->uset.uobj, name);
-	uuset->uset.uobj.ktype = ktype;
-	uuset_init(uuset);
-}
-EXPORT_SYMBOL(uuset_init_type_name);
-
 static int usysfs_fill_super(struct super_block *sb, void *data, int silent)
 {
 	struct inode *inode;
@@ -116,8 +108,8 @@
 		iput(inode);
 		return -ENOMEM;
 	}
-	uuset_init(&usysfs_root_set);
-	usysfs_root_set.uset.uobj.dentry = root;
+	uset_init(&usysfs_root_set);
+	usysfs_root_set.uobj.dentry = root;
 	root->d_fsdata = &usysfs_root;
 	sb->s_root = root;
 	return 0;

Modified: trunk/fs/usysfs/symlink.c
===================================================================
--- trunk/fs/usysfs/symlink.c	2005-03-24 22:00:16 UTC (rev 2046)
+++ trunk/fs/usysfs/symlink.c	2005-03-24 23:38:26 UTC (rev 2047)
@@ -101,11 +101,14 @@
 
 	ret = path_lookup(symname, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, nd);
 	if (!ret) {
-		*target = usysfs_get_uobject(nd->dentry);
-		if (!*target) {
-			ret = -ENOENT;
-			path_release(nd);
-		}
+		if (nd->dentry->d_sb == usysfs_sb) {
+			*target = usysfs_get_uobject(nd->dentry);
+			if (!*target) {
+				ret = -ENOENT;
+				path_release(nd);
+			}
+		} else
+			ret = -EPERM;
 	}
 
 	return ret;

Modified: trunk/fs/usysfs/uobject.c
===================================================================
--- trunk/fs/usysfs/uobject.c	2005-03-24 22:00:16 UTC (rev 2046)
+++ trunk/fs/usysfs/uobject.c	2005-03-24 23:38:26 UTC (rev 2047)
@@ -23,7 +23,6 @@
 
 #include "uobject.h"
 
-static spinlock_t uset_linkage_lock = SPIN_LOCK_UNLOCKED;
 
 static inline struct uobject * to_uobj(struct list_head * entry)
 {

Modified: trunk/fs/usysfs/uobject.h
===================================================================
--- trunk/fs/usysfs/uobject.h	2005-03-24 22:00:16 UTC (rev 2046)
+++ trunk/fs/usysfs/uobject.h	2005-03-24 23:38:26 UTC (rev 2047)
@@ -1,4 +1,6 @@
-/*
+/* -*- mode: c; c-basic-offset: 8; -*-
+ * vim: noexpandtab sw=8 ts=8 sts=0:
+ *
  * uobject.h - generic user object infrastructure.
  *
  * This program is free software; you can redistribute it and/or
@@ -68,7 +70,7 @@
 struct uobj_type {
 	void (*release)(struct uobject *);
 	struct usysfs_attribute_operations	*sysfs_ops;
-	struct usysfs_attribute                 **default_attrs;
+	struct usysfs_attribute			**default_attrs;
 };
 
 
@@ -78,8 +80,9 @@
  */
 
 struct uset {
+	struct uobject		uobj;
 	struct list_head	list;
-	struct uobject		uobj;
+	struct uset **default_sets;
 };
 
 

Modified: trunk/fs/usysfs/usysfs.h
===================================================================
--- trunk/fs/usysfs/usysfs.h	2005-03-24 22:00:16 UTC (rev 2046)
+++ trunk/fs/usysfs/usysfs.h	2005-03-24 23:38:26 UTC (rev 2047)
@@ -49,7 +49,7 @@
  * objects must supply one of make_set() and make_object().  If the
  * object supports make_set(), one can create uset children.  If it
  * supports make_object(), one can create uobject children.  If it has
- * default_sets on uuset->default_sets, it has automatically created
+ * default_sets on uset->default_sets, it has automatically created
  * uset children.  default_sets may coexist alongsize make_set() or
  * make_object(), but if the uset wishes to have only default_sets 
  * children (disallowing mkdir(2)), it must provide
@@ -81,25 +81,10 @@
 }
 
 
-/*
- * Usysfs usets must actually be of type uuset.  This allows default
- * child sets to be created.
- */
-struct uuset {
-	struct uset uset;
-	struct uset **default_sets;
-};
+void uset_init_type_name(struct uset *uset, const char *name,
+			 struct uobj_type *ktype);
 
-static inline struct uuset *to_uuset(struct uset *uset)
-{
-	return uset ? container_of(uset, struct uuset, uset) : NULL;
-}
 
-void uuset_init(struct uuset *uuset);
-void uuset_init_type_name(struct uuset *uuset, const char *name,
-			  struct uobj_type *ktype);
-
-
 /**
  * Use these macros to make defining attributes easier. See include/linux/device.h
  * for examples..



More information about the Ocfs2-commits mailing list