Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'autofs' (patches from Ian Kent)

Merge emailed autofs cleanup/fix patches from Ian Kent

* autofs:
autofs4 - use simple_empty() for empty directory check
autofs4 - dont clear DCACHE_NEED_AUTOMOUNT on rootless mount

+42 -52
-9
fs/autofs4/expire.c
··· 548 548 549 549 spin_lock(&sbi->fs_lock); 550 550 ino->flags &= ~AUTOFS_INF_EXPIRING; 551 - spin_lock(&dentry->d_lock); 552 - if (!ret) { 553 - if ((IS_ROOT(dentry) || 554 - (autofs_type_indirect(sbi->type) && 555 - IS_ROOT(dentry->d_parent))) && 556 - !(dentry->d_flags & DCACHE_NEED_AUTOMOUNT)) 557 - __managed_dentry_set_automount(dentry); 558 - } 559 - spin_unlock(&dentry->d_lock); 560 551 complete_all(&ino->expire_complete); 561 552 spin_unlock(&sbi->fs_lock); 562 553 dput(dentry);
+42 -43
fs/autofs4/root.c
··· 124 124 * it. 125 125 */ 126 126 spin_lock(&sbi->lookup_lock); 127 - spin_lock(&dentry->d_lock); 128 - if (!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs)) { 129 - spin_unlock(&dentry->d_lock); 127 + if (!d_mountpoint(dentry) && simple_empty(dentry)) { 130 128 spin_unlock(&sbi->lookup_lock); 131 129 return -ENOENT; 132 130 } 133 - spin_unlock(&dentry->d_lock); 134 131 spin_unlock(&sbi->lookup_lock); 135 132 136 133 out: ··· 352 355 status = autofs4_mount_wait(dentry); 353 356 if (status) 354 357 return ERR_PTR(status); 355 - spin_lock(&sbi->fs_lock); 356 358 goto done; 357 359 } 358 360 ··· 360 364 * having d_mountpoint() true, so there's no need to call back 361 365 * to the daemon. 362 366 */ 363 - if (dentry->d_inode && S_ISLNK(dentry->d_inode->i_mode)) 367 + if (dentry->d_inode && S_ISLNK(dentry->d_inode->i_mode)) { 368 + spin_unlock(&sbi->fs_lock); 364 369 goto done; 370 + } 371 + 365 372 if (!d_mountpoint(dentry)) { 366 373 /* 367 374 * It's possible that user space hasn't removed directories ··· 378 379 * require user space behave. 379 380 */ 380 381 if (sbi->version > 4) { 381 - if (have_submounts(dentry)) 382 - goto done; 383 - } else { 384 - spin_lock(&dentry->d_lock); 385 - if (!list_empty(&dentry->d_subdirs)) { 386 - spin_unlock(&dentry->d_lock); 382 + if (have_submounts(dentry)) { 383 + spin_unlock(&sbi->fs_lock); 387 384 goto done; 388 385 } 389 - spin_unlock(&dentry->d_lock); 386 + } else { 387 + if (!simple_empty(dentry)) 388 + goto done; 390 389 } 391 390 ino->flags |= AUTOFS_INF_PENDING; 392 391 spin_unlock(&sbi->fs_lock); ··· 396 399 return ERR_PTR(status); 397 400 } 398 401 } 399 - done: 400 - if (!(ino->flags & AUTOFS_INF_EXPIRING)) { 401 - /* 402 - * Any needed mounting has been completed and the path 403 - * updated so clear DCACHE_NEED_AUTOMOUNT so we don't 404 - * call ->d_automount() on rootless multi-mounts since 405 - * it can lead to an incorrect ELOOP error return. 406 - * 407 - * Only clear DMANAGED_AUTOMOUNT for rootless multi-mounts and 408 - * symlinks as in all other cases the dentry will be covered by 409 - * an actual mount so ->d_automount() won't be called during 410 - * the follow. 411 - */ 412 - spin_lock(&dentry->d_lock); 413 - if ((!d_mountpoint(dentry) && 414 - !list_empty(&dentry->d_subdirs)) || 415 - (dentry->d_inode && S_ISLNK(dentry->d_inode->i_mode))) 416 - __managed_dentry_clear_automount(dentry); 417 - spin_unlock(&dentry->d_lock); 418 - } 419 402 spin_unlock(&sbi->fs_lock); 420 - 403 + done: 421 404 /* Mount succeeded, check if we ended up with a new dentry */ 422 405 dentry = autofs4_mountpoint_changed(path); 423 406 if (!dentry) ··· 409 432 int autofs4_d_manage(struct dentry *dentry, bool rcu_walk) 410 433 { 411 434 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); 435 + struct autofs_info *ino = autofs4_dentry_ino(dentry); 436 + int status; 412 437 413 438 DPRINTK("dentry=%p %.*s", 414 439 dentry, dentry->d_name.len, dentry->d_name.name); ··· 435 456 * This dentry may be under construction so wait on mount 436 457 * completion. 437 458 */ 438 - return autofs4_mount_wait(dentry); 459 + status = autofs4_mount_wait(dentry); 460 + if (status) 461 + return status; 462 + 463 + spin_lock(&sbi->fs_lock); 464 + /* 465 + * If the dentry has been selected for expire while we slept 466 + * on the lock then it might go away. We'll deal with that in 467 + * ->d_automount() and wait on a new mount if the expire 468 + * succeeds or return here if it doesn't (since there's no 469 + * mount to follow with a rootless multi-mount). 470 + */ 471 + if (!(ino->flags & AUTOFS_INF_EXPIRING)) { 472 + /* 473 + * Any needed mounting has been completed and the path 474 + * updated so check if this is a rootless multi-mount so 475 + * we can avoid needless calls ->d_automount() and avoid 476 + * an incorrect ELOOP error return. 477 + */ 478 + if ((!d_mountpoint(dentry) && !simple_empty(dentry)) || 479 + (dentry->d_inode && S_ISLNK(dentry->d_inode->i_mode))) 480 + status = -EISDIR; 481 + } 482 + spin_unlock(&sbi->fs_lock); 483 + 484 + return status; 439 485 } 440 486 441 487 /* Lookups in the root directory */ ··· 603 599 604 600 spin_lock(&sbi->lookup_lock); 605 601 __autofs4_add_expiring(dentry); 606 - spin_lock(&dentry->d_lock); 607 - __d_drop(dentry); 608 - spin_unlock(&dentry->d_lock); 602 + d_drop(dentry); 609 603 spin_unlock(&sbi->lookup_lock); 610 604 611 605 return 0; ··· 674 672 return -EACCES; 675 673 676 674 spin_lock(&sbi->lookup_lock); 677 - spin_lock(&dentry->d_lock); 678 - if (!list_empty(&dentry->d_subdirs)) { 679 - spin_unlock(&dentry->d_lock); 675 + if (!simple_empty(dentry)) { 680 676 spin_unlock(&sbi->lookup_lock); 681 677 return -ENOTEMPTY; 682 678 } 683 679 __autofs4_add_expiring(dentry); 684 - __d_drop(dentry); 685 - spin_unlock(&dentry->d_lock); 680 + d_drop(dentry); 686 681 spin_unlock(&sbi->lookup_lock); 687 682 688 683 if (sbi->version < 5)