]> err.no Git - linux-2.6/blobdiff - fs/autofs4/expire.c
[PATCH] blk: Use blk_queue_xxx functions to set parameters
[linux-2.6] / fs / autofs4 / expire.c
index 31540a6404d91ef6c2373a7bb0091af3ef1a8c99..feb6ac427d058b8a1c02b420bbe6ad81ffd581aa 100644 (file)
@@ -56,12 +56,9 @@ static int autofs4_check_mount(struct vfsmount *mnt, struct dentry *dentry)
        mntget(mnt);
        dget(dentry);
 
-       if (!follow_down(&mnt, &dentry))
+       if (!autofs4_follow_mount(&mnt, &dentry))
                goto done;
 
-       while (d_mountpoint(dentry) && follow_down(&mnt, &dentry))
-               ;
-
        /* This is an autofs submount, we can't expire it */
        if (is_autofs4_dentry(dentry))
                goto done;
@@ -99,6 +96,10 @@ static int autofs4_check_tree(struct vfsmount *mnt,
        if (!autofs4_can_expire(top, timeout, do_now))
                return 0;
 
+       /* Is someone visiting anywhere in the tree ? */
+       if (may_umount_tree(mnt))
+               return 0;
+
        spin_lock(&dcache_lock);
 repeat:
        next = this_parent->d_subdirs.next;
@@ -270,10 +271,18 @@ static struct dentry *autofs4_expire(struct super_block *sb,
 
                /* Case 2: tree mount, expire iff entire tree is not busy */
                if (!exp_leaves) {
+                       /* Lock the tree as we must expire as a whole */
+                       spin_lock(&sbi->fs_lock);
                        if (autofs4_check_tree(mnt, dentry, timeout, do_now)) {
-                       expired = dentry;
-                       break;
+                               struct autofs_info *inf = autofs4_dentry_ino(dentry);
+
+                               /* Set this flag early to catch sys_chdir and the like */
+                               inf->flags |= AUTOFS_INF_EXPIRING;
+                               spin_unlock(&sbi->fs_lock);
+                               expired = dentry;
+                               break;
                        }
+                       spin_unlock(&sbi->fs_lock);
                /* Case 3: direct mount, expire individual leaves */
                } else {
                        expired = autofs4_check_leaves(mnt, dentry, timeout, do_now);