[Ocfs2-commits] jlbec commits r2050 - in trunk/fs: ocfs2/cluster
usysfs
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Thu Mar 24 20:20:38 CST 2005
Author: jlbec
Signed-off-by: zab
Date: 2005-03-24 20:20:36 -0600 (Thu, 24 Mar 2005)
New Revision: 2050
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/symlink.c
trunk/fs/usysfs/uobject.c
trunk/fs/usysfs/uobject.h
trunk/fs/usysfs/usysfs.h
Log:
o Move operations into ops structs.
o Get rid of uuobj_type wrapper type.
Signed-off-by: zab
Modified: trunk/fs/ocfs2/cluster/heartbeat.c
===================================================================
--- trunk/fs/ocfs2/cluster/heartbeat.c 2005-03-25 01:25:05 UTC (rev 2049)
+++ trunk/fs/ocfs2/cluster/heartbeat.c 2005-03-25 02:20:36 UTC (rev 2050)
@@ -694,17 +694,19 @@
return ret;
}
-struct usysfs_attribute_operations hb_region_sysfs_ops = {
+static struct usysfs_attribute_operations hb_region_sysfs_ops = {
.show = &hb_region_show,
.store = &hb_region_store,
};
-static struct uuobj_type hb_region_type = {
- .ktype = {
- .release = hb_region_release,
- .sysfs_ops = &hb_region_sysfs_ops,
- .default_attrs = hb_region_default_attrs,
- },
+static struct usysfs_object_operations hb_region_object_ops = {
+ .release = hb_region_release,
+};
+
+static struct uobj_type hb_region_type = {
+ .object_ops = &hb_region_object_ops,
+ .sysfs_ops = &hb_region_sysfs_ops,
+ .default_attrs = hb_region_default_attrs,
.owner = THIS_MODULE,
};
@@ -737,7 +739,7 @@
INIT_LIST_HEAD(®->hr_live_list);
uobject_set_name(®->hr_uobj, name);
- reg->hr_uobj.ktype = &hb_region_type.ktype;
+ reg->hr_uobj.ktype = &hb_region_type;
uobject_init(®->hr_uobj);
ret = ®->hr_uobj;
@@ -767,12 +769,14 @@
uobject_put(uobj);
}
-struct uuobj_type hb_heartbeat_set_type = {
- .ktype = {
- .sysfs_ops = NULL, /* no attributes */
- },
+static struct usysfs_set_operations hb_heartbeat_set_set_ops = {
.make_object = hb_heartbeat_set_make_object,
.drop_object = hb_heartbeat_set_drop_object,
+};
+
+struct uobj_type hb_heartbeat_set_type = {
+ .set_ops = &hb_heartbeat_set_set_ops,
+ .sysfs_ops = NULL, /* no attributes */
.owner = THIS_MODULE,
};
@@ -788,7 +792,7 @@
goto out;
uset_init_type_name(&hs->hs_uset, "heartbeat",
- &hb_heartbeat_set_type.ktype);
+ &hb_heartbeat_set_type);
ret = &hs->hs_uset;
out:
Modified: trunk/fs/ocfs2/cluster/nodemanager.c
===================================================================
--- trunk/fs/ocfs2/cluster/nodemanager.c 2005-03-25 01:25:05 UTC (rev 2049)
+++ trunk/fs/ocfs2/cluster/nodemanager.c 2005-03-25 02:20:36 UTC (rev 2050)
@@ -436,18 +436,23 @@
return ret;
}
-struct usysfs_attribute_operations nm_node_sysfs_ops = {
+static struct usysfs_attribute_operations nm_node_sysfs_ops = {
.show = &nm_node_show,
.store = &nm_node_store,
};
-static struct uuobj_type nm_node_type = {
- .ktype = {
- .release = nm_node_release,
- .sysfs_ops = &nm_node_sysfs_ops,
- .default_attrs = nm_node_default_attrs,
- },
- .make_object = usysfs_make_no_object,
+static struct usysfs_object_operations nm_node_object_ops = {
+ .release = nm_node_release,
+};
+
+static struct usysfs_set_operations nm_node_set_ops = {
+};
+
+static struct uobj_type nm_node_type = {
+ .object_ops = &nm_node_object_ops,
+ .set_ops = &nm_node_set_ops,
+ .sysfs_ops = &nm_node_sysfs_ops,
+ .default_attrs = nm_node_default_attrs,
.owner = THIS_MODULE,
};
@@ -501,7 +506,7 @@
}
uobject_set_name(&node->nd_uobj, name);
- node->nd_uobj.ktype = &nm_node_type.ktype;
+ node->nd_uobj.ktype = &nm_node_type;
uobject_init(&node->nd_uobj);
ret = &node->nd_uobj;
@@ -548,12 +553,14 @@
uobject_put(uobj);
}
-static struct uuobj_type nm_node_set_type = {
- .ktype = {
- .sysfs_ops = NULL, /* no attributes */
- },
+static struct usysfs_set_operations nm_node_set_set_ops = {
.make_object = nm_node_set_make_object,
.drop_object = nm_node_set_drop_object,
+};
+
+static struct uobj_type nm_node_set_type = {
+ .set_ops = &nm_node_set_set_ops,
+ .sysfs_ops = NULL, /* no attributes */
.owner = THIS_MODULE,
};
@@ -569,12 +576,17 @@
kfree(cluster);
}
-static struct uuobj_type nm_cluster_type = {
- .ktype = {
- .release = nm_cluster_release,
- .sysfs_ops = NULL, /* no attributes */
- },
- .make_object = usysfs_make_no_object,
+static struct usysfs_object_operations nm_cluster_object_ops = {
+ .release = nm_cluster_release,
+};
+
+static struct usysfs_set_operations nm_cluster_set_ops = {
+};
+
+static struct uobj_type nm_cluster_type = {
+ .object_ops = &nm_cluster_object_ops,
+ .set_ops = &nm_cluster_set_ops,
+ .sysfs_ops = NULL, /* no attributes */
.owner = THIS_MODULE,
};
@@ -616,8 +628,8 @@
if (cluster == NULL || ns == NULL || hb_uset == NULL || defs == NULL)
goto out;
- 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);
+ uset_init_type_name(&cluster->cl_uset, name, &nm_cluster_type);
+ uset_init_type_name(&ns->ns_uset, "node", &nm_node_set_type);
cluster->cl_uset.default_sets = defs;
cluster->cl_uset.default_sets[0] = &ns->ns_uset;
@@ -650,12 +662,14 @@
uobject_put(uobj);
}
-static struct uuobj_type nm_cluster_set_type = {
- .ktype = {
- .sysfs_ops = NULL, /* no attributes */
- },
+static struct usysfs_set_operations nm_cluster_set_set_ops = {
.make_set = nm_cluster_set_make_set,
.drop_object = nm_cluster_set_drop_object,
+};
+
+static struct uobj_type nm_cluster_set_type = {
+ .set_ops = &nm_cluster_set_set_ops,
+ .sysfs_ops = NULL, /* no attributes */
.owner = THIS_MODULE,
};
@@ -663,7 +677,7 @@
.cs_uset = {
.uobj = {
.name = "cluster",
- .ktype = &nm_cluster_set_type.ktype,
+ .ktype = &nm_cluster_set_type,
},
},
};
Modified: trunk/fs/usysfs/bobtest.c
===================================================================
--- trunk/fs/usysfs/bobtest.c 2005-03-25 01:25:05 UTC (rev 2049)
+++ trunk/fs/usysfs/bobtest.c 2005-03-25 02:20:36 UTC (rev 2050)
@@ -94,12 +94,14 @@
kfree(to_robert(uobj));
}
-static struct uuobj_type uktype_robert = {
- .ktype = {
- .release = robert_release,
- .sysfs_ops = &robert_sysfs_ops,
- .default_attrs = robert_attrs,
- },
+static struct usysfs_object_operations robert_object_ops = {
+ .release = robert_release,
+};
+
+static struct uobj_type uktype_robert = {
+ .object_ops = &robert_object_ops,
+ .sysfs_ops = &robert_sysfs_ops,
+ .default_attrs = robert_attrs,
.owner = THIS_MODULE,
};
@@ -107,7 +109,7 @@
.uset = {
.uobj = {
.name = "robert",
- .ktype = &uktype_robert.ktype,
+ .ktype = &uktype_robert,
},
},
};
@@ -218,12 +220,14 @@
kfree(to_bob(uobj));
}
-static struct uuobj_type uktype_bob = {
- .ktype = {
- .release = bob_release,
- .sysfs_ops = &bob_sysfs_ops,
- .default_attrs = bob_attrs,
- },
+static struct usysfs_object_operations bob_object_ops = {
+ .release = bob_release,
+};
+
+static struct uobj_type uktype_bob = {
+ .object_ops = &bob_object_ops,
+ .sysfs_ops = &bob_sysfs_ops,
+ .default_attrs = bob_attrs,
.owner = THIS_MODULE,
};
@@ -295,7 +299,7 @@
memset(bob, 0, sizeof(struct bob));
uobject_set_name(&bob->uobj, name);
- bob->uobj.ktype = &uktype_bob.ktype;
+ bob->uobj.ktype = &uktype_bob;
uobject_init(&bob->uobj);
bob->showme = 0;
@@ -313,20 +317,22 @@
uobject_put(uobj);
}
-static struct uuobj_type uktype_bobset = {
- .ktype = {
- .sysfs_ops = &bobset_sysfs_ops,
- .default_attrs = bobset_attrs,
- },
+static struct usysfs_set_operations bobset_set_ops = {
.make_object = make_bob,
.drop_object = drop_bob,
};
+static struct uobj_type uktype_bobset = {
+ .set_ops = &bobset_set_ops,
+ .sysfs_ops = &bobset_sysfs_ops,
+ .default_attrs = bobset_attrs,
+};
+
static struct bobset bobset = {
.uset = {
.uobj = {
.name = "bobset",
- .ktype = &uktype_bobset.ktype,
+ .ktype = &uktype_bobset,
},
.default_sets = bobset_sets,
},
@@ -446,23 +452,24 @@
{
int ret = 0;
- if (target->ktype != &uktype_bob.ktype)
+ if (target->ktype != &uktype_bob)
ret = -EINVAL;
return ret;
}
-static struct uuobj_type uktype_jerry = {
- .ktype = {
- .release = jerry_release,
- .sysfs_ops = &jerry_sysfs_ops,
- .default_attrs = jerry_attrs,
- },
- .allow_link = jerry_allow_link,
+static struct usysfs_object_operations jerry_object_ops = {
+ .release = jerry_release,
+ .allow_link = jerry_allow_link,
+};
+
+static struct uobj_type uktype_jerry = {
+ .object_ops = &jerry_object_ops,
+ .sysfs_ops = &jerry_sysfs_ops,
+ .default_attrs = jerry_attrs,
.owner = THIS_MODULE,
};
-
struct tom {
struct uset uset;
int showme;
@@ -572,13 +579,18 @@
kfree(tom);
}
-static struct uuobj_type uktype_tom = {
- .ktype = {
- .release = tom_release,
- .sysfs_ops = &tom_sysfs_ops,
- .default_attrs = tom_attrs,
- },
- .make_object = usysfs_make_no_object,
+static struct usysfs_set_operations tom_set_ops = {
+};
+
+static struct usysfs_object_operations tom_object_ops = {
+ .release = tom_release,
+};
+
+static struct uobj_type uktype_tom = {
+ .object_ops = &tom_object_ops,
+ .set_ops = &tom_set_ops,
+ .sysfs_ops = &tom_sysfs_ops,
+ .default_attrs = tom_attrs,
.owner = THIS_MODULE,
};
@@ -661,7 +673,7 @@
memset(jerry, 0, sizeof(struct jerry));
uobject_set_name(&tom->uset.uobj, name);
- tom->uset.uobj.ktype = &uktype_tom.ktype;
+ tom->uset.uobj.ktype = &uktype_tom;
uset_init(&tom->uset);
tom->showme = 0;
@@ -669,7 +681,7 @@
tomset->n_toms++;
uobject_set_name(&jerry->uset.uobj, "jer");
- jerry->uset.uobj.ktype = &uktype_jerry.ktype;
+ jerry->uset.uobj.ktype = &uktype_jerry;
uset_init(&jerry->uset);
tom->uset.default_sets[0] = &jerry->uset;
@@ -686,20 +698,22 @@
uobject_put(uobj);
}
-static struct uuobj_type uktype_tomset = {
- .ktype = {
- .sysfs_ops = &tomset_sysfs_ops,
- .default_attrs = tomset_attrs,
- },
+static struct usysfs_set_operations tomset_set_ops = {
.make_set = make_tom,
.drop_object = drop_tom,
};
+static struct uobj_type uktype_tomset = {
+ .set_ops = &tomset_set_ops,
+ .sysfs_ops = &tomset_sysfs_ops,
+ .default_attrs = tomset_attrs,
+};
+
static struct tomset tomset = {
.uset = {
.uobj = {
.name = "tomset",
- .ktype = &uktype_tomset.ktype,
+ .ktype = &uktype_tomset,
},
},
.n_toms = 0,
Modified: trunk/fs/usysfs/dir.c
===================================================================
--- trunk/fs/usysfs/dir.c 2005-03-25 01:25:05 UTC (rev 2049)
+++ trunk/fs/usysfs/dir.c 2005-03-25 02:20:36 UTC (rev 2050)
@@ -608,13 +608,14 @@
static void client_drop_object(struct uobject *parent_uobj,
struct uobject *uobj)
{
- struct uuobj_type *uktype;
+ struct uobj_type *uktype;
- uktype = to_uutype(parent_uobj->ktype);
+ uktype = parent_uobj->ktype;
BUG_ON(!uktype);
- if (uktype->drop_object)
- uktype->drop_object(to_uset(parent_uobj), uobj);
+ if (uktype->set_ops->drop_object)
+ uktype->set_ops->drop_object(to_uset(parent_uobj),
+ uobj);
else
uobject_put(uobj);
}
@@ -626,7 +627,7 @@
struct uset *uset;
struct uobject *uobj;
struct uobject *parent_uobj;
- struct uuobj_type *uktype;
+ struct uobj_type *uktype;
struct module *owner;
char *name;
@@ -634,9 +635,11 @@
return -EPERM;
parent_uobj = usysfs_get_uobject(dentry->d_parent);
- uktype = to_uutype(parent_uobj->ktype);
+ uktype = parent_uobj->ktype;
- if (!uktype || (!uktype->make_set && !uktype->make_object)) {
+ if (!uktype ||
+ (!uktype->set_ops->make_set &&
+ !uktype->set_ops->make_object)) {
uobject_put(parent_uobj);
return -EPERM; /* What lack-of-mkdir returns */
}
@@ -647,12 +650,12 @@
return -ENOMEM;
}
snprintf(name, dentry->d_name.len + 1, "%s", dentry->d_name.name);
- if (uktype->make_set) {
- uset = uktype->make_set(to_uset(parent_uobj), name);
+ if (uktype->set_ops->make_set) {
+ uset = uktype->set_ops->make_set(to_uset(parent_uobj), name);
uobj = uset ? &uset->uobj : NULL;
} else {
uset = NULL;
- uobj = uktype->make_object(to_uset(parent_uobj), name);
+ uobj = uktype->set_ops->make_object(to_uset(parent_uobj), name);
}
kfree(name);
if (!uobj) {
@@ -661,7 +664,7 @@
}
ret = -EINVAL;
- uktype = to_uutype(uobj->ktype);
+ uktype = uobj->ktype;
if (uktype) {
owner = uktype->owner;
if (try_module_get(owner)) {
@@ -687,15 +690,11 @@
static int is_set(struct uobject *uobj)
{
int ret = 0;
- struct uuobj_type *uktype;
+ struct uobj_type *uktype;
- uktype = to_uutype(uobj->ktype);
- if (uktype) {
- if (uktype->make_set)
- ret = 1;
- else if (uktype->make_object)
- ret = 1;
- }
+ uktype = uobj->ktype;
+ if (uktype && uktype->set_ops)
+ ret = 1;
return ret;
}
@@ -704,7 +703,6 @@
{
struct uobject *parent_uobj;
struct uobject *uobj;
- struct uuobj_type *uktype, *child_uktype;
struct usysfs_dirent *sd;
struct module *owner = NULL;
int ret;
@@ -718,8 +716,7 @@
parent_uobj = usysfs_get_uobject(dentry->d_parent);
- uktype = to_uutype(parent_uobj->ktype);
- if (!uktype) {
+ if (!parent_uobj->ktype) {
uobject_put(parent_uobj);
return -EINVAL;
}
@@ -735,9 +732,8 @@
/* Drop reference from above, uobj already holds one. */
uobject_put(parent_uobj);
- child_uktype = to_uutype(uobj->ktype);
- if (child_uktype)
- owner = child_uktype->owner;
+ if (uobj->ktype)
+ owner = uobj->ktype->owner;
if (is_set(uobj))
usysfs_drop_set(uobj);
Modified: trunk/fs/usysfs/symlink.c
===================================================================
--- trunk/fs/usysfs/symlink.c 2005-03-25 01:25:05 UTC (rev 2049)
+++ trunk/fs/usysfs/symlink.c 2005-03-25 02:20:36 UTC (rev 2050)
@@ -121,23 +121,24 @@
struct nameidata nd;
struct uobject *parent_uobj;
struct uobject *target_uobj;
- struct uuobj_type *uktype;
+ struct uobj_type *uktype;
ret = -EPERM; /* What lack-of-symlink returns */
if (dentry->d_parent == usysfs_sb->s_root)
goto out;
parent_uobj = usysfs_get_uobject(dentry->d_parent);
- uktype = to_uutype(parent_uobj->ktype);
+ uktype = parent_uobj->ktype;
- if (!uktype || !uktype->allow_link)
+ if (!uktype || !uktype->object_ops ||
+ !uktype->object_ops->allow_link)
goto out_put;
ret = get_target(symname, &nd, &target_uobj);
if (ret)
goto out_put;
- ret = uktype->allow_link(parent_uobj, target_uobj);
+ ret = uktype->object_ops->allow_link(parent_uobj, target_uobj);
if (!ret)
ret = create_link(parent_uobj, target_uobj, dentry);
@@ -156,7 +157,7 @@
struct usysfs_dirent *sd = dentry->d_fsdata;
struct usysfs_symlink *sl;
struct uobject *parent_uobj;
- struct uuobj_type *uktype;
+ struct uobj_type *uktype;
int ret;
ret = -EPERM; /* What lack-of-symlink returns */
@@ -169,7 +170,7 @@
sl = sd->s_element;
parent_uobj = usysfs_get_uobject(dentry->d_parent);
- uktype = to_uutype(parent_uobj->ktype);
+ uktype = parent_uobj->ktype;
list_del_init(&sd->s_sibling);
usysfs_drop_dentry(sd, dentry->d_parent);
@@ -181,8 +182,10 @@
* list_del_init(&sl->sl_list), so that the order of
* drop_link(this, target) and drop_object(target) is preserved.
*/
- if (uktype && uktype->drop_link)
- uktype->drop_link(parent_uobj, sl->sl_target);
+ if (uktype && uktype->object_ops &&
+ uktype->object_ops->drop_link)
+ uktype->object_ops->drop_link(parent_uobj,
+ sl->sl_target);
/* FIXME: Needs lock */
list_del_init(&sl->sl_list);
Modified: trunk/fs/usysfs/uobject.c
===================================================================
--- trunk/fs/usysfs/uobject.c 2005-03-25 01:25:05 UTC (rev 2049)
+++ trunk/fs/usysfs/uobject.c 2005-03-25 02:20:36 UTC (rev 2050)
@@ -22,6 +22,7 @@
#include <linux/slab.h>
#include "uobject.h"
+#include "usysfs.h"
static inline struct uobject * to_uobj(struct list_head * entry)
@@ -124,8 +125,8 @@
if (uobj->k_name != uobj->name)
kfree(uobj->k_name);
uobj->k_name = NULL;
- if (t && t->release)
- t->release(uobj);
+ if (t && t->object_ops && t->object_ops->release)
+ t->object_ops->release(uobj);
if (s)
uset_put(s);
if (parent)
Modified: trunk/fs/usysfs/uobject.h
===================================================================
--- trunk/fs/usysfs/uobject.h 2005-03-25 01:25:05 UTC (rev 2049)
+++ trunk/fs/usysfs/uobject.h 2005-03-25 02:20:36 UTC (rev 2050)
@@ -40,6 +40,8 @@
#define UOBJ_NAME_LEN 20
+struct usysfs_object_operations;
+struct usysfs_set_operations;
struct usysfs_attribute;
struct usysfs_attribute_operations;
@@ -68,7 +70,9 @@
extern void uobject_put(struct uobject *);
struct uobj_type {
- void (*release)(struct uobject *);
+ struct module *owner;
+ struct usysfs_object_operations *object_ops;
+ struct usysfs_set_operations *set_ops;
struct usysfs_attribute_operations *sysfs_ops;
struct usysfs_attribute **default_attrs;
};
@@ -82,7 +86,7 @@
struct uset {
struct uobject uobj;
struct list_head list;
- struct uset **default_sets;
+ struct uset **default_sets;
};
Modified: trunk/fs/usysfs/usysfs.h
===================================================================
--- trunk/fs/usysfs/usysfs.h 2005-03-25 01:25:05 UTC (rev 2049)
+++ trunk/fs/usysfs/usysfs.h 2005-03-25 02:20:36 UTC (rev 2050)
@@ -43,7 +43,7 @@
/*
- * Usysfs objects must have a ->ktype of type uuobj_type.
+ * Usysfs objects must have a ->ktype of type uobj_type.
* If allow_link() exists, the object can symlink(2) out to other
* objects. If the object is a uset, it may support mkdir(2). Kset
* objects must supply one of make_set() and make_object(). If the
@@ -56,24 +56,19 @@
* usysfs_make_no_object() as the value for make_object(). If the uset
* has commit(), it supports pending and commited (active) objects.
*/
-struct uuobj_type {
- struct uobj_type ktype;
- struct module *owner;
+struct usysfs_object_operations {
+ void (*release)(struct uobject *);
int (*allow_link)(struct uobject *src, struct uobject *target);
int (*drop_link)(struct uobject *src, struct uobject *target);
+};
+
+struct usysfs_set_operations {
struct uobject *(*make_object)(struct uset *uset, const char *name);
struct uset *(*make_set)(struct uset *uset, const char *name);
int (*commit)(struct uobject *uobj);
void (*drop_object)(struct uset *uset, struct uobject *uobj);
};
-static inline struct uuobj_type *to_uutype(struct uobj_type *ktype)
-{
- return ktype ?
- container_of(ktype, struct uuobj_type, ktype) :
- NULL;
-}
-
static inline struct uobject *usysfs_make_no_object(struct uset *uset,
const char *name)
{
More information about the Ocfs2-commits
mailing list