]> git.hungrycats.org Git - linux/commitdiff
[PATCH] back out sysfs reference count change
authorGreg Kroah-Hartman <greg@kroah.com>
Tue, 30 Mar 2004 08:53:19 +0000 (00:53 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Tue, 30 Mar 2004 08:53:19 +0000 (00:53 -0800)
This backs out Maneesh's sysfs patch that was recently added to the
kernel.

In its defense, the original patch did solve some fixes that could be
duplicated on SMP machines, but the side affect of the patch caused lots
of problems.  Basically it caused kobjects to get their references
incremented when files that are not present in the kobject are asked for
(udev can easily trigger this when it looks for files call "dev" in
directories that do not have that file).  This can cause easy oopses
when the VFS later ages out those old dentries and the kobject has its
reference finally released (usually after the module that the kobject
lived in was removed.)

I will continue to work with Maneesh to try to solve the original bug,
but for now, this patch needs to be applied.

fs/sysfs/dir.c

index c383f5a4986d45b35a76656c105bbfaca53ba79b..add2045e8c2585801db7b9107dc9c00e870af941 100644 (file)
@@ -20,18 +20,6 @@ static int init_dir(struct inode * inode)
        return 0;
 }
 
-static void sysfs_d_iput(struct dentry * dentry, struct inode * inode)
-{
-       struct kobject * kobj = dentry->d_fsdata;
-
-       if (kobj)
-               kobject_put(kobj);
-       iput(inode);
-}
-
-static struct dentry_operations sysfs_dentry_operations = {
-       .d_iput = &sysfs_d_iput,
-};
 
 static int create_dir(struct kobject * k, struct dentry * p,
                      const char * n, struct dentry ** d)
@@ -45,8 +33,7 @@ static int create_dir(struct kobject * k, struct dentry * p,
                                         S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO,
                                         init_dir);
                if (!error) {
-                       (*d)->d_op = &sysfs_dentry_operations;
-                       (*d)->d_fsdata = kobject_get(k);
+                       (*d)->d_fsdata = k;
                        p->d_inode->i_nlink++;
                }
                dput(*d);