Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 242336
b: refs/heads/master
c: d4a85e3
h: refs/heads/master
v: v3
  • Loading branch information
Ian Kent authored and Al Viro committed Mar 24, 2011
1 parent 8830b6d commit deabb4a
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f9398c233e3201874395eea8558eb616fb198648
refs/heads/master: d4a85e35d1465da055264407d8395e84483084e6
52 changes: 51 additions & 1 deletion trunk/fs/autofs4/expire.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,56 @@ static int autofs4_mount_busy(struct vfsmount *mnt, struct dentry *dentry)
return status;
}

/*
* Calculate and dget next entry in the subdirs list under root.
*/
static struct dentry *get_next_positive_subdir(struct dentry *prev,
struct dentry *root)
{
struct list_head *next;
struct dentry *p, *q;

spin_lock(&autofs4_lock);

if (prev == NULL) {
spin_lock(&root->d_lock);
prev = dget_dlock(root);
next = prev->d_subdirs.next;
p = prev;
goto start;
}

p = prev;
spin_lock(&p->d_lock);
again:
next = p->d_u.d_child.next;
start:
if (next == &root->d_subdirs) {
spin_unlock(&p->d_lock);
spin_unlock(&autofs4_lock);
dput(prev);
return NULL;
}

q = list_entry(next, struct dentry, d_u.d_child);

spin_lock_nested(&q->d_lock, DENTRY_D_LOCK_NESTED);
/* Negative dentry - try next */
if (!simple_positive(q)) {
spin_unlock(&p->d_lock);
p = q;
goto again;
}
dget_dlock(q);
spin_unlock(&q->d_lock);
spin_unlock(&p->d_lock);
spin_unlock(&autofs4_lock);

dput(prev);

return q;
}

/*
* Calculate and dget next entry in top down tree traversal.
*/
Expand Down Expand Up @@ -333,7 +383,7 @@ struct dentry *autofs4_expire_indirect(struct super_block *sb,
timeout = sbi->exp_timeout;

dentry = NULL;
while ((dentry = get_next_positive_dentry(dentry, root))) {
while ((dentry = get_next_positive_subdir(dentry, root))) {
spin_lock(&sbi->fs_lock);
ino = autofs4_dentry_ino(dentry);
/* No point expiring a pending mount */
Expand Down

0 comments on commit deabb4a

Please sign in to comment.