autofs4 - reinstate last used update on access

When direct (and offset) mounts were introduced the the last used
timeout could no longer be updated in ->d_revalidate(). This is
because covered direct mounts would be followed over without calling
the autofs file system. As a result the definition of the busyness
check for all entries was changed to be "actually busy" being an open
file or working directory within the automount. But now we have a call
back in the follow so the last used update on any access can be
re-instated. This requires DCACHE_MANAGE_TRANSIT to always be set.

Signed-off-by: Ian Kent <raven@themaw.net>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

authored by Ian Kent and committed by Al Viro 3c319985 62a7375e

+14 -34
+2 -11
fs/autofs4/expire.c
··· 294 spin_unlock(&sbi->fs_lock); 295 return NULL; 296 } 297 - managed_dentry_set_transit(root); 298 if (!autofs4_direct_busy(mnt, root, timeout, do_now)) { 299 struct autofs_info *ino = autofs4_dentry_ino(root); 300 ino->flags |= AUTOFS_INF_EXPIRING; ··· 301 spin_unlock(&sbi->fs_lock); 302 return root; 303 } 304 - managed_dentry_clear_transit(root); 305 spin_unlock(&sbi->fs_lock); 306 dput(root); 307 ··· 339 ino = autofs4_dentry_ino(dentry); 340 /* No point expiring a pending mount */ 341 if (ino->flags & AUTOFS_INF_PENDING) 342 - goto cont; 343 - managed_dentry_set_transit(dentry); 344 345 /* 346 * Case 1: (i) indirect mount or top level pseudo direct mount ··· 399 } 400 } 401 next: 402 - managed_dentry_clear_transit(dentry); 403 - cont: 404 spin_unlock(&sbi->fs_lock); 405 } 406 return NULL; ··· 479 spin_lock(&sbi->fs_lock); 480 ino = autofs4_dentry_ino(dentry); 481 ino->flags &= ~AUTOFS_INF_EXPIRING; 482 - if (!d_unhashed(dentry)) 483 - managed_dentry_clear_transit(dentry); 484 complete_all(&ino->expire_complete); 485 spin_unlock(&sbi->fs_lock); 486 ··· 506 spin_lock(&sbi->fs_lock); 507 ino->flags &= ~AUTOFS_INF_EXPIRING; 508 spin_lock(&dentry->d_lock); 509 - if (ret) 510 - __managed_dentry_clear_transit(dentry); 511 - else { 512 if ((IS_ROOT(dentry) || 513 (autofs_type_indirect(sbi->type) && 514 IS_ROOT(dentry->d_parent))) &&
··· 294 spin_unlock(&sbi->fs_lock); 295 return NULL; 296 } 297 if (!autofs4_direct_busy(mnt, root, timeout, do_now)) { 298 struct autofs_info *ino = autofs4_dentry_ino(root); 299 ino->flags |= AUTOFS_INF_EXPIRING; ··· 302 spin_unlock(&sbi->fs_lock); 303 return root; 304 } 305 spin_unlock(&sbi->fs_lock); 306 dput(root); 307 ··· 341 ino = autofs4_dentry_ino(dentry); 342 /* No point expiring a pending mount */ 343 if (ino->flags & AUTOFS_INF_PENDING) 344 + goto next; 345 346 /* 347 * Case 1: (i) indirect mount or top level pseudo direct mount ··· 402 } 403 } 404 next: 405 spin_unlock(&sbi->fs_lock); 406 } 407 return NULL; ··· 484 spin_lock(&sbi->fs_lock); 485 ino = autofs4_dentry_ino(dentry); 486 ino->flags &= ~AUTOFS_INF_EXPIRING; 487 complete_all(&ino->expire_complete); 488 spin_unlock(&sbi->fs_lock); 489 ··· 513 spin_lock(&sbi->fs_lock); 514 ino->flags &= ~AUTOFS_INF_EXPIRING; 515 spin_lock(&dentry->d_lock); 516 + if (!ret) { 517 if ((IS_ROOT(dentry) || 518 (autofs_type_indirect(sbi->type) && 519 IS_ROOT(dentry->d_parent))) &&
+12 -23
fs/autofs4/root.c
··· 275 { 276 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); 277 struct autofs_info *ino = autofs4_dentry_ino(dentry); 278 - int status; 279 280 if (ino->flags & AUTOFS_INF_PENDING) { 281 DPRINTK("waiting for mount name=%.*s", 282 dentry->d_name.len, dentry->d_name.name); 283 status = autofs4_wait(sbi, dentry, NFY_MOUNT); 284 DPRINTK("mount wait done status=%d", status); 285 - ino->last_used = jiffies; 286 - return status; 287 } 288 - return 0; 289 } 290 291 static int do_expire_wait(struct dentry *dentry) ··· 318 */ 319 if (autofs_type_indirect(sbi->type) && d_unhashed(dentry)) { 320 struct dentry *parent = dentry->d_parent; 321 struct dentry *new = d_lookup(parent, &dentry->d_name); 322 if (!new) 323 return NULL; 324 dput(path->dentry); 325 path->dentry = new; 326 } ··· 339 340 DPRINTK("dentry=%p %.*s", 341 dentry, dentry->d_name.len, dentry->d_name.name); 342 - 343 - /* 344 - * Someone may have manually umounted this or it was a submount 345 - * that has gone away. 346 - */ 347 - spin_lock(&dentry->d_lock); 348 - if (!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs)) { 349 - if (!(dentry->d_flags & DCACHE_MANAGE_TRANSIT) && 350 - (dentry->d_flags & DCACHE_NEED_AUTOMOUNT)) 351 - __managed_dentry_set_transit(path->dentry); 352 - } 353 - spin_unlock(&dentry->d_lock); 354 355 /* The daemon never triggers a mount. */ 356 if (autofs4_oz_mode(sbi)) ··· 408 done: 409 if (!(ino->flags & AUTOFS_INF_EXPIRING)) { 410 /* 411 - * Any needed mounting has been completed and the path updated 412 - * so turn this into a normal dentry so we don't continually 413 - * call ->d_automount() and ->d_manage(). 414 - */ 415 - spin_lock(&dentry->d_lock); 416 - __managed_dentry_clear_transit(dentry); 417 - /* 418 * Only clear DMANAGED_AUTOMOUNT for rootless multi-mounts and 419 * symlinks as in all other cases the dentry will be covered by 420 * an actual mount so ->d_automount() won't be called during 421 * the follow. 422 */ 423 if ((!d_mountpoint(dentry) && 424 !list_empty(&dentry->d_subdirs)) || 425 (dentry->d_inode && S_ISLNK(dentry->d_inode->i_mode)))
··· 275 { 276 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); 277 struct autofs_info *ino = autofs4_dentry_ino(dentry); 278 + int status = 0; 279 280 if (ino->flags & AUTOFS_INF_PENDING) { 281 DPRINTK("waiting for mount name=%.*s", 282 dentry->d_name.len, dentry->d_name.name); 283 status = autofs4_wait(sbi, dentry, NFY_MOUNT); 284 DPRINTK("mount wait done status=%d", status); 285 } 286 + ino->last_used = jiffies; 287 + return status; 288 } 289 290 static int do_expire_wait(struct dentry *dentry) ··· 319 */ 320 if (autofs_type_indirect(sbi->type) && d_unhashed(dentry)) { 321 struct dentry *parent = dentry->d_parent; 322 + struct autofs_info *ino; 323 struct dentry *new = d_lookup(parent, &dentry->d_name); 324 if (!new) 325 return NULL; 326 + ino = autofs4_dentry_ino(new); 327 + ino->last_used = jiffies; 328 dput(path->dentry); 329 path->dentry = new; 330 } ··· 337 338 DPRINTK("dentry=%p %.*s", 339 dentry, dentry->d_name.len, dentry->d_name.name); 340 341 /* The daemon never triggers a mount. */ 342 if (autofs4_oz_mode(sbi)) ··· 418 done: 419 if (!(ino->flags & AUTOFS_INF_EXPIRING)) { 420 /* 421 + * Any needed mounting has been completed and the path 422 + * updated so clear DCACHE_NEED_AUTOMOUNT so we don't 423 + * call ->d_automount() on rootless multi-mounts since 424 + * it can lead to an incorrect ELOOP error return. 425 + * 426 * Only clear DMANAGED_AUTOMOUNT for rootless multi-mounts and 427 * symlinks as in all other cases the dentry will be covered by 428 * an actual mount so ->d_automount() won't be called during 429 * the follow. 430 */ 431 + spin_lock(&dentry->d_lock); 432 if ((!d_mountpoint(dentry) && 433 !list_empty(&dentry->d_subdirs)) || 434 (dentry->d_inode && S_ISLNK(dentry->d_inode->i_mode)))