Commit 58f2a4c7 authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Greg Kroah-Hartman

sysfs: remove s_sibling hacks

sysfs: remove s_sibling hacks

s_sibling was used for three different purposes:
1) as a linked list of entries in the directory
2) as a linked list of entries to be deleted
3) as a pointer to "struct completion"

This patch removes the hack and introduces new union u which
holds pointers for cases 2) and 3).

This change is needed for the following patch that removes s_sibling at all
and replaces it with a rb tree.
Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 4f72c0ca
...@@ -154,7 +154,6 @@ struct sysfs_dirent *sysfs_get_active(struct sysfs_dirent *sd) ...@@ -154,7 +154,6 @@ struct sysfs_dirent *sysfs_get_active(struct sysfs_dirent *sd)
*/ */
void sysfs_put_active(struct sysfs_dirent *sd) void sysfs_put_active(struct sysfs_dirent *sd)
{ {
struct completion *cmpl;
int v; int v;
if (unlikely(!sd)) if (unlikely(!sd))
...@@ -166,10 +165,9 @@ void sysfs_put_active(struct sysfs_dirent *sd) ...@@ -166,10 +165,9 @@ void sysfs_put_active(struct sysfs_dirent *sd)
return; return;
/* atomic_dec_return() is a mb(), we'll always see the updated /* atomic_dec_return() is a mb(), we'll always see the updated
* sd->s_sibling. * sd->u.completion.
*/ */
cmpl = (void *)sd->s_sibling; complete(sd->u.completion);
complete(cmpl);
} }
/** /**
...@@ -183,16 +181,16 @@ static void sysfs_deactivate(struct sysfs_dirent *sd) ...@@ -183,16 +181,16 @@ static void sysfs_deactivate(struct sysfs_dirent *sd)
DECLARE_COMPLETION_ONSTACK(wait); DECLARE_COMPLETION_ONSTACK(wait);
int v; int v;
BUG_ON(sd->s_sibling || !(sd->s_flags & SYSFS_FLAG_REMOVED)); BUG_ON(!(sd->s_flags & SYSFS_FLAG_REMOVED));
if (!(sysfs_type(sd) & SYSFS_ACTIVE_REF)) if (!(sysfs_type(sd) & SYSFS_ACTIVE_REF))
return; return;
sd->s_sibling = (void *)&wait; sd->u.completion = (void *)&wait;
rwsem_acquire(&sd->dep_map, 0, 0, _RET_IP_); rwsem_acquire(&sd->dep_map, 0, 0, _RET_IP_);
/* atomic_add_return() is a mb(), put_active() will always see /* atomic_add_return() is a mb(), put_active() will always see
* the updated sd->s_sibling. * the updated sd->u.completion.
*/ */
v = atomic_add_return(SD_DEACTIVATED_BIAS, &sd->s_active); v = atomic_add_return(SD_DEACTIVATED_BIAS, &sd->s_active);
...@@ -201,8 +199,6 @@ static void sysfs_deactivate(struct sysfs_dirent *sd) ...@@ -201,8 +199,6 @@ static void sysfs_deactivate(struct sysfs_dirent *sd)
wait_for_completion(&wait); wait_for_completion(&wait);
} }
sd->s_sibling = NULL;
lock_acquired(&sd->dep_map, _RET_IP_); lock_acquired(&sd->dep_map, _RET_IP_);
rwsem_release(&sd->dep_map, 1, _RET_IP_); rwsem_release(&sd->dep_map, 1, _RET_IP_);
} }
...@@ -518,7 +514,7 @@ void sysfs_remove_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd) ...@@ -518,7 +514,7 @@ void sysfs_remove_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd)
} }
sd->s_flags |= SYSFS_FLAG_REMOVED; sd->s_flags |= SYSFS_FLAG_REMOVED;
sd->s_sibling = acxt->removed; sd->u.removed_list = acxt->removed;
acxt->removed = sd; acxt->removed = sd;
} }
...@@ -542,8 +538,7 @@ void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt) ...@@ -542,8 +538,7 @@ void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt)
while (acxt->removed) { while (acxt->removed) {
struct sysfs_dirent *sd = acxt->removed; struct sysfs_dirent *sd = acxt->removed;
acxt->removed = sd->s_sibling; acxt->removed = sd->u.removed_list;
sd->s_sibling = NULL;
sysfs_deactivate(sd); sysfs_deactivate(sd);
unmap_bin_file(sd); unmap_bin_file(sd);
......
...@@ -66,6 +66,11 @@ struct sysfs_dirent { ...@@ -66,6 +66,11 @@ struct sysfs_dirent {
struct rb_node name_node; struct rb_node name_node;
union {
struct completion *completion;
struct sysfs_dirent *removed_list;
} u;
const void *s_ns; /* namespace tag */ const void *s_ns; /* namespace tag */
union { union {
struct sysfs_elem_dir s_dir; struct sysfs_elem_dir s_dir;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment