]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/autofs4/root.c
[PATCH] autofs4: lookup white space cleanup
[linux-2.6-omap-h63xx.git] / fs / autofs4 / root.c
index 2241405ffc413a49035cad0085be9c481c325165..2c676bd44acdcc910a721b2bf75154fd43b2c450 100644 (file)
@@ -12,6 +12,7 @@
  *
  * ------------------------------------------------------------------------- */
 
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/stat.h>
 #include <linux/param.h>
@@ -86,7 +87,7 @@ static int autofs4_root_readdir(struct file *file, void *dirent,
 
 /* Update usage from here to top of tree, so that scan of
    top-level directories will give a useful result */
-static void autofs4_update_usage(struct dentry *dentry)
+static void autofs4_update_usage(struct vfsmount *mnt, struct dentry *dentry)
 {
        struct dentry *top = dentry->d_sb->s_root;
 
@@ -95,7 +96,7 @@ static void autofs4_update_usage(struct dentry *dentry)
                struct autofs_info *ino = autofs4_dentry_ino(dentry);
 
                if (ino) {
-                       update_atime(dentry->d_inode);
+                       touch_atime(mnt, dentry);
                        ino->last_used = jiffies;
                }
        }
@@ -194,6 +195,8 @@ static int autofs4_dir_open(struct inode *inode, struct file *file)
                if (!empty)
                        d_invalidate(dentry);
 
+               nd.dentry = dentry;
+               nd.mnt = mnt;
                nd.flags = LOOKUP_DIRECTORY;
                status = (dentry->d_op->d_revalidate)(dentry, &nd);
 
@@ -289,24 +292,24 @@ out:
        return autofs4_dcache_readdir(file, dirent, filldir);
 }
 
