Inotify: undefined reference to `anon_inode_getfd'
[safe/jmp/linux-2.6] / fs / autofs4 / root.c
index 305136b..e8e5e63 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/stat.h>
+#include <linux/slab.h>
 #include <linux/param.h>
 #include <linux/time.h>
 #include "autofs_i.h"
@@ -133,7 +134,7 @@ static int autofs4_dir_open(struct inode *inode, struct file *file)
         * it.
         */
        spin_lock(&dcache_lock);
-       if (!d_mountpoint(dentry) && __simple_empty(dentry)) {
+       if (!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs)) {
                spin_unlock(&dcache_lock);
                return -ENOENT;
        }
@@ -176,8 +177,7 @@ static int try_to_fill_dentry(struct dentry *dentry, int flags)
                }
        /* Trigger mount for path component or follow link */
        } else if (ino->flags & AUTOFS_INF_PENDING ||
-                       autofs4_need_mount(flags) ||
-                       current->link_count) {
+                       autofs4_need_mount(flags)) {
                DPRINTK("waiting for mount name=%.*s",
                        dentry->d_name.len, dentry->d_name.name);
 
@@ -257,11 +257,11 @@ static void *autofs4_follow_link(struct dentry *dentry, struct nameidata *nd)
         * mount it again.
         */
        if (ino->flags & AUTOFS_INF_PENDING ||
-           (!d_mountpoint(dentry) && __simple_empty(dentry))) {
+           (!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs))) {
                spin_unlock(&dcache_lock);
                spin_unlock(&sbi->fs_lock);
 
-               status = try_to_fill_dentry(dentry, 0);
+               status = try_to_fill_dentry(dentry, nd->flags);
                if (status)
                        goto out_error;
 
@@ -340,8 +340,7 @@ static int autofs4_revalidate(struct dentry *dentry, struct nameidata *nd)
        /* Check for a non-mountpoint directory with no contents */
        spin_lock(&dcache_lock);
        if (S_ISDIR(dentry->d_inode->i_mode) &&
-           !d_mountpoint(dentry) && 
-           __simple_empty(dentry)) {
+           !d_mountpoint(dentry) && list_empty(&dentry->d_subdirs)) {
                DPRINTK("dentry=%p %.*s, emptydir",
                         dentry, dentry->d_name.len, dentry->d_name.name);
                spin_unlock(&dcache_lock);
@@ -405,8 +404,11 @@ static const struct dentry_operations autofs4_dentry_operations = {
        .d_release      = autofs4_dentry_release,
 };
 
-static struct dentry *autofs4_lookup_active(struct autofs_sb_info *sbi, struct dentry *parent, struct qstr *name)
+static struct dentry *autofs4_lookup_active(struct dentry *dentry)
 {
+       struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
+       struct dentry *parent = dentry->d_parent;
+       struct qstr *name = &dentry->d_name;
        unsigned int len = name->len;
        unsigned int hash = name->hash;
        const unsigned char *str = name->name;
@@ -417,23 +419,23 @@ static struct dentry *autofs4_lookup_active(struct autofs_sb_info *sbi, struct d
        head = &sbi->active_list;
        list_for_each(p, head) {
                struct autofs_info *ino;
-               struct dentry *dentry;
+               struct dentry *active;
                struct qstr *qstr;
 
                ino = list_entry(p, struct autofs_info, active);
-               dentry = ino->dentry;
+               active = ino->dentry;
 
-               spin_lock(&dentry->d_lock);
+               spin_lock(&active->d_lock);
 
                /* Already gone? */
-               if (atomic_read(&dentry->d_count) == 0)
+               if (atomic_read(&active->d_count) == 0)
                        goto next;
 
-               qstr = &dentry->d_name;
+               qstr = &active->d_name;
 
-               if (dentry->d_name.hash != hash)
+               if (active->d_name.hash != hash)
                        goto next;
-               if (dentry->d_parent != parent)
+               if (active->d_parent != parent)
                        goto next;
 
                if (qstr->len != len)
@@ -441,15 +443,15 @@ static struct dentry *autofs4_lookup_active(struct autofs_sb_info *sbi, struct d
                if (memcmp(qstr->name, str, len))
                        goto next;
 
-               if (d_unhashed(dentry)) {
-                       dget(dentry);
-                       spin_unlock(&dentry->d_lock);
+               if (d_unhashed(active)) {
+                       dget(active);
+                       spin_unlock(&active->d_lock);
                        spin_unlock(&sbi->lookup_lock);
                        spin_unlock(&dcache_lock);
-                       return dentry;
+                       return active;
                }
 next:
-               spin_unlock(&dentry->d_lock);
+               spin_unlock(&active->d_lock);
        }
        spin_unlock(&sbi->lookup_lock);
        spin_unlock(&dcache_lock);
@@ -457,8 +459,11 @@ next:
        return NULL;
 }
 
-static struct dentry *autofs4_lookup_expiring(struct autofs_sb_info *sbi, struct dentry *parent, struct qstr *name)
+static struct dentry *autofs4_lookup_expiring(struct dentry *dentry)
 {
+       struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
+       struct dentry *parent = dentry->d_parent;
+       struct qstr *name = &dentry->d_name;
        unsigned int len = name->len;
        unsigned int hash = name->hash;
        const unsigned char *str = name->name;
@@ -469,23 +474,23 @@ static struct dentry *autofs4_lookup_expiring(struct autofs_sb_info *sbi, struct
        head = &sbi->expiring_list;
        list_for_each(p, head) {
                struct autofs_info *ino;
-               struct dentry *dentry;
+               struct dentry *expiring;
                struct qstr *qstr;
 
                ino = list_entry(p, struct autofs_info, expiring);
-               dentry = ino->dentry;
+               expiring = ino->dentry;
 
-               spin_lock(&dentry->d_lock);
+               spin_lock(&expiring->d_lock);
 
                /* Bad luck, we've already been dentry_iput */
-               if (!dentry->d_inode)
+               if (!expiring->d_inode)
                        goto next;
 
-               qstr = &dentry->d_name;
+               qstr = &expiring->d_name;
 
-               if (dentry->d_name.hash != hash)
+               if (expiring->d_name.hash != hash)
                        goto next;
-               if (dentry->d_parent != parent)
+               if (expiring->d_parent != parent)
                        goto next;
 
                if (qstr->len != len)
@@ -493,15 +498,15 @@ static struct dentry *autofs4_lookup_expiring(struct autofs_sb_info *sbi, struct
                if (memcmp(qstr->name, str, len))
                        goto next;
 
-               if (d_unhashed(dentry)) {
-                       dget(dentry);
-                       spin_unlock(&dentry->d_lock);
+               if (d_unhashed(expiring)) {
+                       dget(expiring);
+                       spin_unlock(&expiring->d_lock);
                        spin_unlock(&sbi->lookup_lock);
                        spin_unlock(&dcache_lock);
-                       return dentry;
+                       return expiring;
                }
 next:
-               spin_unlock(&dentry->d_lock);
+               spin_unlock(&expiring->d_lock);
        }
        spin_unlock(&sbi->lookup_lock);
        spin_unlock(&dcache_lock);
@@ -514,7 +519,7 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s
 {
        struct autofs_sb_info *sbi;
        struct autofs_info *ino;
-       struct dentry *expiring, *unhashed;
+       struct dentry *expiring, *active;
        int oz_mode;
 
        DPRINTK("name = %.*s",
@@ -530,9 +535,9 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s
        DPRINTK("pid = %u, pgrp = %u, catatonic = %d, oz_mode = %d",
                 current->pid, task_pgrp_nr(current), sbi->catatonic, oz_mode);
 
-       unhashed = autofs4_lookup_active(sbi, dentry->d_parent, &dentry->d_name);
-       if (unhashed) {
-               dentry = unhashed;
+       active = autofs4_lookup_active(dentry);
+       if (active) {
+               dentry = active;
                ino = autofs4_dentry_ino(dentry);
        } else {
                /*
@@ -567,9 +572,7 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s
 
        if (!oz_mode) {
                mutex_unlock(&dir->i_mutex);
-               expiring = autofs4_lookup_expiring(sbi,
-                                                  dentry->d_parent,
-                                                  &dentry->d_name);
+               expiring = autofs4_lookup_expiring(dentry);
                if (expiring) {
                        /*
                         * If we are racing with expire the request might not
@@ -600,8 +603,8 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s
                        if (sigismember (sigset, SIGKILL) ||
                            sigismember (sigset, SIGQUIT) ||
                            sigismember (sigset, SIGINT)) {
-                           if (unhashed)
-                               dput(unhashed);
+                           if (active)
+                               dput(active);
                            return ERR_PTR(-ERESTARTNOINTR);
                        }
                }
@@ -633,14 +636,14 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s
                else
                        dentry = ERR_PTR(-ENOENT);
 
-               if (unhashed)
-                       dput(unhashed);
+               if (active)
+                       dput(active);
 
                return dentry;
        }
 
-       if (unhashed)
-               return unhashed;
+       if (active)
+               return active;
 
        return NULL;
 }