From: Tejun Heo <htejun@gmail.com>
To: gregkh@suse.de, maneesh@in.ibm.com, dmitry.torokhov@gmail.com,
cornelia.huck@de.ibm.com, oneukum@suse.de, rpurdie@rpsys.net,
James.Bottomley@SteelEye.com, linux-kernel@vger.kernel.org,
htejun@gmail.com
Cc: Tejun Heo <htejun@gmail.com>
Subject: [PATCH 09/14] sysfs: implement kobj_sysfs_assoc_lock
Date: Sat, 7 Apr 2007 17:23:47 +0900 [thread overview]
Message-ID: <11759342272795-git-send-email-htejun@gmail.com> (raw)
In-Reply-To: <1175934226928-git-send-email-htejun@gmail.com>
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>
---
fs/sysfs/dir.c | 8 +++++++-
fs/sysfs/sysfs.h | 1 +
2 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index d70ead5..8372c0c 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -13,6 +13,7 @@
#include "sysfs.h"
DECLARE_RWSEM(sysfs_rename_sem);
+spinlock_t kobj_sysfs_assoc_lock = SPIN_LOCK_UNLOCKED;
struct kobject *sysfs_get_kobject(struct dentry *dentry)
{
@@ -388,8 +389,13 @@ static void __sysfs_remove_dir(struct dentry *dentry)
void sysfs_remove_dir(struct kobject * kobj)
{
- __sysfs_remove_dir(kobj->dentry);
+ struct dentry *d = kobj->dentry;
+
+ spin_lock(&kobj_sysfs_assoc_lock);
kobj->dentry = NULL;
+ spin_unlock(&kobj_sysfs_assoc_lock);
+
+ __sysfs_remove_dir(d);
}
int sysfs_rename_dir(struct kobject * kobj, struct dentry *new_parent,
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index c1965b9..9dcd0b0 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -61,6 +61,7 @@ extern void sysfs_remove_subdir(struct dentry *);
extern void sysfs_drop_dentry(struct sysfs_dirent *sd, struct dentry *parent);
extern int sysfs_setattr(struct dentry *dentry, struct iattr *iattr);
+extern spinlock_t kobj_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.0.3
next prev parent reply other threads:[~2007-04-07 8:26 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-07 8:23 [PATCHSET #master] sysfs: make sysfs disconnect immediately from kobject on deletion Tejun Heo
2007-04-07 8:23 ` [PATCH 03/14] sysfs: move sysfs_get_kobject() and release_sysfs_dirent() to dir.c Tejun Heo
2007-04-07 8:23 ` [PATCH 02/14] sysfs: fix error handling in binattr write() Tejun Heo
2007-04-07 8:23 ` [PATCH 01/14] sysfs: fix i_ino handling in sysfs Tejun Heo
2007-04-07 8:23 ` Tejun Heo [this message]
2007-04-07 8:23 ` [PATCH 04/14] sysfs: flatten cleanup paths in sysfs_add_link() and create_dir() Tejun Heo
2007-04-07 8:23 ` [PATCH 10/14] sysfs: reimplement symlink using sysfs_dirent tree Tejun Heo
2007-04-07 8:23 ` [PATCH 06/14] sysfs: add sysfs_dirent->s_parent Tejun Heo
2007-04-07 8:23 ` [PATCH 08/14] sysfs: make sysfs_dirent->s_element a union Tejun Heo
2007-04-07 8:23 ` [PATCH 07/14] sysfs: add sysfs_dirent->s_name Tejun Heo
2007-04-07 8:23 ` [PATCH 05/14] sysfs: consolidate sysfs_dirent creation functions Tejun Heo
2007-04-07 8:23 ` [PATCH 13/14] sysfs: kill attribute file orphaning Tejun Heo
2007-04-08 2:18 ` Tejun Heo
2007-04-07 8:23 ` [PATCH 11/14] sysfs: implement bin_buffer Tejun Heo
2007-04-07 8:23 ` [PATCH 12/14] sysfs: implement immediate kobject disconnect Tejun Heo
2007-04-07 8:23 ` [PATCH 14/14] sysfs: kill unnecessary attribute->owner Tejun Heo
-- strict thread matches above, loose matches on Subject: below --
2007-04-09 4:18 [PATCHSET #master] sysfs: make sysfs disconnect immediately on deletion, take 2 Tejun Heo
2007-04-09 4:18 ` [PATCH 09/14] sysfs: implement kobj_sysfs_assoc_lock Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11759342272795-git-send-email-htejun@gmail.com \
--to=htejun@gmail.com \
--cc=James.Bottomley@SteelEye.com \
--cc=cornelia.huck@de.ibm.com \
--cc=dmitry.torokhov@gmail.com \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=maneesh@in.ibm.com \
--cc=oneukum@suse.de \
--cc=rpurdie@rpsys.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox