* Suspend write operations on all local writeable filesystems. Does * full sync of them in the process. * * Iterate over the mount points in reverse order, suspending most * recently mounted filesystems first. It handles a case where a * filesystem mounted from a md(4) vnode-backed device should be * suspended before the filesystem that owns the vnode. */
| 2552 | * suspended before the filesystem that owns the vnode. |
| 2553 | */ |
| 2554 | void |
| 2555 | suspend_all_fs(void) |
| 2556 | { |
| 2557 | struct mount *mp; |
| 2558 | int error; |
| 2559 | |
| 2560 | mtx_lock(&mountlist_mtx); |
| 2561 | TAILQ_FOREACH_REVERSE(mp, &mountlist, mntlist, mnt_list) { |
| 2562 | error = vfs_busy(mp, MBF_MNTLSTLOCK | MBF_NOWAIT); |
| 2563 | if (error != 0) |
| 2564 | continue; |
| 2565 | if ((mp->mnt_flag & (MNT_RDONLY | MNT_LOCAL)) != MNT_LOCAL || |
| 2566 | (mp->mnt_kern_flag & MNTK_SUSPEND) != 0) { |
| 2567 | mtx_lock(&mountlist_mtx); |
| 2568 | vfs_unbusy(mp); |
| 2569 | continue; |
| 2570 | } |
| 2571 | error = vfs_write_suspend(mp, 0); |
| 2572 | if (error == 0) { |
| 2573 | MNT_ILOCK(mp); |
| 2574 | MPASS((mp->mnt_kern_flag & MNTK_SUSPEND_ALL) == 0); |
| 2575 | mp->mnt_kern_flag |= MNTK_SUSPEND_ALL; |
| 2576 | MNT_IUNLOCK(mp); |
| 2577 | mtx_lock(&mountlist_mtx); |
| 2578 | } else { |
| 2579 | printf("suspend of %s failed, error %d\n", |
| 2580 | mp->mnt_stat.f_mntonname, error); |
| 2581 | mtx_lock(&mountlist_mtx); |
| 2582 | vfs_unbusy(mp); |
| 2583 | } |
| 2584 | } |
| 2585 | mtx_unlock(&mountlist_mtx); |
| 2586 | } |
| 2587 | |
| 2588 | void |
| 2589 | resume_all_fs(void) |
nothing calls this directly
no test coverage detected