Revert "kernfs: remove KERNFS_ACTIVE_REF and add kernfs_lockdep()"
This reverts commit a69d001cfc
.
Tejun writes:
I'm sorry but can you please revert the whole series?
get_active() waiting while a node is deactivated has potential
to lead to deadlock and that deactivate/reactivate interface is
something fundamentally flawed and that cgroup will have to work
with the remove_self() like everybody else. IOW, I think the
first posting was correct.
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
798c75a0d4
commit
0890147fe0
2 changed files with 12 additions and 20 deletions
|
@ -22,15 +22,6 @@ DEFINE_MUTEX(kernfs_mutex);
|
||||||
|
|
||||||
#define rb_to_kn(X) rb_entry((X), struct kernfs_node, rb)
|
#define rb_to_kn(X) rb_entry((X), struct kernfs_node, rb)
|
||||||
|
|
||||||
static bool kernfs_lockdep(struct kernfs_node *kn)
|
|
||||||
{
|
|
||||||
#ifdef CONFIG_DEBUG_LOCK_ALLOC
|
|
||||||
return kn->flags & KERNFS_LOCKDEP;
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* kernfs_name_hash
|
* kernfs_name_hash
|
||||||
* @name: Null terminated string to hash
|
* @name: Null terminated string to hash
|
||||||
|
@ -147,7 +138,7 @@ struct kernfs_node *kernfs_get_active(struct kernfs_node *kn)
|
||||||
if (!atomic_inc_unless_negative(&kn->active))
|
if (!atomic_inc_unless_negative(&kn->active))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (kernfs_lockdep(kn))
|
if (kn->flags & KERNFS_LOCKDEP)
|
||||||
rwsem_acquire_read(&kn->dep_map, 0, 1, _RET_IP_);
|
rwsem_acquire_read(&kn->dep_map, 0, 1, _RET_IP_);
|
||||||
return kn;
|
return kn;
|
||||||
}
|
}
|
||||||
|
@ -167,7 +158,7 @@ void kernfs_put_active(struct kernfs_node *kn)
|
||||||
if (unlikely(!kn))
|
if (unlikely(!kn))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (kernfs_lockdep(kn))
|
if (kn->flags & KERNFS_LOCKDEP)
|
||||||
rwsem_release(&kn->dep_map, 1, _RET_IP_);
|
rwsem_release(&kn->dep_map, 1, _RET_IP_);
|
||||||
v = atomic_dec_return(&kn->active);
|
v = atomic_dec_return(&kn->active);
|
||||||
if (likely(v != KN_DEACTIVATED_BIAS))
|
if (likely(v != KN_DEACTIVATED_BIAS))
|
||||||
|
@ -188,22 +179,22 @@ static void kernfs_deactivate(struct kernfs_node *kn)
|
||||||
|
|
||||||
BUG_ON(!(kn->flags & KERNFS_REMOVED));
|
BUG_ON(!(kn->flags & KERNFS_REMOVED));
|
||||||
|
|
||||||
|
if (!(kernfs_type(kn) & KERNFS_ACTIVE_REF))
|
||||||
|
return;
|
||||||
|
|
||||||
|
rwsem_acquire(&kn->dep_map, 0, 0, _RET_IP_);
|
||||||
|
|
||||||
atomic_add(KN_DEACTIVATED_BIAS, &kn->active);
|
atomic_add(KN_DEACTIVATED_BIAS, &kn->active);
|
||||||
|
|
||||||
if (kernfs_lockdep(kn)) {
|
|
||||||
rwsem_acquire(&kn->dep_map, 0, 0, _RET_IP_);
|
|
||||||
if (atomic_read(&kn->active) != KN_DEACTIVATED_BIAS)
|
if (atomic_read(&kn->active) != KN_DEACTIVATED_BIAS)
|
||||||
lock_contended(&kn->dep_map, _RET_IP_);
|
lock_contended(&kn->dep_map, _RET_IP_);
|
||||||
}
|
|
||||||
|
|
||||||
wait_event(root->deactivate_waitq,
|
wait_event(root->deactivate_waitq,
|
||||||
atomic_read(&kn->active) == KN_DEACTIVATED_BIAS);
|
atomic_read(&kn->active) == KN_DEACTIVATED_BIAS);
|
||||||
|
|
||||||
if (kernfs_lockdep(kn)) {
|
|
||||||
lock_acquired(&kn->dep_map, _RET_IP_);
|
lock_acquired(&kn->dep_map, _RET_IP_);
|
||||||
rwsem_release(&kn->dep_map, 1, _RET_IP_);
|
rwsem_release(&kn->dep_map, 1, _RET_IP_);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* kernfs_get - get a reference count on a kernfs_node
|
* kernfs_get - get a reference count on a kernfs_node
|
||||||
|
|
|
@ -34,6 +34,7 @@ enum kernfs_node_type {
|
||||||
};
|
};
|
||||||
|
|
||||||
#define KERNFS_TYPE_MASK 0x000f
|
#define KERNFS_TYPE_MASK 0x000f
|
||||||
|
#define KERNFS_ACTIVE_REF KERNFS_FILE
|
||||||
#define KERNFS_FLAG_MASK ~KERNFS_TYPE_MASK
|
#define KERNFS_FLAG_MASK ~KERNFS_TYPE_MASK
|
||||||
|
|
||||||
enum kernfs_node_flag {
|
enum kernfs_node_flag {
|
||||||
|
|
Loading…
Add table
Reference in a new issue