]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
procfs-improve-scaling-in-proc-v5
authorNathan Zimmer <nzimmer@sgi.com>
Sun, 10 Mar 2013 10:55:18 +0000 (21:55 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 12 Mar 2013 03:57:30 +0000 (14:57 +1100)
v5: Corrected some warnings from sparce including the supplied by Sasha.

Signed-off-by: Nathan Zimmer <nzimmer@sgi.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/proc/inode.c

index 6cccc4d7a106ee68fb0e966c6fcaad0e06ea2d8e..f53660a471c2f14a70edef2786efde17fe26aa6c 100644 (file)
@@ -284,7 +284,7 @@ static long proc_reg_compat_ioctl(struct file *file, unsigned int cmd, unsigned
                return rv;
        }
        atomic_inc(&pde->pde_users);
-       compat_ioctl = pde->proc_fops->compat_ioctl;
+       compat_ioctl = fops->compat_ioctl;
        rcu_read_unlock();
 
        if (compat_ioctl)
@@ -309,7 +309,7 @@ static int proc_reg_mmap(struct file *file, struct vm_area_struct *vma)
                return rv;
        }
        atomic_inc(&pde->pde_users);
-       mmap = pde->proc_fops->mmap;
+       mmap = fops->mmap;
        rcu_read_unlock();
 
        if (mmap)
@@ -352,7 +352,7 @@ static int proc_reg_open(struct inode *inode, struct file *file)
        atomic_inc(&pde->pde_users);
        open = fops->open;
        release = fops->release;
-       rcu_read_lock();
+       rcu_read_unlock();
 
        if (open)
                rv = open(inode, file);
@@ -400,6 +400,7 @@ static int proc_reg_release(struct inode *inode, struct file *file)
        rcu_read_lock();
        fops = rcu_dereference(pde->proc_fops);
        if (!fops) {
+               rcu_read_unlock();
                /*
                 * Can't simply exit, __fput() will think that everything is OK,
                 * and move on to freeing struct file. remove_proc_entry() will
@@ -464,6 +465,7 @@ static const struct file_operations proc_reg_file_ops_no_compat = {
 struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
 {
        struct inode *inode = iget_locked(sb, de->low_ino);
+       const struct file_operations *fops;
 
        if (inode && (inode->i_state & I_NEW)) {
                inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
@@ -480,19 +482,22 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
                        set_nlink(inode, de->nlink);
                if (de->proc_iops)
                        inode->i_op = de->proc_iops;
-               if (de->proc_fops) {
+               rcu_read_lock();
+               fops = rcu_dereference(de->proc_fops);
+               if (fops) {
                        if (S_ISREG(inode->i_mode)) {
 #ifdef CONFIG_COMPAT
-                               if (!de->proc_fops->compat_ioctl)
+                               if (!fops->compat_ioctl)
                                        inode->i_fop =
                                                &proc_reg_file_ops_no_compat;
                                else
 #endif
                                        inode->i_fop = &proc_reg_file_ops;
                        } else {
-                               inode->i_fop = de->proc_fops;
+                               inode->i_fop = fops;
                        }
                }
+               rcu_read_unlock();
                unlock_new_inode(inode);
        } else
               pde_put(de);