-static int try_to_fill_dentry(struct dentry *dentry, 
-                             struct super_block *sb,
-                             struct autofs_sb_info *sbi, int flags)
+static int try_to_fill_dentry(struct vfsmount *mnt, struct dentry *dentry, int flags)
 {
-       struct autofs_info *de_info = autofs4_dentry_ino(dentry);
+       struct super_block *sb = mnt->mnt_sb;
+       struct autofs_sb_info *sbi = autofs4_sbi(sb);
+       struct autofs_info *ino = autofs4_dentry_ino(dentry);
        int status = 0;
 
        /* Block on any pending expiry here; invalidate the dentry
            when expiration is done to trigger mount request with a new
            dentry */
-       if (de_info && (de_info->flags & AUTOFS_INF_EXPIRING)) {
+       if (ino && (ino->flags & AUTOFS_INF_EXPIRING)) {
                DPRINTK("waiting for expire %p name=%.*s",
                         dentry, dentry->d_name.len, dentry->d_name.name);
 
                status = autofs4_wait(sbi, dentry, NFY_NONE);
-               
+
                DPRINTK("expire done status=%d", status);
-               
+
                /*
                 * If the directory still exists the mount request must
                 * continue otherwise it can't be followed at the right
@@ -320,18 +323,21 @@ static int try_to_fill_dentry(struct dentry *dentry,
        DPRINTK("dentry=%p %.*s ino=%p",
                 dentry, dentry->d_name.len, dentry->d_name.name, dentry->d_inode);
 
-       /* Wait for a pending mount, triggering one if there isn't one already */
+       /*
+        * Wait for a pending mount, triggering one if there
+        * isn't one already
+        */
        if (dentry->d_inode == NULL) {
                DPRINTK("waiting for mount name=%.*s",
                         dentry->d_name.len, dentry->d_name.name);
 
                status = autofs4_wait(sbi, dentry, NFY_MOUNT);
-                
+
                DPRINTK("mount done status=%d", status);
 
                if (status && dentry->d_inode)
                        return 0; /* Try to get the kernel to invalidate this dentry */
-               
+
                /* Turn this into a real negative dentry? */
                if (status == -ENOENT) {
                        dentry->d_time = jiffies + AUTOFS_NEGATIVE_TIMEOUT;
@@ -364,10 +370,12 @@ static int try_to_fill_dentry(struct dentry *dentry,
                }
        }
 
-       /* We don't update the usages for the autofs daemon itself, this
-          is necessary for recursive autofs mounts */
+       /*
+        * We don't update the usages for the autofs daemon itself, this
+        * is necessary for recursive autofs mounts
+        */
        if (!autofs4_oz_mode(sbi))
-               autofs4_update_usage(dentry);
+               autofs4_update_usage(mnt, dentry);
 
        spin_lock(&dentry->d_lock);
        dentry->d_flags &= ~DCACHE_AUTOFS_PENDING;
@@ -381,9 +389,9 @@ static int try_to_fill_dentry(struct dentry *dentry,
  * yet completely filled in, and revalidate has to delay such
  * lookups..
  */
-static int autofs4_revalidate(struct dentry * dentry, struct nameidata *nd)
+static int autofs4_revalidate(struct dentry *dentry, struct nameidata *nd)
 {
-       struct inode * dir = dentry->d_parent->d_inode;
+       struct inode *dir = dentry->d_parent->d_inode;
        struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb);
        int oz_mode = autofs4_oz_mode(sbi);
        int flags = nd ? nd->flags : 0;
@@ -392,7 +400,7 @@ static int autofs4_revalidate(struct dentry * dentry, struct nameidata *nd)
        /* Pending dentry */
        if (autofs4_ispending(dentry)) {
                if (!oz_mode)
-                       status = try_to_fill_dentry(dentry, dir->i_sb, sbi, flags);
+                       status = try_to_fill_dentry(nd->mnt, dentry, flags);
                return status;
        }
 
@@ -409,14 +417,14 @@ static int autofs4_revalidate(struct dentry * dentry, struct nameidata *nd)
                         dentry, dentry->d_name.len, dentry->d_name.name);
                spin_unlock(&dcache_lock);
                if (!oz_mode)
-                       status = try_to_fill_dentry(dentry, dir->i_sb, sbi, flags);
+                       status = try_to_fill_dentry(nd->mnt, dentry, flags);
                return status;
        }
        spin_unlock(&dcache_lock);
 
        /* Update the usage list */
        if (!oz_mode)
-               autofs4_update_usage(dentry);
+               autofs4_update_usage(nd->mnt, dentry);
 
        return 1;
 }
@@ -459,12 +467,13 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s
        DPRINTK("name = %.*s",
                dentry->d_name.len, dentry->d_name.name);
 
+       /* File name too long to exist */
        if (dentry->d_name.len > NAME_MAX)
-               return ERR_PTR(-ENAMETOOLONG);/* File name too long to exist */
+               return ERR_PTR(-ENAMETOOLONG);
 
        sbi = autofs4_sbi(dir->i_sb);
-
        oz_mode = autofs4_oz_mode(sbi);
+
        DPRINTK("pid = %u, pgrp = %u, catatonic = %d, oz_mode = %d",
                 current->pid, process_group(current), sbi->catatonic, oz_mode);
 
@@ -489,9 +498,9 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s
        d_add(dentry, NULL);
 
        if (dentry->d_op && dentry->d_op->d_revalidate) {
-               up(&dir->i_sem);
+               mutex_unlock(&dir->i_mutex);
                (dentry->d_op->d_revalidate)(dentry, nd);
-               down(&dir->i_sem);
+               mutex_lock(&dir->i_mutex);
        }
 
        /*
@@ -516,7 +525,7 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s
         * doesn't do the right thing for all system calls, but it should
         * be OK for the operations we permit from an autofs.
         */
-       if ( dentry->d_inode && d_unhashed(dentry) )
+       if (dentry->d_inode && d_unhashed(dentry))
                return ERR_PTR(-ENOENT);
 
        return NULL;