aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-06-13 14:45:15 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-07-11 19:09:04 -0400
commitaecdcedaab49ca40620dc7dd70f67ee7269a66c9 (patch)
treedf1faa0302e6fb428b7ae0a14d443626fd73b121
parent3e5190380ebef77f2b015c9e7a4ca225a3d75021 (diff)
sysfs: implement kobj_sysfs_assoc_lock
kobj->dentry can go away anytime unless the user controls when the associated sysfs node is deleted. This patch implements kobj_sysfs_assoc_lock which protects kobj->dentry. This will be used to maintain kobj based API when converting sysfs to use sysfs_dirent tree instead of dentry/kobject. Note that this lock belongs to kobject/driver-model not sysfs. Once sysfs is converted to not use kobject in its interface, this can be removed from sysfs. This is in preparation of object reference simplification. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--fs/sysfs/dir.c8
-rw-r--r--fs/sysfs/sysfs.h1
2 files changed, 8 insertions, 1 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 079122695675..e9fddcc59447 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -15,6 +15,7 @@
15 15
16DECLARE_RWSEM(sysfs_rename_sem); 16DECLARE_RWSEM(sysfs_rename_sem);
17spinlock_t sysfs_lock = SPIN_LOCK_UNLOCKED; 17spinlock_t sysfs_lock = SPIN_LOCK_UNLOCKED;
18spinlock_t kobj_sysfs_assoc_lock = SPIN_LOCK_UNLOCKED;
18 19
19static spinlock_t sysfs_ino_lock = SPIN_LOCK_UNLOCKED; 20static spinlock_t sysfs_ino_lock = SPIN_LOCK_UNLOCKED;
20static DEFINE_IDA(sysfs_ino_ida); 21static DEFINE_IDA(sysfs_ino_ida);
@@ -426,8 +427,13 @@ static void __sysfs_remove_dir(struct dentry *dentry)
426 427
427void sysfs_remove_dir(struct kobject * kobj) 428void sysfs_remove_dir(struct kobject * kobj)
428{ 429{
429 __sysfs_remove_dir(kobj->dentry); 430 struct dentry *d = kobj->dentry;
431
432 spin_lock(&kobj_sysfs_assoc_lock);
430 kobj->dentry = NULL; 433 kobj->dentry = NULL;
434 spin_unlock(&kobj_sysfs_assoc_lock);
435
436 __sysfs_remove_dir(d);
431} 437}
432 438
433int sysfs_rename_dir(struct kobject * kobj, struct dentry *new_parent, 439int sysfs_rename_dir(struct kobject * kobj, struct dentry *new_parent,
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 39ab0481379c..718e2e123fae 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -62,6 +62,7 @@ extern void sysfs_drop_dentry(struct sysfs_dirent *sd, struct dentry *parent);
62extern int sysfs_setattr(struct dentry *dentry, struct iattr *iattr); 62extern int sysfs_setattr(struct dentry *dentry, struct iattr *iattr);
63 63
64extern spinlock_t sysfs_lock; 64extern spinlock_t sysfs_lock;
65extern spinlock_t kobj_sysfs_assoc_lock;
65extern struct rw_semaphore sysfs_rename_sem; 66extern struct rw_semaphore sysfs_rename_sem;
66extern struct super_block * sysfs_sb; 67extern struct super_block * sysfs_sb;
67extern const struct file_operations sysfs_dir_operations; 68extern const struct file_operations sysfs_dir_operations;