aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysfs
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2011-11-01 10:06:17 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-11-01 12:16:14 -0400
commitf6d90b4f9ce018bff429d6e01ee672de712b8641 (patch)
tree3fe57c005cece1d734ebb2b5dd23876fa3eb644e /fs/sysfs
parentc87d5d594736dd8b56df67e31846c7d7b8c41a8f (diff)
sysfs: Make sysfs_rename safe with sysfs_dirents in rbtrees.
In sysfs_rename we need to remove the optimization of not calling sysfs_unlink_sibling and sysfs_link_sibling if the renamed parent directory is not changing. This optimization is no longer valid now that sysfs dirents are stored in an rbtree sorted by name. Move the assignment of s_ns before the call of sysfs_link_sibling. With no sysfs_dirent fields changing after the call of sysfs_link_sibling this allows sysfs_link_sibling to take any of the directory entries into account when it builds the rbtrees, and s_ns looks like a prime canidate to be used in the rbtree in the future. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Cc: Jiri Slaby <jirislaby@gmail.com> Cc: Greg KH <gregkh@suse.de> Cc: David Miller <davem@davemloft.net> Cc: Mikulas Patocka <mpatocka@redhat.com> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/sysfs')
-rw-r--r--fs/sysfs/dir.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 48ffbdf0d017..7fdf6a7b7436 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -865,15 +865,13 @@ int sysfs_rename(struct sysfs_dirent *sd,
865 sd->s_name = new_name; 865 sd->s_name = new_name;
866 } 866 }
867 867
868 /* Remove from old parent's list and insert into new parent's list. */ 868 /* Move to the appropriate place in the appropriate directories rbtree. */
869 if (sd->s_parent != new_parent_sd) { 869 sysfs_unlink_sibling(sd);
870 sysfs_unlink_sibling(sd); 870 sysfs_get(new_parent_sd);
871 sysfs_get(new_parent_sd); 871 sysfs_put(sd->s_parent);
872 sysfs_put(sd->s_parent);
873 sd->s_parent = new_parent_sd;
874 sysfs_link_sibling(sd);
875 }
876 sd->s_ns = new_ns; 872 sd->s_ns = new_ns;
873 sd->s_parent = new_parent_sd;
874 sysfs_link_sibling(sd);
877 875
878 error = 0; 876 error = 0;
879 out: 877 out: