aboutsummaryrefslogtreecommitdiffstats
path: root/fs/autofs4/expire.c
diff options
context:
space:
mode:
authorIan Kent <raven@themaw.net>2005-05-01 11:59:17 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-01 11:59:17 -0400
commit3a9720ce73c9247e5262922d65e90444ea75eb50 (patch)
treec70bba916168232f530c00858e7e8a0c5bd82b38 /fs/autofs4/expire.c
parent4dcd00b18118d174c4b8d838c11f437f0af3c20c (diff)
[PATCH] autofs4: tree race fix
For tree mount maps, a call to chdir or chroot, to a directory above the moint point directories at a certain time during the expire results in the expire incorrectly thinking the tree is not busy. This patch adds a check to see if the filesystem above the tree mount points is busy and also locks the filesystem during the tree mount expire to prevent the race. Signed-off-by: Ian Kent <raven@themaw.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/autofs4/expire.c')
-rw-r--r--fs/autofs4/expire.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c
index 31540a6404d..500425e24fb 100644
--- a/fs/autofs4/expire.c
+++ b/fs/autofs4/expire.c
@@ -99,6 +99,10 @@ static int autofs4_check_tree(struct vfsmount *mnt,
99 if (!autofs4_can_expire(top, timeout, do_now)) 99 if (!autofs4_can_expire(top, timeout, do_now))
100 return 0; 100 return 0;
101 101
102 /* Is someone visiting anywhere in the tree ? */
103 if (may_umount_tree(mnt))
104 return 0;
105
102 spin_lock(&dcache_lock); 106 spin_lock(&dcache_lock);
103repeat: 107repeat:
104 next = this_parent->d_subdirs.next; 108 next = this_parent->d_subdirs.next;
@@ -270,10 +274,18 @@ static struct dentry *autofs4_expire(struct super_block *sb,
270 274
271 /* Case 2: tree mount, expire iff entire tree is not busy */ 275 /* Case 2: tree mount, expire iff entire tree is not busy */
272 if (!exp_leaves) { 276 if (!exp_leaves) {
277 /* Lock the tree as we must expire as a whole */
278 spin_lock(&sbi->fs_lock);
273 if (autofs4_check_tree(mnt, dentry, timeout, do_now)) { 279 if (autofs4_check_tree(mnt, dentry, timeout, do_now)) {
274 expired = dentry; 280 struct autofs_info *inf = autofs4_dentry_ino(dentry);
275 break; 281
282 /* Set this flag early to catch sys_chdir and the like */
283 inf->flags |= AUTOFS_INF_EXPIRING;
284 spin_unlock(&sbi->fs_lock);
285 expired = dentry;
286 break;
276 } 287 }
288 spin_unlock(&sbi->fs_lock);
277 /* Case 3: direct mount, expire individual leaves */ 289 /* Case 3: direct mount, expire individual leaves */
278 } else { 290 } else {
279 expired = autofs4_check_leaves(mnt, dentry, timeout, do_now); 291 expired = autofs4_check_leaves(mnt, dentry, timeout, do_now);