From: Tejun Heo <[email protected]> Replace sysfs_lock and kobj_sysfs_assoc_lock with sysfs_assoc_lock. sysfs_lock was originally to be used to protect sysfs_dirent tree but mutex seems better choice, so there is no reason to keep sysfs_lock separate. Merge the two spinlocks into one. Signed-off-by: Tejun Heo <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> --- fs/sysfs/dir.c | 19 +++++++++---------- fs/sysfs/inode.c | 16 ++++++++-------- fs/sysfs/symlink.c | 6 +++--- fs/sysfs/sysfs.h | 3 +-- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index 31b6cf3..1b56434 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c @@ -15,8 +15,7 @@ #include "sysfs.h" DECLARE_RWSEM(sysfs_rename_sem); -spinlock_t sysfs_lock = SPIN_LOCK_UNLOCKED; -spinlock_t kobj_sysfs_assoc_lock = SPIN_LOCK_UNLOCKED; +spinlock_t sysfs_assoc_lock = SPIN_LOCK_UNLOCKED; static spinlock_t sysfs_ino_lock = SPIN_LOCK_UNLOCKED; static DEFINE_IDA(sysfs_ino_ida); @@ -236,10 +235,10 @@ static void sysfs_d_iput(struct dentry * dentry, struct inode * inode) struct sysfs_dirent * sd = dentry->d_fsdata; if (sd) { - /* sd->s_dentry is protected with sysfs_lock. This - * allows sysfs_drop_dentry() to dereference it. + /* sd->s_dentry is protected with sysfs_assoc_lock. + * This allows sysfs_drop_dentry() to dereference it. */ - spin_lock(&sysfs_lock); + spin_lock(&sysfs_assoc_lock); /* The dentry might have been deleted or another * lookup could have happened updating sd->s_dentry to @@ -248,7 +247,7 @@ static void sysfs_d_iput(struct dentry * dentry, struct inode * inode) */ if (sd->s_dentry == dentry) sd->s_dentry = NULL; - spin_unlock(&sysfs_lock); + spin_unlock(&sysfs_assoc_lock); sysfs_put(sd); } iput(inode); @@ -298,9 +297,9 @@ static void sysfs_attach_dentry(struct sysfs_dirent *sd, struct dentry *dentry) dentry->d_fsdata = sysfs_get(sd); /* protect sd->s_dentry against sysfs_d_iput */ - spin_lock(&sysfs_lock); + spin_lock(&sysfs_assoc_lock); sd->s_dentry = dentry; - spin_unlock(&sysfs_lock); + spin_unlock(&sysfs_assoc_lock); d_rehash(dentry); } @@ -603,9 +602,9 @@ void sysfs_remove_dir(struct kobject * kobj) { struct sysfs_dirent *sd = kobj->sd; - spin_lock(&kobj_sysfs_assoc_lock); + spin_lock(&sysfs_assoc_lock); kobj->sd = NULL; - spin_unlock(&kobj_sysfs_assoc_lock); + spin_unlock(&sysfs_assoc_lock); __sysfs_remove_dir(sd); } diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c index 1be8537..e4c2393 100644 --- a/fs/sysfs/inode.c +++ b/fs/sysfs/inode.c @@ -211,11 +211,11 @@ void sysfs_instantiate(struct dentry *dentry, struct inode *inode) * parent on entry to this function such that it can't be looked * up anymore. * - * @sd->s_dentry which is protected with sysfs_lock points to the - * currently associated dentry but we're not holding a reference - * to it and racing with dput(). Grab dcache_lock and verify - * dentry before dropping it. If @sd->s_dentry is NULL or dput() - * beats us, no need to bother. + * @sd->s_dentry which is protected with sysfs_assoc_lock points + * to the currently associated dentry but we're not holding a + * reference to it and racing with dput(). Grab dcache_lock and + * verify dentry before dropping it. If @sd->s_dentry is NULL or + * dput() beats us, no need to bother. */ void sysfs_drop_dentry(struct sysfs_dirent *sd) { @@ -224,9 +224,9 @@ void sysfs_drop_dentry(struct sysfs_dirent *sd) struct inode *inode; /* We're not holding a reference to ->s_dentry dentry but the - * field will stay valid as long as sysfs_lock is held. + * field will stay valid as long as sysfs_assoc_lock is held. */ - spin_lock(&sysfs_lock); + spin_lock(&sysfs_assoc_lock); spin_lock(&dcache_lock); /* drop dentry if it's there and dput() didn't kill it yet */ @@ -238,7 +238,7 @@ void sysfs_drop_dentry(struct sysfs_dirent *sd) } spin_unlock(&dcache_lock); - spin_unlock(&sysfs_lock); + spin_unlock(&sysfs_assoc_lock); dput(dentry); /* XXX: unpin if directory, this will go away soon */ diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c index 43cc522..cbd95a4 100644 --- a/fs/sysfs/symlink.c +++ b/fs/sysfs/symlink.c @@ -82,12 +82,12 @@ int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char return -EFAULT; /* target->sd can go away beneath us but is protected with - * kobj_sysfs_assoc_lock. Fetch target_sd from it. + * sysfs_assoc_lock. Fetch target_sd from it. */ - spin_lock(&kobj_sysfs_assoc_lock); + spin_lock(&sysfs_assoc_lock); if (target->sd) target_sd = sysfs_get(target->sd); - spin_unlock(&kobj_sysfs_assoc_lock); + spin_unlock(&sysfs_assoc_lock); if (!target_sd) return -ENOENT; diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h index 27a5f4b..4572677 100644 --- a/fs/sysfs/sysfs.h +++ b/fs/sysfs/sysfs.h @@ -81,8 +81,7 @@ extern void sysfs_remove_subdir(struct sysfs_dirent *sd); extern void sysfs_drop_dentry(struct sysfs_dirent *sd); extern int sysfs_setattr(struct dentry *dentry, struct iattr *iattr); -extern spinlock_t sysfs_lock; -extern spinlock_t kobj_sysfs_assoc_lock; +extern spinlock_t sysfs_assoc_lock; extern struct rw_semaphore sysfs_rename_sem; extern struct super_block * sysfs_sb; extern const struct file_operations sysfs_dir_operations; -- 1.5.2.2 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
- Follow-Ups:
- [PATCH 56/61] sysfs: use sysfs_mutex to protect the sysfs_dirent tree
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 56/61] sysfs: use sysfs_mutex to protect the sysfs_dirent tree
- References:
- [GIT PATCH] sysfs and driver core patches for 2.6.22
- From: Greg KH <[email protected]>
- [PATCH 01/61] Rules on how to use sysfs in userspace programs
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 02/61] debugfs: add rename for debugfs files
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 03/61] DMI-based module autoloading
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 04/61] Driver core: add missing kset uevent
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 05/61] sysdev: use mutex instead of semaphore
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 06/61] Power Management: use mutexes instead of semaphores
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 07/61] PM: Remove pm_parent from struct dev_pm_info
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 08/61] PM: Remove saved_state from struct dev_pm_info
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 09/61] PM: Simplify suspend_device
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 10/61] Driver core: include linux/mutex.h from attribute_container.c
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 11/61] driver core: properly get driver in device_release_driver
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 12/61] driver core: fix kernel doc of device_release_driver
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 13/61] Driver core: fix devres_release_all() return value
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 14/61] PM: Remove prev_state from struct dev_pm_info
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 15/61] PM: Remove power_state.event checks from suspend core code
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 16/61] PM: Do not check parent state in suspend and resume core code
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 17/61] PM: do not use saved_state from struct dev_pm_info on ARM
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 18/61] Driver core: coding style cleanup
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 19/61] idr: fix obscure bug in allocation path
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 20/61] idr: separate out idr_mark_full()
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 21/61] ida: implement idr based id allocator
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 22/61] sysfs: move release_sysfs_dirent() to dir.c
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 23/61] sysfs: allocate inode number using ida
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 24/61] sysfs: make sysfs_put() ignore NULL sd
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 25/61] sysfs: fix error handling in binattr write()
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 26/61] sysfs: flatten cleanup paths in sysfs_add_link() and create_dir()
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 27/61] sysfs: flatten and fix sysfs_rename_dir() error handling
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 28/61] sysfs: consolidate sysfs_dirent creation functions
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 29/61] sysfs: add sysfs_dirent->s_parent
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 30/61] sysfs: add sysfs_dirent->s_name
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 31/61] sysfs: make sysfs_dirent->s_element a union
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 32/61] sysfs: implement kobj_sysfs_assoc_lock
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 33/61] sysfs: reimplement symlink using sysfs_dirent tree
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 34/61] sysfs: implement bin_buffer
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 35/61] sysfs: implement sysfs_dirent active reference and immediate disconnect
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 36/61] sysfs: kill attribute file orphaning
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 37/61] sysfs: separate out sysfs_attach_dentry()
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 38/61] sysfs: reimplement sysfs_drop_dentry()
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 39/61] sysfs: kill unnecessary attribute->owner
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 40/61] driver-core: make devt_attr and uevent_attr static
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 41/61] sysfs: make sysfs_alloc_ino() static
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 42/61] sysfs: fix parent refcounting during rename and move
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 43/61] sysfs: reorganize sysfs_new_indoe() and sysfs_create()
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 44/61] sysfs: use iget_locked() instead of new_inode()
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 45/61] sysfs: fix root sysfs_dirent -> root dentry association
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 46/61] sysfs: move s_active functions to fs/sysfs/dir.c
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 47/61] sysfs: slim down sysfs_dirent->s_active
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 48/61] sysfs: use singly-linked list for sysfs_dirent tree
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 49/61] sysfs: Fix oops in sysfs_drop_dentry on x86_64
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 50/61] sysfs: make sysfs_drop_dentry() access inodes using ilookup()
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 51/61] sysfs: rename sysfs_dirent->s_type to s_flags and make room for flags
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 52/61] sysfs: implement SYSFS_FLAG_REMOVED flag
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 53/61] sysfs: implement sysfs_find_dirent() and sysfs_get_dirent()
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 54/61] sysfs: make kobj point to sysfs_dirent instead of dentry
- From: Greg Kroah-Hartman <[email protected]>
- [GIT PATCH] sysfs and driver core patches for 2.6.22
- Prev by Date: [PATCH 54/61] sysfs: make kobj point to sysfs_dirent instead of dentry
- Next by Date: [PATCH 56/61] sysfs: use sysfs_mutex to protect the sysfs_dirent tree
- Previous by thread: [PATCH 54/61] sysfs: make kobj point to sysfs_dirent instead of dentry
- Next by thread: [PATCH 56/61] sysfs: use sysfs_mutex to protect the sysfs_dirent tree
- Index(es):