[Ocfs2-commits] zab commits r1875 - trunk/fs/ocfs2/cluster
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Tue Feb 1 14:34:38 CST 2005
Author: zab
Date: 2005-02-01 14:34:36 -0600 (Tue, 01 Feb 2005)
New Revision: 1875
Modified:
trunk/fs/ocfs2/cluster/nodemanager.c
Log:
o fix a few places that were blocking while holding spin locks
- the nm_lock doesn't protect anything in nm_get_{group,node}_by_num,
factor it out
- registered nm callbacks block all over the place, protect the list of them
with a sem
Modified: trunk/fs/ocfs2/cluster/nodemanager.c
===================================================================
--- trunk/fs/ocfs2/cluster/nodemanager.c 2005-02-01 18:39:51 UTC (rev 1874)
+++ trunk/fs/ocfs2/cluster/nodemanager.c 2005-02-01 20:34:36 UTC (rev 1875)
@@ -145,7 +145,7 @@
char *nm_nodename;
EXPORT_SYMBOL(nm_nodename);
static spinlock_t nm_lock = SPIN_LOCK_UNLOCKED;
-static spinlock_t nm_cb_lock = SPIN_LOCK_UNLOCKED;
+static DECLARE_MUTEX(nm_cb_sem);
struct list_head nm_callbacks[NM_NUM_CB];
@@ -176,10 +176,6 @@
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 struct inode * __nm_get_group_by_num(u8 group_num);
-static struct inode * __nm_get_node_by_num(u8 node_num);
-
-
static u8 nm_get_group_index(struct inode *group, struct inode *inode, struct dentry **child);
#define NM_HASH_BITS 7
@@ -586,7 +582,7 @@
if (ino >= NM_INVALID_SLOT_NUM || group_num >= NM_INVALID_SLOT_NUM)
goto leave;
- inode = __nm_get_group_by_num(group_num);
+ inode = nm_get_group_by_num(group_num);
if (!inode)
goto leave;
if (list_empty(&inode->i_dentry))
@@ -804,7 +800,7 @@
ret = -EINVAL;
node_num = data->arg_u.index;
- inode = __nm_get_node_by_num(node_num);
+ inode = nm_get_node_by_num(node_num);
if (inode) {
dentry = list_entry(inode->i_dentry.next, struct dentry,
d_alias);
@@ -845,7 +841,7 @@
ret = -EINVAL;
group_num = data->arg_u.index;
- inode = __nm_get_group_by_num(group_num);
+ inode = nm_get_group_by_num(group_num);
if (inode) {
g = inode->u.generic_ip;
dentry = list_entry(inode->i_dentry.next, struct dentry,
@@ -982,7 +978,7 @@
-static struct inode * __nm_get_group_by_num(u8 group_num)
+struct inode * nm_get_group_by_num(u8 group_num)
{
struct inode *inode = iget(single_sb, group_num + NM_GROUP_INODE_START);
if (!inode)
@@ -993,8 +989,9 @@
}
return inode;
}
+EXPORT_SYMBOL(nm_get_group_by_num);
-static struct inode * __nm_get_node_by_num(u8 node_num)
+struct inode * nm_get_node_by_num(u8 node_num)
{
struct inode *inode = iget(single_sb, node_num + NM_NODE_INODE_START);
if (!inode)
@@ -1005,6 +1002,7 @@
}
return inode;
}
+EXPORT_SYMBOL(nm_get_node_by_num);
/* ipv4 only for now... */
struct inode * nm_get_node_by_ip(u32 addr)
@@ -1030,31 +1028,11 @@
}
EXPORT_SYMBOL(nm_get_node_by_ip);
-struct inode * nm_get_group_by_num(u8 group_num)
-{
- struct inode *inode;
- spin_lock(&nm_lock);
- inode = __nm_get_group_by_num(group_num);
- spin_unlock(&nm_lock);
- return inode;
-}
-EXPORT_SYMBOL(nm_get_group_by_num);
-
nm_cluster * nm_get_cluster(void)
{
return &cluster;
}
-struct inode * nm_get_node_by_num(u8 node_num)
-{
- struct inode *inode;
- spin_lock(&nm_lock);
- inode = __nm_get_node_by_num(node_num);
- spin_unlock(&nm_lock);
- return inode;
-}
-EXPORT_SYMBOL(nm_get_node_by_num);
-
struct inode * nm_get_group_node_by_index(struct inode *group, u8 index)
{
struct dentry *dentry = NULL, *parent;
@@ -1203,14 +1181,13 @@
return -ENOMEM;
memset(f, 0, sizeof(nm_callback_func));
f->func = func;
- spin_lock(&nm_cb_lock);
+ down(&nm_cb_sem);
list_add_tail(&f->list, &nm_callbacks[type]);
- spin_unlock(&nm_cb_lock);
+ up(&nm_cb_sem);
return 0;
}
EXPORT_SYMBOL(nm_register_callback);
-#warning need to change nm callbacks to be like hb callbacks... no locks when calling.
int nm_unregister_callback(int type, void (*func)(void *, void *, u8))
{
struct list_head *iter, *tmpiter;
@@ -1220,7 +1197,7 @@
if (type < NM_NODE_ADD_CB || type > NM_GROUP_NODE_DEL_CB)
return ret;
- spin_lock(&nm_cb_lock);
+ down(&nm_cb_sem);
list_for_each_safe(iter, tmpiter, &nm_callbacks[type]) {
f = list_entry (iter, nm_callback_func, list);
if (f->func == func) {
@@ -1230,7 +1207,7 @@
break;
}
}
- spin_unlock(&nm_cb_lock);
+ up(&nm_cb_sem);
return ret;
}
EXPORT_SYMBOL(nm_unregister_callback);
@@ -1240,12 +1217,12 @@
struct list_head *iter;
nm_callback_func *f;
- spin_lock(&nm_cb_lock);
+ down(&nm_cb_sem);
list_for_each(iter, &nm_callbacks[type]) {
f = list_entry (iter, nm_callback_func, list);
(f->func) (ptr1, ptr2, idx);
}
- spin_unlock(&nm_cb_lock);
+ up(&nm_cb_sem);
}
More information about the Ocfs2-commits
mailing list