Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* -*- c -*- --------------------------------------------------------------- * |
| 2 | * |
| 3 | * linux/fs/autofs/expire.c |
| 4 | * |
| 5 | * Copyright 1997-1998 Transmeta Corporation -- All Rights Reserved |
| 6 | * Copyright 1999-2000 Jeremy Fitzhardinge <jeremy@goop.org> |
Ian Kent | 3a15e2a | 2006-03-27 01:14:55 -0800 | [diff] [blame] | 7 | * Copyright 2001-2006 Ian Kent <raven@themaw.net> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * |
| 9 | * This file is part of the Linux kernel and is made available under |
| 10 | * the terms of the GNU General Public License, version 2, or at your |
| 11 | * option, any later version, incorporated herein by reference. |
| 12 | * |
| 13 | * ------------------------------------------------------------------------- */ |
| 14 | |
| 15 | #include "autofs_i.h" |
| 16 | |
| 17 | static unsigned long now; |
| 18 | |
Ian Kent | 1f5f2c3 | 2006-03-27 01:14:44 -0800 | [diff] [blame] | 19 | /* Check if a dentry can be expired */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | static inline int autofs4_can_expire(struct dentry *dentry, |
| 21 | unsigned long timeout, int do_now) |
| 22 | { |
| 23 | struct autofs_info *ino = autofs4_dentry_ino(dentry); |
| 24 | |
| 25 | /* dentry in the process of being deleted */ |
| 26 | if (ino == NULL) |
| 27 | return 0; |
| 28 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | if (!do_now) { |
| 30 | /* Too young to die */ |
Ian Kent | c0ba7e5 | 2006-09-25 16:24:16 -0700 | [diff] [blame] | 31 | if (!timeout || time_after(ino->last_used + timeout, now)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | return 1; |
| 35 | } |
| 36 | |
Ian Kent | 1f5f2c3 | 2006-03-27 01:14:44 -0800 | [diff] [blame] | 37 | /* Check a mount point for busyness */ |
| 38 | static int autofs4_mount_busy(struct vfsmount *mnt, struct dentry *dentry) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | { |
Ian Kent | e0a7aae | 2006-03-27 01:14:47 -0800 | [diff] [blame] | 40 | struct dentry *top = dentry; |
Al Viro | 9393bd0 | 2009-04-18 13:58:15 -0400 | [diff] [blame] | 41 | struct path path = {.mnt = mnt, .dentry = dentry}; |
Ian Kent | 1f5f2c3 | 2006-03-27 01:14:44 -0800 | [diff] [blame] | 42 | int status = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | |
Al Viro | a455589 | 2014-10-21 20:11:25 -0400 | [diff] [blame] | 44 | DPRINTK("dentry %p %pd", dentry, dentry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | |
Al Viro | 9393bd0 | 2009-04-18 13:58:15 -0400 | [diff] [blame] | 46 | path_get(&path); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
David Howells | cc53ce5 | 2011-01-14 18:45:26 +0000 | [diff] [blame] | 48 | if (!follow_down_one(&path)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | goto done; |
| 50 | |
Al Viro | 9393bd0 | 2009-04-18 13:58:15 -0400 | [diff] [blame] | 51 | if (is_autofs4_dentry(path.dentry)) { |
| 52 | struct autofs_sb_info *sbi = autofs4_sbi(path.dentry->d_sb); |
Ian Kent | bc9c406 | 2008-11-06 12:53:22 -0800 | [diff] [blame] | 53 | |
| 54 | /* This is an autofs submount, we can't expire it */ |
Ian Kent | a92daf6 | 2009-01-06 14:42:08 -0800 | [diff] [blame] | 55 | if (autofs_type_indirect(sbi->type)) |
Ian Kent | bc9c406 | 2008-11-06 12:53:22 -0800 | [diff] [blame] | 56 | goto done; |
Ian Kent | bc9c406 | 2008-11-06 12:53:22 -0800 | [diff] [blame] | 57 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | |
Ian Kent | e0a7aae | 2006-03-27 01:14:47 -0800 | [diff] [blame] | 59 | /* Update the expiry counter if fs is busy */ |
Ian Kent | 37d0892 | 2009-09-01 11:26:22 +0800 | [diff] [blame] | 60 | if (!may_umount_tree(path.mnt)) { |
Ian Kent | e0a7aae | 2006-03-27 01:14:47 -0800 | [diff] [blame] | 61 | struct autofs_info *ino = autofs4_dentry_ino(top); |
| 62 | ino->last_used = jiffies; |
| 63 | goto done; |
| 64 | } |
| 65 | |
| 66 | status = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | done: |
| 68 | DPRINTK("returning = %d", status); |
Al Viro | 9393bd0 | 2009-04-18 13:58:15 -0400 | [diff] [blame] | 69 | path_put(&path); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | return status; |
| 71 | } |
| 72 | |
Ian Kent | 1ce12ba | 2006-03-27 01:14:45 -0800 | [diff] [blame] | 73 | /* |
Ian Kent | d4a85e3 | 2011-03-25 01:51:20 +0800 | [diff] [blame] | 74 | * Calculate and dget next entry in the subdirs list under root. |
| 75 | */ |
| 76 | static struct dentry *get_next_positive_subdir(struct dentry *prev, |
| 77 | struct dentry *root) |
| 78 | { |
Ian Kent | e785472 | 2011-03-25 01:51:31 +0800 | [diff] [blame] | 79 | struct autofs_sb_info *sbi = autofs4_sbi(root->d_sb); |
Ian Kent | d4a85e3 | 2011-03-25 01:51:20 +0800 | [diff] [blame] | 80 | struct list_head *next; |
Ian Kent | a45440f | 2012-08-06 09:37:47 +0800 | [diff] [blame] | 81 | struct dentry *q; |
Ian Kent | d4a85e3 | 2011-03-25 01:51:20 +0800 | [diff] [blame] | 82 | |
Ian Kent | e785472 | 2011-03-25 01:51:31 +0800 | [diff] [blame] | 83 | spin_lock(&sbi->lookup_lock); |
Ian Kent | a45440f | 2012-08-06 09:37:47 +0800 | [diff] [blame] | 84 | spin_lock(&root->d_lock); |
Ian Kent | d4a85e3 | 2011-03-25 01:51:20 +0800 | [diff] [blame] | 85 | |
Ian Kent | a45440f | 2012-08-06 09:37:47 +0800 | [diff] [blame] | 86 | if (prev) |
Al Viro | 946e51f | 2014-10-26 19:19:16 -0400 | [diff] [blame] | 87 | next = prev->d_child.next; |
Ian Kent | a45440f | 2012-08-06 09:37:47 +0800 | [diff] [blame] | 88 | else { |
Ian Kent | d4a85e3 | 2011-03-25 01:51:20 +0800 | [diff] [blame] | 89 | prev = dget_dlock(root); |
| 90 | next = prev->d_subdirs.next; |
Ian Kent | d4a85e3 | 2011-03-25 01:51:20 +0800 | [diff] [blame] | 91 | } |
| 92 | |
Ian Kent | a45440f | 2012-08-06 09:37:47 +0800 | [diff] [blame] | 93 | cont: |
Ian Kent | d4a85e3 | 2011-03-25 01:51:20 +0800 | [diff] [blame] | 94 | if (next == &root->d_subdirs) { |
Ian Kent | a45440f | 2012-08-06 09:37:47 +0800 | [diff] [blame] | 95 | spin_unlock(&root->d_lock); |
Ian Kent | e785472 | 2011-03-25 01:51:31 +0800 | [diff] [blame] | 96 | spin_unlock(&sbi->lookup_lock); |
Ian Kent | d4a85e3 | 2011-03-25 01:51:20 +0800 | [diff] [blame] | 97 | dput(prev); |
| 98 | return NULL; |
| 99 | } |
| 100 | |
Al Viro | 946e51f | 2014-10-26 19:19:16 -0400 | [diff] [blame] | 101 | q = list_entry(next, struct dentry, d_child); |
Ian Kent | d4a85e3 | 2011-03-25 01:51:20 +0800 | [diff] [blame] | 102 | |
| 103 | spin_lock_nested(&q->d_lock, DENTRY_D_LOCK_NESTED); |
Ian Kent | a45440f | 2012-08-06 09:37:47 +0800 | [diff] [blame] | 104 | /* Already gone or negative dentry (under construction) - try next */ |
Al Viro | 84d08fa | 2013-07-05 18:59:33 +0400 | [diff] [blame] | 105 | if (!d_count(q) || !simple_positive(q)) { |
Ian Kent | a45440f | 2012-08-06 09:37:47 +0800 | [diff] [blame] | 106 | spin_unlock(&q->d_lock); |
Al Viro | 946e51f | 2014-10-26 19:19:16 -0400 | [diff] [blame] | 107 | next = q->d_child.next; |
Ian Kent | a45440f | 2012-08-06 09:37:47 +0800 | [diff] [blame] | 108 | goto cont; |
Ian Kent | d4a85e3 | 2011-03-25 01:51:20 +0800 | [diff] [blame] | 109 | } |
| 110 | dget_dlock(q); |
| 111 | spin_unlock(&q->d_lock); |
Ian Kent | a45440f | 2012-08-06 09:37:47 +0800 | [diff] [blame] | 112 | spin_unlock(&root->d_lock); |
Ian Kent | e785472 | 2011-03-25 01:51:31 +0800 | [diff] [blame] | 113 | spin_unlock(&sbi->lookup_lock); |
Ian Kent | d4a85e3 | 2011-03-25 01:51:20 +0800 | [diff] [blame] | 114 | |
| 115 | dput(prev); |
| 116 | |
| 117 | return q; |
| 118 | } |
| 119 | |
| 120 | /* |
Nick Piggin | 2fd6b7f | 2011-01-07 17:49:34 +1100 | [diff] [blame] | 121 | * Calculate and dget next entry in top down tree traversal. |
Ian Kent | 1ce12ba | 2006-03-27 01:14:45 -0800 | [diff] [blame] | 122 | */ |
Nick Piggin | 2fd6b7f | 2011-01-07 17:49:34 +1100 | [diff] [blame] | 123 | static struct dentry *get_next_positive_dentry(struct dentry *prev, |
| 124 | struct dentry *root) |
Ian Kent | 1ce12ba | 2006-03-27 01:14:45 -0800 | [diff] [blame] | 125 | { |
Ian Kent | e785472 | 2011-03-25 01:51:31 +0800 | [diff] [blame] | 126 | struct autofs_sb_info *sbi = autofs4_sbi(root->d_sb); |
Nick Piggin | 2fd6b7f | 2011-01-07 17:49:34 +1100 | [diff] [blame] | 127 | struct list_head *next; |
| 128 | struct dentry *p, *ret; |
Ian Kent | 1ce12ba | 2006-03-27 01:14:45 -0800 | [diff] [blame] | 129 | |
Nick Piggin | 2fd6b7f | 2011-01-07 17:49:34 +1100 | [diff] [blame] | 130 | if (prev == NULL) |
Ian Kent | c14cc63 | 2011-01-18 12:06:04 +0800 | [diff] [blame] | 131 | return dget(root); |
Nick Piggin | 2fd6b7f | 2011-01-07 17:49:34 +1100 | [diff] [blame] | 132 | |
Ian Kent | e785472 | 2011-03-25 01:51:31 +0800 | [diff] [blame] | 133 | spin_lock(&sbi->lookup_lock); |
Nick Piggin | 2fd6b7f | 2011-01-07 17:49:34 +1100 | [diff] [blame] | 134 | relock: |
| 135 | p = prev; |
| 136 | spin_lock(&p->d_lock); |
| 137 | again: |
| 138 | next = p->d_subdirs.next; |
Ian Kent | 1ce12ba | 2006-03-27 01:14:45 -0800 | [diff] [blame] | 139 | if (next == &p->d_subdirs) { |
| 140 | while (1) { |
Nick Piggin | 2fd6b7f | 2011-01-07 17:49:34 +1100 | [diff] [blame] | 141 | struct dentry *parent; |
| 142 | |
| 143 | if (p == root) { |
| 144 | spin_unlock(&p->d_lock); |
Ian Kent | e785472 | 2011-03-25 01:51:31 +0800 | [diff] [blame] | 145 | spin_unlock(&sbi->lookup_lock); |
Nick Piggin | 2fd6b7f | 2011-01-07 17:49:34 +1100 | [diff] [blame] | 146 | dput(prev); |
Ian Kent | 1ce12ba | 2006-03-27 01:14:45 -0800 | [diff] [blame] | 147 | return NULL; |
Nick Piggin | 2fd6b7f | 2011-01-07 17:49:34 +1100 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | parent = p->d_parent; |
| 151 | if (!spin_trylock(&parent->d_lock)) { |
| 152 | spin_unlock(&p->d_lock); |
| 153 | cpu_relax(); |
| 154 | goto relock; |
| 155 | } |
| 156 | spin_unlock(&p->d_lock); |
Al Viro | 946e51f | 2014-10-26 19:19:16 -0400 | [diff] [blame] | 157 | next = p->d_child.next; |
Nick Piggin | 2fd6b7f | 2011-01-07 17:49:34 +1100 | [diff] [blame] | 158 | p = parent; |
| 159 | if (next != &parent->d_subdirs) |
Ian Kent | 1ce12ba | 2006-03-27 01:14:45 -0800 | [diff] [blame] | 160 | break; |
Ian Kent | 1ce12ba | 2006-03-27 01:14:45 -0800 | [diff] [blame] | 161 | } |
| 162 | } |
Al Viro | 946e51f | 2014-10-26 19:19:16 -0400 | [diff] [blame] | 163 | ret = list_entry(next, struct dentry, d_child); |
Nick Piggin | 2fd6b7f | 2011-01-07 17:49:34 +1100 | [diff] [blame] | 164 | |
| 165 | spin_lock_nested(&ret->d_lock, DENTRY_D_LOCK_NESTED); |
| 166 | /* Negative dentry - try next */ |
| 167 | if (!simple_positive(ret)) { |
Ian Kent | c14cc63 | 2011-01-18 12:06:04 +0800 | [diff] [blame] | 168 | spin_unlock(&p->d_lock); |
Steven Rostedt | 1d6f209 | 2011-08-22 11:52:28 +0800 | [diff] [blame] | 169 | lock_set_subclass(&ret->d_lock.dep_map, 0, _RET_IP_); |
Nick Piggin | 2fd6b7f | 2011-01-07 17:49:34 +1100 | [diff] [blame] | 170 | p = ret; |
| 171 | goto again; |
| 172 | } |
| 173 | dget_dlock(ret); |
| 174 | spin_unlock(&ret->d_lock); |
| 175 | spin_unlock(&p->d_lock); |
Ian Kent | e785472 | 2011-03-25 01:51:31 +0800 | [diff] [blame] | 176 | spin_unlock(&sbi->lookup_lock); |
Nick Piggin | 2fd6b7f | 2011-01-07 17:49:34 +1100 | [diff] [blame] | 177 | |
| 178 | dput(prev); |
| 179 | |
| 180 | return ret; |
Ian Kent | 1ce12ba | 2006-03-27 01:14:45 -0800 | [diff] [blame] | 181 | } |
| 182 | |
Ian Kent | 3a15e2a | 2006-03-27 01:14:55 -0800 | [diff] [blame] | 183 | /* |
| 184 | * Check a direct mount point for busyness. |
| 185 | * Direct mounts have similar expiry semantics to tree mounts. |
| 186 | * The tree is not busy iff no mountpoints are busy and there are no |
| 187 | * autofs submounts. |
| 188 | */ |
| 189 | static int autofs4_direct_busy(struct vfsmount *mnt, |
| 190 | struct dentry *top, |
| 191 | unsigned long timeout, |
| 192 | int do_now) |
| 193 | { |
Al Viro | a455589 | 2014-10-21 20:11:25 -0400 | [diff] [blame] | 194 | DPRINTK("top %p %pd", top, top); |
Ian Kent | 3a15e2a | 2006-03-27 01:14:55 -0800 | [diff] [blame] | 195 | |
Ian Kent | 3a15e2a | 2006-03-27 01:14:55 -0800 | [diff] [blame] | 196 | /* If it's busy update the expiry counters */ |
| 197 | if (!may_umount_tree(mnt)) { |
| 198 | struct autofs_info *ino = autofs4_dentry_ino(top); |
| 199 | if (ino) |
| 200 | ino->last_used = jiffies; |
| 201 | return 1; |
| 202 | } |
| 203 | |
| 204 | /* Timeout of a direct mount is determined by its top dentry */ |
| 205 | if (!autofs4_can_expire(top, timeout, do_now)) |
| 206 | return 1; |
| 207 | |
| 208 | return 0; |
| 209 | } |
| 210 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | /* Check a directory tree of mount points for busyness |
| 212 | * The tree is not busy iff no mountpoints are busy |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | */ |
Ian Kent | 1f5f2c3 | 2006-03-27 01:14:44 -0800 | [diff] [blame] | 214 | static int autofs4_tree_busy(struct vfsmount *mnt, |
| 215 | struct dentry *top, |
| 216 | unsigned long timeout, |
| 217 | int do_now) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | { |
Ian Kent | e0a7aae | 2006-03-27 01:14:47 -0800 | [diff] [blame] | 219 | struct autofs_info *top_ino = autofs4_dentry_ino(top); |
Ian Kent | 1ce12ba | 2006-03-27 01:14:45 -0800 | [diff] [blame] | 220 | struct dentry *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | |
Al Viro | a455589 | 2014-10-21 20:11:25 -0400 | [diff] [blame] | 222 | DPRINTK("top %p %pd", top, top); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | |
| 224 | /* Negative dentry - give up */ |
| 225 | if (!simple_positive(top)) |
Ian Kent | 1f5f2c3 | 2006-03-27 01:14:44 -0800 | [diff] [blame] | 226 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | |
Nick Piggin | 2fd6b7f | 2011-01-07 17:49:34 +1100 | [diff] [blame] | 228 | p = NULL; |
| 229 | while ((p = get_next_positive_dentry(p, top))) { |
Al Viro | a455589 | 2014-10-21 20:11:25 -0400 | [diff] [blame] | 230 | DPRINTK("dentry %p %pd", p, p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | |
Ian Kent | 1aff3c8 | 2006-03-27 01:14:46 -0800 | [diff] [blame] | 232 | /* |
| 233 | * Is someone visiting anywhere in the subtree ? |
| 234 | * If there's no mount we need to check the usage |
| 235 | * count for the autofs dentry. |
Ian Kent | e0a7aae | 2006-03-27 01:14:47 -0800 | [diff] [blame] | 236 | * If the fs is busy update the expiry counter. |
Ian Kent | 1aff3c8 | 2006-03-27 01:14:46 -0800 | [diff] [blame] | 237 | */ |
Ian Kent | 1ce12ba | 2006-03-27 01:14:45 -0800 | [diff] [blame] | 238 | if (d_mountpoint(p)) { |
Ian Kent | 1ce12ba | 2006-03-27 01:14:45 -0800 | [diff] [blame] | 239 | if (autofs4_mount_busy(mnt, p)) { |
Ian Kent | e0a7aae | 2006-03-27 01:14:47 -0800 | [diff] [blame] | 240 | top_ino->last_used = jiffies; |
Ian Kent | 1ce12ba | 2006-03-27 01:14:45 -0800 | [diff] [blame] | 241 | dput(p); |
Ian Kent | 1f5f2c3 | 2006-03-27 01:14:44 -0800 | [diff] [blame] | 242 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | } |
Ian Kent | 1aff3c8 | 2006-03-27 01:14:46 -0800 | [diff] [blame] | 244 | } else { |
Ian Kent | e0a7aae | 2006-03-27 01:14:47 -0800 | [diff] [blame] | 245 | struct autofs_info *ino = autofs4_dentry_ino(p); |
Ian Kent | 1aff3c8 | 2006-03-27 01:14:46 -0800 | [diff] [blame] | 246 | unsigned int ino_count = atomic_read(&ino->count); |
| 247 | |
| 248 | /* allow for dget above and top is already dgot */ |
| 249 | if (p == top) |
| 250 | ino_count += 2; |
| 251 | else |
| 252 | ino_count++; |
| 253 | |
Al Viro | 84d08fa | 2013-07-05 18:59:33 +0400 | [diff] [blame] | 254 | if (d_count(p) > ino_count) { |
Ian Kent | e0a7aae | 2006-03-27 01:14:47 -0800 | [diff] [blame] | 255 | top_ino->last_used = jiffies; |
Ian Kent | 1aff3c8 | 2006-03-27 01:14:46 -0800 | [diff] [blame] | 256 | dput(p); |
| 257 | return 1; |
| 258 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | } |
Ian Kent | 1aff3c8 | 2006-03-27 01:14:46 -0800 | [diff] [blame] | 261 | |
| 262 | /* Timeout of a tree mount is ultimately determined by its top dentry */ |
| 263 | if (!autofs4_can_expire(top, timeout, do_now)) |
| 264 | return 1; |
| 265 | |
Ian Kent | 1f5f2c3 | 2006-03-27 01:14:44 -0800 | [diff] [blame] | 266 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | static struct dentry *autofs4_check_leaves(struct vfsmount *mnt, |
| 270 | struct dentry *parent, |
| 271 | unsigned long timeout, |
| 272 | int do_now) |
| 273 | { |
Ian Kent | 1ce12ba | 2006-03-27 01:14:45 -0800 | [diff] [blame] | 274 | struct dentry *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | |
Al Viro | a455589 | 2014-10-21 20:11:25 -0400 | [diff] [blame] | 276 | DPRINTK("parent %p %pd", parent, parent); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | |
Nick Piggin | 2fd6b7f | 2011-01-07 17:49:34 +1100 | [diff] [blame] | 278 | p = NULL; |
| 279 | while ((p = get_next_positive_dentry(p, parent))) { |
Al Viro | a455589 | 2014-10-21 20:11:25 -0400 | [diff] [blame] | 280 | DPRINTK("dentry %p %pd", p, p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | |
Ian Kent | 1ce12ba | 2006-03-27 01:14:45 -0800 | [diff] [blame] | 282 | if (d_mountpoint(p)) { |
Ian Kent | e0a7aae | 2006-03-27 01:14:47 -0800 | [diff] [blame] | 283 | /* Can we umount this guy */ |
| 284 | if (autofs4_mount_busy(mnt, p)) |
Nick Piggin | 2fd6b7f | 2011-01-07 17:49:34 +1100 | [diff] [blame] | 285 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | |
Ian Kent | e0a7aae | 2006-03-27 01:14:47 -0800 | [diff] [blame] | 287 | /* Can we expire this guy */ |
| 288 | if (autofs4_can_expire(p, timeout, do_now)) |
Ian Kent | 1ce12ba | 2006-03-27 01:14:45 -0800 | [diff] [blame] | 289 | return p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | return NULL; |
| 293 | } |
| 294 | |
Ian Kent | 3a15e2a | 2006-03-27 01:14:55 -0800 | [diff] [blame] | 295 | /* Check if we can expire a direct mount (possibly a tree) */ |
Ian Kent | 8d7b48e | 2008-10-15 22:02:54 -0700 | [diff] [blame] | 296 | struct dentry *autofs4_expire_direct(struct super_block *sb, |
| 297 | struct vfsmount *mnt, |
| 298 | struct autofs_sb_info *sbi, |
| 299 | int how) |
Ian Kent | 3a15e2a | 2006-03-27 01:14:55 -0800 | [diff] [blame] | 300 | { |
| 301 | unsigned long timeout; |
| 302 | struct dentry *root = dget(sb->s_root); |
| 303 | int do_now = how & AUTOFS_EXP_IMMEDIATE; |
Ian Kent | b5b8017 | 2011-01-14 18:46:03 +0000 | [diff] [blame] | 304 | struct autofs_info *ino; |
Ian Kent | 3a15e2a | 2006-03-27 01:14:55 -0800 | [diff] [blame] | 305 | |
Ian Kent | c0ba7e5 | 2006-09-25 16:24:16 -0700 | [diff] [blame] | 306 | if (!root) |
Ian Kent | 3a15e2a | 2006-03-27 01:14:55 -0800 | [diff] [blame] | 307 | return NULL; |
| 308 | |
| 309 | now = jiffies; |
| 310 | timeout = sbi->exp_timeout; |
| 311 | |
Ian Kent | 3a15e2a | 2006-03-27 01:14:55 -0800 | [diff] [blame] | 312 | spin_lock(&sbi->fs_lock); |
Ian Kent | b5b8017 | 2011-01-14 18:46:03 +0000 | [diff] [blame] | 313 | ino = autofs4_dentry_ino(root); |
| 314 | /* No point expiring a pending mount */ |
Ian Kent | f9398c2 | 2011-03-25 01:51:14 +0800 | [diff] [blame] | 315 | if (ino->flags & AUTOFS_INF_PENDING) |
| 316 | goto out; |
Ian Kent | 3a15e2a | 2006-03-27 01:14:55 -0800 | [diff] [blame] | 317 | if (!autofs4_direct_busy(mnt, root, timeout, do_now)) { |
NeilBrown | 4d885f9 | 2014-10-13 15:52:20 -0700 | [diff] [blame] | 318 | ino->flags |= AUTOFS_INF_NO_RCU; |
Ian Kent | 3a15e2a | 2006-03-27 01:14:55 -0800 | [diff] [blame] | 319 | spin_unlock(&sbi->fs_lock); |
NeilBrown | 4d885f9 | 2014-10-13 15:52:20 -0700 | [diff] [blame] | 320 | synchronize_rcu(); |
| 321 | spin_lock(&sbi->fs_lock); |
| 322 | if (!autofs4_direct_busy(mnt, root, timeout, do_now)) { |
| 323 | ino->flags |= AUTOFS_INF_EXPIRING; |
| 324 | smp_mb(); |
| 325 | ino->flags &= ~AUTOFS_INF_NO_RCU; |
| 326 | init_completion(&ino->expire_complete); |
| 327 | spin_unlock(&sbi->fs_lock); |
| 328 | return root; |
| 329 | } |
| 330 | ino->flags &= ~AUTOFS_INF_NO_RCU; |
Ian Kent | 3a15e2a | 2006-03-27 01:14:55 -0800 | [diff] [blame] | 331 | } |
Ian Kent | f9398c2 | 2011-03-25 01:51:14 +0800 | [diff] [blame] | 332 | out: |
Ian Kent | 3a15e2a | 2006-03-27 01:14:55 -0800 | [diff] [blame] | 333 | spin_unlock(&sbi->fs_lock); |
| 334 | dput(root); |
| 335 | |
| 336 | return NULL; |
| 337 | } |
| 338 | |
NeilBrown | a5d1dba | 2014-10-13 15:52:16 -0700 | [diff] [blame] | 339 | /* Check if 'dentry' should expire, or return a nearby |
| 340 | * dentry that is suitable. |
| 341 | * If returned dentry is different from arg dentry, |
| 342 | * then a dget() reference was taken, else not. |
| 343 | */ |
| 344 | static struct dentry *should_expire(struct dentry *dentry, |
| 345 | struct vfsmount *mnt, |
| 346 | unsigned long timeout, |
| 347 | int how) |
| 348 | { |
| 349 | int do_now = how & AUTOFS_EXP_IMMEDIATE; |
| 350 | int exp_leaves = how & AUTOFS_EXP_LEAVES; |
| 351 | struct autofs_info *ino = autofs4_dentry_ino(dentry); |
| 352 | unsigned int ino_count; |
| 353 | |
| 354 | /* No point expiring a pending mount */ |
| 355 | if (ino->flags & AUTOFS_INF_PENDING) |
| 356 | return NULL; |
| 357 | |
| 358 | /* |
| 359 | * Case 1: (i) indirect mount or top level pseudo direct mount |
| 360 | * (autofs-4.1). |
| 361 | * (ii) indirect mount with offset mount, check the "/" |
| 362 | * offset (autofs-5.0+). |
| 363 | */ |
| 364 | if (d_mountpoint(dentry)) { |
Al Viro | a455589 | 2014-10-21 20:11:25 -0400 | [diff] [blame] | 365 | DPRINTK("checking mountpoint %p %pd", dentry, dentry); |
NeilBrown | a5d1dba | 2014-10-13 15:52:16 -0700 | [diff] [blame] | 366 | |
| 367 | /* Can we umount this guy */ |
| 368 | if (autofs4_mount_busy(mnt, dentry)) |
| 369 | return NULL; |
| 370 | |
| 371 | /* Can we expire this guy */ |
| 372 | if (autofs4_can_expire(dentry, timeout, do_now)) |
| 373 | return dentry; |
| 374 | return NULL; |
| 375 | } |
| 376 | |
David Howells | 2b0143b | 2015-03-17 22:25:59 +0000 | [diff] [blame] | 377 | if (d_really_is_positive(dentry) && d_is_symlink(dentry)) { |
Al Viro | a455589 | 2014-10-21 20:11:25 -0400 | [diff] [blame] | 378 | DPRINTK("checking symlink %p %pd", dentry, dentry); |
NeilBrown | a5d1dba | 2014-10-13 15:52:16 -0700 | [diff] [blame] | 379 | /* |
| 380 | * A symlink can't be "busy" in the usual sense so |
| 381 | * just check last used for expire timeout. |
| 382 | */ |
| 383 | if (autofs4_can_expire(dentry, timeout, do_now)) |
| 384 | return dentry; |
| 385 | return NULL; |
| 386 | } |
| 387 | |
| 388 | if (simple_empty(dentry)) |
| 389 | return NULL; |
| 390 | |
| 391 | /* Case 2: tree mount, expire iff entire tree is not busy */ |
| 392 | if (!exp_leaves) { |
| 393 | /* Path walk currently on this dentry? */ |
| 394 | ino_count = atomic_read(&ino->count) + 1; |
| 395 | if (d_count(dentry) > ino_count) |
| 396 | return NULL; |
| 397 | |
| 398 | if (!autofs4_tree_busy(mnt, dentry, timeout, do_now)) |
| 399 | return dentry; |
| 400 | /* |
| 401 | * Case 3: pseudo direct mount, expire individual leaves |
| 402 | * (autofs-4.1). |
| 403 | */ |
| 404 | } else { |
| 405 | /* Path walk currently on this dentry? */ |
| 406 | struct dentry *expired; |
| 407 | ino_count = atomic_read(&ino->count) + 1; |
| 408 | if (d_count(dentry) > ino_count) |
| 409 | return NULL; |
| 410 | |
| 411 | expired = autofs4_check_leaves(mnt, dentry, timeout, do_now); |
| 412 | if (expired) { |
| 413 | if (expired == dentry) |
| 414 | dput(dentry); |
| 415 | return expired; |
| 416 | } |
| 417 | } |
| 418 | return NULL; |
| 419 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | /* |
| 421 | * Find an eligible tree to time-out |
| 422 | * A tree is eligible if :- |
| 423 | * - it is unused by any user process |
| 424 | * - it has been unused for exp_timeout time |
| 425 | */ |
Ian Kent | 8d7b48e | 2008-10-15 22:02:54 -0700 | [diff] [blame] | 426 | struct dentry *autofs4_expire_indirect(struct super_block *sb, |
| 427 | struct vfsmount *mnt, |
| 428 | struct autofs_sb_info *sbi, |
| 429 | int how) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | { |
| 431 | unsigned long timeout; |
| 432 | struct dentry *root = sb->s_root; |
Nick Piggin | 2fd6b7f | 2011-01-07 17:49:34 +1100 | [diff] [blame] | 433 | struct dentry *dentry; |
NeilBrown | a5d1dba | 2014-10-13 15:52:16 -0700 | [diff] [blame] | 434 | struct dentry *expired; |
Ian Kent | 97e7449 | 2008-07-23 21:30:26 -0700 | [diff] [blame] | 435 | struct autofs_info *ino; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | |
Ian Kent | c0ba7e5 | 2006-09-25 16:24:16 -0700 | [diff] [blame] | 437 | if (!root) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | return NULL; |
| 439 | |
| 440 | now = jiffies; |
| 441 | timeout = sbi->exp_timeout; |
| 442 | |
Nick Piggin | 2fd6b7f | 2011-01-07 17:49:34 +1100 | [diff] [blame] | 443 | dentry = NULL; |
Ian Kent | d4a85e3 | 2011-03-25 01:51:20 +0800 | [diff] [blame] | 444 | while ((dentry = get_next_positive_subdir(dentry, root))) { |
Ian Kent | 97e7449 | 2008-07-23 21:30:26 -0700 | [diff] [blame] | 445 | spin_lock(&sbi->fs_lock); |
NeilBrown | 4d885f9 | 2014-10-13 15:52:20 -0700 | [diff] [blame] | 446 | ino = autofs4_dentry_ino(dentry); |
| 447 | if (ino->flags & AUTOFS_INF_NO_RCU) |
| 448 | expired = NULL; |
| 449 | else |
| 450 | expired = should_expire(dentry, mnt, timeout, how); |
| 451 | if (!expired) { |
| 452 | spin_unlock(&sbi->fs_lock); |
| 453 | continue; |
| 454 | } |
| 455 | ino = autofs4_dentry_ino(expired); |
| 456 | ino->flags |= AUTOFS_INF_NO_RCU; |
| 457 | spin_unlock(&sbi->fs_lock); |
| 458 | synchronize_rcu(); |
| 459 | spin_lock(&sbi->fs_lock); |
| 460 | if (should_expire(expired, mnt, timeout, how)) { |
NeilBrown | a5d1dba | 2014-10-13 15:52:16 -0700 | [diff] [blame] | 461 | if (expired != dentry) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | dput(dentry); |
NeilBrown | a5d1dba | 2014-10-13 15:52:16 -0700 | [diff] [blame] | 463 | goto found; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | } |
NeilBrown | 4d885f9 | 2014-10-13 15:52:20 -0700 | [diff] [blame] | 465 | |
| 466 | ino->flags &= ~AUTOFS_INF_NO_RCU; |
| 467 | if (expired != dentry) |
| 468 | dput(expired); |
Ian Kent | 97e7449 | 2008-07-23 21:30:26 -0700 | [diff] [blame] | 469 | spin_unlock(&sbi->fs_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | return NULL; |
Ian Kent | afec570 | 2008-05-01 04:35:06 -0700 | [diff] [blame] | 472 | |
| 473 | found: |
Al Viro | a455589 | 2014-10-21 20:11:25 -0400 | [diff] [blame] | 474 | DPRINTK("returning %p %pd", expired, expired); |
Ian Kent | 97e7449 | 2008-07-23 21:30:26 -0700 | [diff] [blame] | 475 | ino->flags |= AUTOFS_INF_EXPIRING; |
NeilBrown | 4d885f9 | 2014-10-13 15:52:20 -0700 | [diff] [blame] | 476 | smp_mb(); |
| 477 | ino->flags &= ~AUTOFS_INF_NO_RCU; |
Ian Kent | 6e60a9a | 2008-07-23 21:30:27 -0700 | [diff] [blame] | 478 | init_completion(&ino->expire_complete); |
Ian Kent | 97e7449 | 2008-07-23 21:30:26 -0700 | [diff] [blame] | 479 | spin_unlock(&sbi->fs_lock); |
Ian Kent | e785472 | 2011-03-25 01:51:31 +0800 | [diff] [blame] | 480 | spin_lock(&sbi->lookup_lock); |
Nick Piggin | 2fd6b7f | 2011-01-07 17:49:34 +1100 | [diff] [blame] | 481 | spin_lock(&expired->d_parent->d_lock); |
| 482 | spin_lock_nested(&expired->d_lock, DENTRY_D_LOCK_NESTED); |
Al Viro | 946e51f | 2014-10-26 19:19:16 -0400 | [diff] [blame] | 483 | list_move(&expired->d_parent->d_subdirs, &expired->d_child); |
Nick Piggin | 2fd6b7f | 2011-01-07 17:49:34 +1100 | [diff] [blame] | 484 | spin_unlock(&expired->d_lock); |
| 485 | spin_unlock(&expired->d_parent->d_lock); |
Ian Kent | e785472 | 2011-03-25 01:51:31 +0800 | [diff] [blame] | 486 | spin_unlock(&sbi->lookup_lock); |
Ian Kent | afec570 | 2008-05-01 04:35:06 -0700 | [diff] [blame] | 487 | return expired; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | } |
| 489 | |
NeilBrown | 23bfc2a | 2014-10-13 15:52:14 -0700 | [diff] [blame] | 490 | int autofs4_expire_wait(struct dentry *dentry, int rcu_walk) |
Ian Kent | 06a3598 | 2008-07-23 21:30:28 -0700 | [diff] [blame] | 491 | { |
| 492 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); |
| 493 | struct autofs_info *ino = autofs4_dentry_ino(dentry); |
| 494 | int status; |
| 495 | |
| 496 | /* Block on any pending expire */ |
NeilBrown | 4d885f9 | 2014-10-13 15:52:20 -0700 | [diff] [blame] | 497 | if (!(ino->flags & (AUTOFS_INF_EXPIRING | AUTOFS_INF_NO_RCU))) |
| 498 | return 0; |
| 499 | if (rcu_walk) |
| 500 | return -ECHILD; |
| 501 | |
Ian Kent | 06a3598 | 2008-07-23 21:30:28 -0700 | [diff] [blame] | 502 | spin_lock(&sbi->fs_lock); |
| 503 | if (ino->flags & AUTOFS_INF_EXPIRING) { |
| 504 | spin_unlock(&sbi->fs_lock); |
| 505 | |
Al Viro | a455589 | 2014-10-21 20:11:25 -0400 | [diff] [blame] | 506 | DPRINTK("waiting for expire %p name=%pd", dentry, dentry); |
Ian Kent | 06a3598 | 2008-07-23 21:30:28 -0700 | [diff] [blame] | 507 | |
| 508 | status = autofs4_wait(sbi, dentry, NFY_NONE); |
| 509 | wait_for_completion(&ino->expire_complete); |
| 510 | |
| 511 | DPRINTK("expire done status=%d", status); |
| 512 | |
Al Viro | 4b1ae27 | 2010-03-03 12:58:31 -0500 | [diff] [blame] | 513 | if (d_unhashed(dentry)) |
Ian Kent | 06a3598 | 2008-07-23 21:30:28 -0700 | [diff] [blame] | 514 | return -EAGAIN; |
| 515 | |
| 516 | return status; |
| 517 | } |
| 518 | spin_unlock(&sbi->fs_lock); |
| 519 | |
| 520 | return 0; |
| 521 | } |
| 522 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | /* Perform an expiry operation */ |
| 524 | int autofs4_expire_run(struct super_block *sb, |
| 525 | struct vfsmount *mnt, |
| 526 | struct autofs_sb_info *sbi, |
| 527 | struct autofs_packet_expire __user *pkt_p) |
| 528 | { |
| 529 | struct autofs_packet_expire pkt; |
Ian Kent | 97e7449 | 2008-07-23 21:30:26 -0700 | [diff] [blame] | 530 | struct autofs_info *ino; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | struct dentry *dentry; |
Ian Kent | 97e7449 | 2008-07-23 21:30:26 -0700 | [diff] [blame] | 532 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | |
| 534 | memset(&pkt,0,sizeof pkt); |
| 535 | |
| 536 | pkt.hdr.proto_version = sbi->version; |
| 537 | pkt.hdr.type = autofs_ptype_expire; |
| 538 | |
Ian Kent | 3a15e2a | 2006-03-27 01:14:55 -0800 | [diff] [blame] | 539 | if ((dentry = autofs4_expire_indirect(sb, mnt, sbi, 0)) == NULL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | return -EAGAIN; |
| 541 | |
| 542 | pkt.len = dentry->d_name.len; |
| 543 | memcpy(pkt.name, dentry->d_name.name, pkt.len); |
| 544 | pkt.name[pkt.len] = '\0'; |
| 545 | dput(dentry); |
| 546 | |
| 547 | if ( copy_to_user(pkt_p, &pkt, sizeof(struct autofs_packet_expire)) ) |
Ian Kent | 97e7449 | 2008-07-23 21:30:26 -0700 | [diff] [blame] | 548 | ret = -EFAULT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | |
Ian Kent | 97e7449 | 2008-07-23 21:30:26 -0700 | [diff] [blame] | 550 | spin_lock(&sbi->fs_lock); |
| 551 | ino = autofs4_dentry_ino(dentry); |
NeilBrown | 6ece08e | 2014-10-13 15:52:18 -0700 | [diff] [blame] | 552 | /* avoid rapid-fire expire attempts if expiry fails */ |
| 553 | ino->last_used = now; |
Ian Kent | 97e7449 | 2008-07-23 21:30:26 -0700 | [diff] [blame] | 554 | ino->flags &= ~AUTOFS_INF_EXPIRING; |
Ian Kent | 6e60a9a | 2008-07-23 21:30:27 -0700 | [diff] [blame] | 555 | complete_all(&ino->expire_complete); |
Ian Kent | 97e7449 | 2008-07-23 21:30:26 -0700 | [diff] [blame] | 556 | spin_unlock(&sbi->fs_lock); |
| 557 | |
| 558 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | } |
| 560 | |
Ian Kent | 56fcef7 | 2009-03-31 15:24:43 -0700 | [diff] [blame] | 561 | int autofs4_do_expire_multi(struct super_block *sb, struct vfsmount *mnt, |
| 562 | struct autofs_sb_info *sbi, int when) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | { |
| 564 | struct dentry *dentry; |
| 565 | int ret = -EAGAIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 566 | |
Ian Kent | a92daf6 | 2009-01-06 14:42:08 -0800 | [diff] [blame] | 567 | if (autofs_type_trigger(sbi->type)) |
Ian Kent | 56fcef7 | 2009-03-31 15:24:43 -0700 | [diff] [blame] | 568 | dentry = autofs4_expire_direct(sb, mnt, sbi, when); |
Ian Kent | 3a15e2a | 2006-03-27 01:14:55 -0800 | [diff] [blame] | 569 | else |
Ian Kent | 56fcef7 | 2009-03-31 15:24:43 -0700 | [diff] [blame] | 570 | dentry = autofs4_expire_indirect(sb, mnt, sbi, when); |
Ian Kent | 3a15e2a | 2006-03-27 01:14:55 -0800 | [diff] [blame] | 571 | |
| 572 | if (dentry) { |
Ian Kent | 1f5f2c3 | 2006-03-27 01:14:44 -0800 | [diff] [blame] | 573 | struct autofs_info *ino = autofs4_dentry_ino(dentry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | |
| 575 | /* This is synchronous because it makes the daemon a |
| 576 | little easier */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | ret = autofs4_wait(sbi, dentry, NFY_EXPIRE); |
Ian Kent | 6e60a9a | 2008-07-23 21:30:27 -0700 | [diff] [blame] | 578 | |
Ian Kent | 97e7449 | 2008-07-23 21:30:26 -0700 | [diff] [blame] | 579 | spin_lock(&sbi->fs_lock); |
NeilBrown | 6ece08e | 2014-10-13 15:52:18 -0700 | [diff] [blame] | 580 | /* avoid rapid-fire expire attempts if expiry fails */ |
| 581 | ino->last_used = now; |
Ian Kent | 1f5f2c3 | 2006-03-27 01:14:44 -0800 | [diff] [blame] | 582 | ino->flags &= ~AUTOFS_INF_EXPIRING; |
Ian Kent | 6e60a9a | 2008-07-23 21:30:27 -0700 | [diff] [blame] | 583 | complete_all(&ino->expire_complete); |
Ian Kent | 97e7449 | 2008-07-23 21:30:26 -0700 | [diff] [blame] | 584 | spin_unlock(&sbi->fs_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | dput(dentry); |
| 586 | } |
Ian Kent | 1f5f2c3 | 2006-03-27 01:14:44 -0800 | [diff] [blame] | 587 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 588 | return ret; |
| 589 | } |
| 590 | |
Ian Kent | 56fcef7 | 2009-03-31 15:24:43 -0700 | [diff] [blame] | 591 | /* Call repeatedly until it returns -EAGAIN, meaning there's nothing |
| 592 | more to be done */ |
| 593 | int autofs4_expire_multi(struct super_block *sb, struct vfsmount *mnt, |
| 594 | struct autofs_sb_info *sbi, int __user *arg) |
| 595 | { |
| 596 | int do_now = 0; |
| 597 | |
| 598 | if (arg && get_user(do_now, arg)) |
| 599 | return -EFAULT; |
| 600 | |
| 601 | return autofs4_do_expire_multi(sb, mnt, sbi, do_now); |
| 602 | } |
| 603 | |