]> git.baikalelectronics.ru Git - kernel.git/commit
sysfs: rename sysfs_assoc_lock and explain what it's about
authorTejun Heo <tj@kernel.org>
Wed, 30 Oct 2013 14:28:36 +0000 (10:28 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Nov 2013 19:13:37 +0000 (12:13 -0700)
commit1e2cbdacf1ae6175ac717ae2601b2a1652ebc885
tree56746a582c79df11a88fe0016ea4919c018d5553
parent60d24323c9eda756c3e308782d1538204aae743e
sysfs: rename sysfs_assoc_lock and explain what it's about

sysfs_assoc_lock is an odd piece of locking.  In general, whoever owns
a kobject is responsible for synchronizing sysfs operations and sysfs
proper assumes that, for example, removal won't race with any other
operation; however, this doesn't work for symlinking because an entity
performing symlink doesn't usually own the target kobject and thus has
no control over its removal.

sysfs_assoc_lock synchronizes symlink operations against kobj->sd
disassociation so that symlink code doesn't end up dereferencing
already freed sysfs_dirent by racing with removal of the target
kobject.

This is quite obscure and the generic name of the lock and lack of
comments make it difficult to understand its role.  Let's rename it to
sysfs_symlink_target_lock and add comments explaining what's going on.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/sysfs/dir.c
fs/sysfs/symlink.c
fs/sysfs/sysfs.h