]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
sysfs: implement SYSFS_FLAG_REMOVED flag
authorTejun Heo <htejun@gmail.com>
Wed, 13 Jun 2007 19:27:22 +0000 (04:27 +0900)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 11 Jul 2007 23:09:08 +0000 (16:09 -0700)
Implement SYSFS_FLAG_REMOVED flag which currently is used only to
improve sanity check in sysfs_deactivate().  The flag will be used to
make directory entries reclamiable.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/sysfs/dir.c
fs/sysfs/inode.c
include/linux/sysfs.h

index eb9bc0a8717b8b57e1905db37773a3e8a918f4f7..f2ea00683ec915cfb7af75b07956fe10e0bbddaa 100644 (file)
@@ -171,7 +171,7 @@ void sysfs_deactivate(struct sysfs_dirent *sd)
        DECLARE_COMPLETION_ONSTACK(wait);
        int v;
 
-       BUG_ON(sd->s_sibling);
+       BUG_ON(sd->s_sibling || !(sd->s_flags & SYSFS_FLAG_REMOVED));
        sd->s_sibling = (void *)&wait;
 
        /* atomic_add_return() is a mb(), put_active() will always see
@@ -506,6 +506,7 @@ static void remove_dir(struct dentry * d)
        mutex_lock(&parent->d_inode->i_mutex);
 
        sysfs_unlink_sibling(sd);
+       sd->s_flags |= SYSFS_FLAG_REMOVED;
 
        pr_debug(" o %s removing done (%d)\n",d->d_name.name,
                 atomic_read(&d->d_count));
@@ -540,6 +541,7 @@ static void __sysfs_remove_dir(struct dentry *dentry)
                struct sysfs_dirent *sd = *pos;
 
                if (sysfs_type(sd) && (sysfs_type(sd) & SYSFS_NOT_PINNED)) {
+                       sd->s_flags |= SYSFS_FLAG_REMOVED;
                        *pos = sd->s_sibling;
                        sd->s_sibling = removed;
                        removed = sd;
index ee3a5d957051a33221c1c3a61f432d40b0a5dd4e..e2f6ef138d20e4d957ad68870bdbe8a708846a55 100644 (file)
@@ -296,6 +296,7 @@ int sysfs_hash_and_remove(struct dentry * dir, const char * name)
                if (!sysfs_type(sd))
                        continue;
                if (!strcmp(sd->s_name, name)) {
+                       sd->s_flags |= SYSFS_FLAG_REMOVED;
                        *pos = sd->s_sibling;
                        sd->s_sibling = NULL;
                        found = 1;
index 58135509023e30637e554b831360c4bb4797f07d..2a6df6444e6931acf1cf283bdb6514828fc87dc0 100644 (file)
@@ -84,6 +84,7 @@ struct sysfs_ops {
 #define SYSFS_COPY_NAME                (SYSFS_DIR | SYSFS_KOBJ_LINK)
 
 #define SYSFS_FLAG_MASK                ~SYSFS_TYPE_MASK
+#define SYSFS_FLAG_REMOVED     0x0100
 
 #ifdef CONFIG_SYSFS