aboutsummaryrefslogtreecommitdiffstats
path: root/fs/autofs4/expire.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/autofs4/expire.c')
-rw-r--r--fs/autofs4/expire.c54
1 files changed, 26 insertions, 28 deletions
diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c
index dc39589df165..bcc17f533699 100644
--- a/fs/autofs4/expire.c
+++ b/fs/autofs4/expire.c
@@ -16,7 +16,7 @@
16 16
17static unsigned long now; 17static unsigned long now;
18 18
19/* Check if a dentry can be expired return 1 if it can else return 0 */ 19/* Check if a dentry can be expired */
20static inline int autofs4_can_expire(struct dentry *dentry, 20static inline int autofs4_can_expire(struct dentry *dentry,
21 unsigned long timeout, int do_now) 21 unsigned long timeout, int do_now)
22{ 22{
@@ -41,14 +41,13 @@ static inline int autofs4_can_expire(struct dentry *dentry,
41 attempts if expire fails the first time */ 41 attempts if expire fails the first time */
42 ino->last_used = now; 42 ino->last_used = now;
43 } 43 }
44
45 return 1; 44 return 1;
46} 45}
47 46
48/* Check a mount point for busyness return 1 if not busy, otherwise */ 47/* Check a mount point for busyness */
49static int autofs4_check_mount(struct vfsmount *mnt, struct dentry *dentry) 48static int autofs4_mount_busy(struct vfsmount *mnt, struct dentry *dentry)
50{ 49{
51 int status = 0; 50 int status = 1;
52 51
53 DPRINTK("dentry %p %.*s", 52 DPRINTK("dentry %p %.*s",
54 dentry, (int)dentry->d_name.len, dentry->d_name.name); 53 dentry, (int)dentry->d_name.len, dentry->d_name.name);
@@ -65,7 +64,7 @@ static int autofs4_check_mount(struct vfsmount *mnt, struct dentry *dentry)
65 64
66 /* The big question */ 65 /* The big question */
67 if (may_umount_tree(mnt) == 0) 66 if (may_umount_tree(mnt) == 0)
68 status = 1; 67 status = 0;
69done: 68done:
70 DPRINTK("returning = %d", status); 69 DPRINTK("returning = %d", status);
71 mntput(mnt); 70 mntput(mnt);
@@ -75,30 +74,29 @@ done:
75 74
76/* Check a directory tree of mount points for busyness 75/* Check a directory tree of mount points for busyness
77 * The tree is not busy iff no mountpoints are busy 76 * The tree is not busy iff no mountpoints are busy
78 * Return 1 if the tree is busy or 0 otherwise
79 */ 77 */
80static int autofs4_check_tree(struct vfsmount *mnt, 78static int autofs4_tree_busy(struct vfsmount *mnt,
81 struct dentry *top, 79 struct dentry *top,
82 unsigned long timeout, 80 unsigned long timeout,
83 int do_now) 81 int do_now)
84{ 82{
85 struct dentry *this_parent = top; 83 struct dentry *this_parent = top;
86 struct list_head *next; 84 struct list_head *next;
87 85
88 DPRINTK("parent %p %.*s", 86 DPRINTK("top %p %.*s",
89 top, (int)top->d_name.len, top->d_name.name); 87 top, (int)top->d_name.len, top->d_name.name);
90 88
91 /* Negative dentry - give up */ 89 /* Negative dentry - give up */
92 if (!simple_positive(top)) 90 if (!simple_positive(top))
93 return 0; 91 return 1;
94 92
95 /* Timeout of a tree mount is determined by its top dentry */ 93 /* Timeout of a tree mount is determined by its top dentry */
96 if (!autofs4_can_expire(top, timeout, do_now)) 94 if (!autofs4_can_expire(top, timeout, do_now))
97 return 0; 95 return 1;
98 96
99 /* Is someone visiting anywhere in the tree ? */ 97 /* Is someone visiting anywhere in the tree ? */
100 if (may_umount_tree(mnt)) 98 if (may_umount_tree(mnt))
101 return 0; 99 return 1;
102 100
103 spin_lock(&dcache_lock); 101 spin_lock(&dcache_lock);
104repeat: 102repeat:
@@ -126,9 +124,9 @@ resume:
126 124
127 if (d_mountpoint(dentry)) { 125 if (d_mountpoint(dentry)) {
128 /* First busy => tree busy */ 126 /* First busy => tree busy */
129 if (!autofs4_check_mount(mnt, dentry)) { 127 if (autofs4_mount_busy(mnt, dentry)) {
130 dput(dentry); 128 dput(dentry);
131 return 0; 129 return 1;
132 } 130 }
133 } 131 }
134 132
@@ -144,7 +142,7 @@ resume:
144 } 142 }
145 spin_unlock(&dcache_lock); 143 spin_unlock(&dcache_lock);
146 144
147 return 1; 145 return 0;
148} 146}
149 147
150static struct dentry *autofs4_check_leaves(struct vfsmount *mnt, 148static struct dentry *autofs4_check_leaves(struct vfsmount *mnt,
@@ -188,7 +186,7 @@ resume:
188 goto cont; 186 goto cont;
189 187
190 /* Can we umount this guy */ 188 /* Can we umount this guy */
191 if (autofs4_check_mount(mnt, dentry)) 189 if (!autofs4_mount_busy(mnt, dentry))
192 return dentry; 190 return dentry;
193 191
194 } 192 }
@@ -241,7 +239,7 @@ static struct dentry *autofs4_expire(struct super_block *sb,
241 struct dentry *dentry = list_entry(next, struct dentry, d_u.d_child); 239 struct dentry *dentry = list_entry(next, struct dentry, d_u.d_child);
242 240
243 /* Negative dentry - give up */ 241 /* Negative dentry - give up */
244 if ( !simple_positive(dentry) ) { 242 if (!simple_positive(dentry)) {
245 next = next->next; 243 next = next->next;
246 continue; 244 continue;
247 } 245 }
@@ -259,21 +257,21 @@ static struct dentry *autofs4_expire(struct super_block *sb,
259 goto next; 257 goto next;
260 258
261 /* Can we umount this guy */ 259 /* Can we umount this guy */
262 if (autofs4_check_mount(mnt, dentry)) { 260 if (!autofs4_mount_busy(mnt, dentry)) {
263 expired = dentry; 261 expired = dentry;
264 break; 262 break;
265 } 263 }
266 goto next; 264 goto next;
267 } 265 }
268 266
269 if ( simple_empty(dentry) ) 267 if (simple_empty(dentry))
270 goto next; 268 goto next;
271 269
272 /* Case 2: tree mount, expire iff entire tree is not busy */ 270 /* Case 2: tree mount, expire iff entire tree is not busy */
273 if (!exp_leaves) { 271 if (!exp_leaves) {
274 /* Lock the tree as we must expire as a whole */ 272 /* Lock the tree as we must expire as a whole */
275 spin_lock(&sbi->fs_lock); 273 spin_lock(&sbi->fs_lock);
276 if (autofs4_check_tree(mnt, dentry, timeout, do_now)) { 274 if (!autofs4_tree_busy(mnt, dentry, timeout, do_now)) {
277 struct autofs_info *inf = autofs4_dentry_ino(dentry); 275 struct autofs_info *inf = autofs4_dentry_ino(dentry);
278 276
279 /* Set this flag early to catch sys_chdir and the like */ 277 /* Set this flag early to catch sys_chdir and the like */
@@ -297,7 +295,7 @@ next:
297 next = next->next; 295 next = next->next;
298 } 296 }
299 297
300 if ( expired ) { 298 if (expired) {
301 DPRINTK("returning %p %.*s", 299 DPRINTK("returning %p %.*s",
302 expired, (int)expired->d_name.len, expired->d_name.name); 300 expired, (int)expired->d_name.len, expired->d_name.name);
303 spin_lock(&dcache_lock); 301 spin_lock(&dcache_lock);
@@ -352,16 +350,16 @@ int autofs4_expire_multi(struct super_block *sb, struct vfsmount *mnt,
352 return -EFAULT; 350 return -EFAULT;
353 351
354 if ((dentry = autofs4_expire(sb, mnt, sbi, do_now)) != NULL) { 352 if ((dentry = autofs4_expire(sb, mnt, sbi, do_now)) != NULL) {
355 struct autofs_info *de_info = autofs4_dentry_ino(dentry); 353 struct autofs_info *ino = autofs4_dentry_ino(dentry);
356 354
357 /* This is synchronous because it makes the daemon a 355 /* This is synchronous because it makes the daemon a
358 little easier */ 356 little easier */
359 de_info->flags |= AUTOFS_INF_EXPIRING; 357 ino->flags |= AUTOFS_INF_EXPIRING;
360 ret = autofs4_wait(sbi, dentry, NFY_EXPIRE); 358 ret = autofs4_wait(sbi, dentry, NFY_EXPIRE);
361 de_info->flags &= ~AUTOFS_INF_EXPIRING; 359 ino->flags &= ~AUTOFS_INF_EXPIRING;
362 dput(dentry); 360 dput(dentry);
363 } 361 }
364 362
365 return ret; 363 return ret;
366} 364}
367 365