17 static unsigned long now;
20 static inline int autofs4_can_expire(
struct dentry *
dentry,
21 unsigned long timeout,
int do_now)
44 static int autofs4_mount_busy(
struct vfsmount *mnt,
struct dentry *dentry)
46 struct dentry *
top = dentry;
62 if (autofs_type_indirect(sbi->
type))
69 if (!d_mountpoint(path.
dentry)) {
84 DPRINTK(
"returning = %d", status);
92 static struct dentry *get_next_positive_subdir(
struct dentry *
prev,
105 prev = dget_dlock(root);
111 spin_unlock(&root->
d_lock);
121 if (q->
d_count == 0 || !simple_positive(q)) {
128 spin_unlock(&root->
d_lock);
139 static struct dentry *get_next_positive_dentry(
struct dentry *prev,
144 struct dentry *
p, *
ret;
167 if (!spin_trylock(&parent->
d_lock)) {
183 if (!simple_positive(ret)) {
190 spin_unlock(&ret->
d_lock);
205 static int autofs4_direct_busy(
struct vfsmount *mnt,
207 unsigned long timeout,
222 if (!autofs4_can_expire(top, timeout, do_now))
231 static int autofs4_tree_busy(
struct vfsmount *mnt,
233 unsigned long timeout,
236 struct autofs_info *top_ino = autofs4_dentry_ino(top);
243 if (!simple_positive(top))
247 while ((p = get_next_positive_dentry(p, top))) {
257 if (d_mountpoint(p)) {
258 if (autofs4_mount_busy(mnt, p)) {
288 if (!autofs4_can_expire(top, timeout, do_now))
294 static struct dentry *autofs4_check_leaves(
struct vfsmount *mnt,
295 struct dentry *parent,
296 unsigned long timeout,
305 while ((p = get_next_positive_dentry(p, parent))) {
309 if (d_mountpoint(p)) {
311 if (autofs4_mount_busy(mnt, p))
315 if (autofs4_can_expire(p, timeout, do_now))
328 unsigned long timeout;
329 struct dentry *root = dget(sb->
s_root);
340 ino = autofs4_dentry_ino(root);
344 if (!autofs4_direct_busy(mnt, root, timeout, do_now)) {
345 struct autofs_info *ino = autofs4_dentry_ino(root);
369 unsigned long timeout;
370 struct dentry *root = sb->
s_root;
371 struct dentry *dentry;
372 struct dentry *expired =
NULL;
376 unsigned int ino_count;
385 while ((dentry = get_next_positive_subdir(dentry, root))) {
387 ino = autofs4_dentry_ino(dentry);
398 if (d_mountpoint(dentry)) {
399 DPRINTK(
"checking mountpoint %p %.*s",
403 if (autofs4_mount_busy(mnt, dentry))
407 if (autofs4_can_expire(dentry, timeout, do_now)) {
421 if (dentry->
d_count > ino_count)
424 if (!autofs4_tree_busy(mnt, dentry, timeout, do_now)) {
435 if (dentry->
d_count > ino_count)
438 expired = autofs4_check_leaves(mnt, dentry, timeout, do_now);
451 expired, (
int)expired->
d_name.len, expired->
d_name.name);
452 ino = autofs4_dentry_ino(expired);
457 spin_lock(&expired->
d_parent->d_lock);
460 spin_unlock(&expired->
d_lock);
461 spin_unlock(&expired->
d_parent->d_lock);
469 struct autofs_info *ino = autofs4_dentry_ino(dentry);
477 DPRINTK(
"waiting for expire %p name=%.*s",
483 DPRINTK(
"expire done status=%d", status);
485 if (d_unhashed(dentry))
503 struct dentry *dentry;
506 memset(&pkt,0,
sizeof pkt);
523 ino = autofs4_dentry_ino(dentry);
534 struct dentry *dentry;
537 if (autofs_type_trigger(sbi->
type))
543 struct autofs_info *ino = autofs4_dentry_ino(dentry);
551 spin_lock(&dentry->
d_lock);
554 (autofs_type_indirect(sbi->
type) &&
557 __managed_dentry_set_automount(dentry);
559 spin_unlock(&dentry->
d_lock);