diff options
Diffstat (limited to 'fs/autofs4/expire.c')
-rw-r--r-- | fs/autofs4/expire.c | 55 |
1 files changed, 31 insertions, 24 deletions
diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c index cc1d01365905..f43100b9662b 100644 --- a/fs/autofs4/expire.c +++ b/fs/autofs4/expire.c | |||
@@ -26,10 +26,6 @@ static inline int autofs4_can_expire(struct dentry *dentry, | |||
26 | if (ino == NULL) | 26 | if (ino == NULL) |
27 | return 0; | 27 | return 0; |
28 | 28 | ||
29 | /* No point expiring a pending mount */ | ||
30 | if (ino->flags & AUTOFS_INF_PENDING) | ||
31 | return 0; | ||
32 | |||
33 | if (!do_now) { | 29 | if (!do_now) { |
34 | /* Too young to die */ | 30 | /* Too young to die */ |
35 | if (!timeout || time_after(ino->last_used + timeout, now)) | 31 | if (!timeout || time_after(ino->last_used + timeout, now)) |
@@ -56,7 +52,7 @@ static int autofs4_mount_busy(struct vfsmount *mnt, struct dentry *dentry) | |||
56 | 52 | ||
57 | path_get(&path); | 53 | path_get(&path); |
58 | 54 | ||
59 | if (!follow_down(&path)) | 55 | if (!follow_down_one(&path)) |
60 | goto done; | 56 | goto done; |
61 | 57 | ||
62 | if (is_autofs4_dentry(path.dentry)) { | 58 | if (is_autofs4_dentry(path.dentry)) { |
@@ -100,7 +96,7 @@ static struct dentry *get_next_positive_dentry(struct dentry *prev, | |||
100 | struct dentry *p, *ret; | 96 | struct dentry *p, *ret; |
101 | 97 | ||
102 | if (prev == NULL) | 98 | if (prev == NULL) |
103 | return dget(prev); | 99 | return dget(root); |
104 | 100 | ||
105 | spin_lock(&autofs4_lock); | 101 | spin_lock(&autofs4_lock); |
106 | relock: | 102 | relock: |
@@ -137,7 +133,7 @@ again: | |||
137 | spin_lock_nested(&ret->d_lock, DENTRY_D_LOCK_NESTED); | 133 | spin_lock_nested(&ret->d_lock, DENTRY_D_LOCK_NESTED); |
138 | /* Negative dentry - try next */ | 134 | /* Negative dentry - try next */ |
139 | if (!simple_positive(ret)) { | 135 | if (!simple_positive(ret)) { |
140 | spin_unlock(&ret->d_lock); | 136 | spin_unlock(&p->d_lock); |
141 | p = ret; | 137 | p = ret; |
142 | goto again; | 138 | goto again; |
143 | } | 139 | } |
@@ -283,6 +279,7 @@ struct dentry *autofs4_expire_direct(struct super_block *sb, | |||
283 | unsigned long timeout; | 279 | unsigned long timeout; |
284 | struct dentry *root = dget(sb->s_root); | 280 | struct dentry *root = dget(sb->s_root); |
285 | int do_now = how & AUTOFS_EXP_IMMEDIATE; | 281 | int do_now = how & AUTOFS_EXP_IMMEDIATE; |
282 | struct autofs_info *ino; | ||
286 | 283 | ||
287 | if (!root) | 284 | if (!root) |
288 | return NULL; | 285 | return NULL; |
@@ -291,19 +288,21 @@ struct dentry *autofs4_expire_direct(struct super_block *sb, | |||
291 | timeout = sbi->exp_timeout; | 288 | timeout = sbi->exp_timeout; |
292 | 289 | ||
293 | spin_lock(&sbi->fs_lock); | 290 | spin_lock(&sbi->fs_lock); |
291 | ino = autofs4_dentry_ino(root); | ||
292 | /* No point expiring a pending mount */ | ||
293 | if (ino->flags & AUTOFS_INF_PENDING) { | ||
294 | spin_unlock(&sbi->fs_lock); | ||
295 | return NULL; | ||
296 | } | ||
297 | managed_dentry_set_transit(root); | ||
294 | if (!autofs4_direct_busy(mnt, root, timeout, do_now)) { | 298 | if (!autofs4_direct_busy(mnt, root, timeout, do_now)) { |
295 | struct autofs_info *ino = autofs4_dentry_ino(root); | 299 | struct autofs_info *ino = autofs4_dentry_ino(root); |
296 | if (d_mountpoint(root)) { | ||
297 | ino->flags |= AUTOFS_INF_MOUNTPOINT; | ||
298 | spin_lock(&root->d_lock); | ||
299 | root->d_flags &= ~DCACHE_MOUNTED; | ||
300 | spin_unlock(&root->d_lock); | ||
301 | } | ||
302 | ino->flags |= AUTOFS_INF_EXPIRING; | 300 | ino->flags |= AUTOFS_INF_EXPIRING; |
303 | init_completion(&ino->expire_complete); | 301 | init_completion(&ino->expire_complete); |
304 | spin_unlock(&sbi->fs_lock); | 302 | spin_unlock(&sbi->fs_lock); |
305 | return root; | 303 | return root; |
306 | } | 304 | } |
305 | managed_dentry_clear_transit(root); | ||
307 | spin_unlock(&sbi->fs_lock); | 306 | spin_unlock(&sbi->fs_lock); |
308 | dput(root); | 307 | dput(root); |
309 | 308 | ||
@@ -340,6 +339,10 @@ struct dentry *autofs4_expire_indirect(struct super_block *sb, | |||
340 | while ((dentry = get_next_positive_dentry(dentry, root))) { | 339 | while ((dentry = get_next_positive_dentry(dentry, root))) { |
341 | spin_lock(&sbi->fs_lock); | 340 | spin_lock(&sbi->fs_lock); |
342 | ino = autofs4_dentry_ino(dentry); | 341 | ino = autofs4_dentry_ino(dentry); |
342 | /* No point expiring a pending mount */ | ||
343 | if (ino->flags & AUTOFS_INF_PENDING) | ||
344 | goto cont; | ||
345 | managed_dentry_set_transit(dentry); | ||
343 | 346 | ||
344 | /* | 347 | /* |
345 | * Case 1: (i) indirect mount or top level pseudo direct mount | 348 | * Case 1: (i) indirect mount or top level pseudo direct mount |
@@ -399,6 +402,8 @@ struct dentry *autofs4_expire_indirect(struct super_block *sb, | |||
399 | } | 402 | } |
400 | } | 403 | } |
401 | next: | 404 | next: |
405 | managed_dentry_clear_transit(dentry); | ||
406 | cont: | ||
402 | spin_unlock(&sbi->fs_lock); | 407 | spin_unlock(&sbi->fs_lock); |
403 | } | 408 | } |
404 | return NULL; | 409 | return NULL; |
@@ -479,6 +484,8 @@ int autofs4_expire_run(struct super_block *sb, | |||
479 | spin_lock(&sbi->fs_lock); | 484 | spin_lock(&sbi->fs_lock); |
480 | ino = autofs4_dentry_ino(dentry); | 485 | ino = autofs4_dentry_ino(dentry); |
481 | ino->flags &= ~AUTOFS_INF_EXPIRING; | 486 | ino->flags &= ~AUTOFS_INF_EXPIRING; |
487 | if (!d_unhashed(dentry)) | ||
488 | managed_dentry_clear_transit(dentry); | ||
482 | complete_all(&ino->expire_complete); | 489 | complete_all(&ino->expire_complete); |
483 | spin_unlock(&sbi->fs_lock); | 490 | spin_unlock(&sbi->fs_lock); |
484 | 491 | ||
@@ -504,18 +511,18 @@ int autofs4_do_expire_multi(struct super_block *sb, struct vfsmount *mnt, | |||
504 | ret = autofs4_wait(sbi, dentry, NFY_EXPIRE); | 511 | ret = autofs4_wait(sbi, dentry, NFY_EXPIRE); |
505 | 512 | ||
506 | spin_lock(&sbi->fs_lock); | 513 | spin_lock(&sbi->fs_lock); |
507 | if (ino->flags & AUTOFS_INF_MOUNTPOINT) { | ||
508 | spin_lock(&sb->s_root->d_lock); | ||
509 | /* | ||
510 | * If we haven't been expired away, then reset | ||
511 | * mounted status. | ||
512 | */ | ||
513 | if (mnt->mnt_parent != mnt) | ||
514 | sb->s_root->d_flags |= DCACHE_MOUNTED; | ||
515 | spin_unlock(&sb->s_root->d_lock); | ||
516 | ino->flags &= ~AUTOFS_INF_MOUNTPOINT; | ||
517 | } | ||
518 | ino->flags &= ~AUTOFS_INF_EXPIRING; | 514 | ino->flags &= ~AUTOFS_INF_EXPIRING; |
515 | spin_lock(&dentry->d_lock); | ||
516 | if (ret) | ||
517 | __managed_dentry_clear_transit(dentry); | ||
518 | else { | ||
519 | if ((IS_ROOT(dentry) || | ||
520 | (autofs_type_indirect(sbi->type) && | ||
521 | IS_ROOT(dentry->d_parent))) && | ||
522 | !(dentry->d_flags & DCACHE_NEED_AUTOMOUNT)) | ||
523 | __managed_dentry_set_automount(dentry); | ||
524 | } | ||
525 | spin_unlock(&dentry->d_lock); | ||
519 | complete_all(&ino->expire_complete); | 526 | complete_all(&ino->expire_complete); |
520 | spin_unlock(&sbi->fs_lock); | 527 | spin_unlock(&sbi->fs_lock); |
521 | dput(dentry); | 528 | dput(dentry); |