]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/autofs4/root.c
[PATCH] autofs4: pending flag not cleared on mount fail
[linux-2.6-omap-h63xx.git] / fs / autofs4 / root.c
index 84e030c8ddd0f99047473308afc4d26f555e2c14..563ef9d7da9ffa858ad754217861f4e2292b30ea 100644 (file)
@@ -137,7 +137,9 @@ static int autofs4_dir_open(struct inode *inode, struct file *file)
                nd.flags = LOOKUP_DIRECTORY;
                ret = (dentry->d_op->d_revalidate)(dentry, &nd);
 
-               if (!ret) {
+               if (ret <= 0) {
+                       if (ret < 0)
+                               status = ret;
                        dcache_dir_close(inode, file);
                        goto out;
                }
@@ -279,9 +281,6 @@ static int try_to_fill_dentry(struct dentry *dentry, int flags)
 
                DPRINTK("mount done status=%d", status);
 
-               if (status && dentry->d_inode)
-                       return status; /* Try to get the kernel to invalidate this dentry */
-
                /* Turn this into a real negative dentry? */
                if (status == -ENOENT) {
                        spin_lock(&dentry->d_lock);
@@ -327,6 +326,7 @@ static int try_to_fill_dentry(struct dentry *dentry, int flags)
 static void *autofs4_follow_link(struct dentry *dentry, struct nameidata *nd)
 {
        struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
+       struct autofs_info *ino = autofs4_dentry_ino(dentry);
        int oz_mode = autofs4_oz_mode(sbi);
        unsigned int lookup_type;
        int status;
@@ -340,13 +340,8 @@ static void *autofs4_follow_link(struct dentry *dentry, struct nameidata *nd)
        if (oz_mode || !lookup_type)
                goto done;
 
-       /*
-        * If a request is pending wait for it.
-        * If it's a mount then it won't be expired till at least
-        * a liitle later and if it's an expire then we might need
-        * to mount it again.
-        */
-       if (autofs4_ispending(dentry)) {
+       /* If an expire request is pending wait for it. */
+       if (ino && (ino->flags & AUTOFS_INF_EXPIRING)) {
                DPRINTK("waiting for active request %p name=%.*s",
                        dentry, dentry->d_name.len, dentry->d_name.name);
 
@@ -361,7 +356,7 @@ static void *autofs4_follow_link(struct dentry *dentry, struct nameidata *nd)
         * don't try to mount it again.
         */
        spin_lock(&dcache_lock);
-       if (!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs)) {
+       if (!d_mountpoint(dentry) && __simple_empty(dentry)) {
                spin_unlock(&dcache_lock);
 
                status = try_to_fill_dentry(dentry, 0);
@@ -404,13 +399,23 @@ static int autofs4_revalidate(struct dentry *dentry, struct nameidata *nd)
        struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb);
        int oz_mode = autofs4_oz_mode(sbi);
        int flags = nd ? nd->flags : 0;
-       int status = 0;
+       int status = 1;
 
        /* Pending dentry */
        if (autofs4_ispending(dentry)) {
-               if (!oz_mode)
-                       status = try_to_fill_dentry(dentry, flags);
-               return !status;
+               /* The daemon never causes a mount to trigger */
+               if (oz_mode)
+                       return 1;
+
+               /*
+                * A zero status is success otherwise we have a
+                * negative error code.
+                */
+               status = try_to_fill_dentry(dentry, flags);
+               if (status == 0)
+                               return 1;
+
+               return status;
        }
 
        /* Negative dentry.. invalidate if "old" */
@@ -425,9 +430,19 @@ static int autofs4_revalidate(struct dentry *dentry, struct nameidata *nd)
                DPRINTK("dentry=%p %.*s, emptydir",
                         dentry, dentry->d_name.len, dentry->d_name.name);
                spin_unlock(&dcache_lock);
-               if (!oz_mode)
-                       status = try_to_fill_dentry(dentry, flags);
-               return !status;
+               /* The daemon never causes a mount to trigger */
+               if (oz_mode)
+                       return 1;
+
+               /*
+                * A zero status is success otherwise we have a
+                * negative error code.
+                */
+               status = try_to_fill_dentry(dentry, flags);
+               if (status == 0)
+                       return 1;
+
+               return status;
        }
        spin_unlock(&dcache_lock);
 
@@ -522,6 +537,9 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s
                            return ERR_PTR(-ERESTARTNOINTR);
                        }
                }
+               spin_lock(&dentry->d_lock);
+               dentry->d_flags &= ~DCACHE_AUTOFS_PENDING;
+               spin_unlock(&dentry->d_lock);
        }
 
        /*