diff options
author | kib <kib@FreeBSD.org> | 2014-12-08 16:48:57 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2014-12-08 16:48:57 +0000 |
commit | 1a8d4344d0a617f3f123dabedfb9c1615b94ebfa (patch) | |
tree | dab51d0fd4666c42270ad0e89f8f1417a0aa7c34 /sys/kern/vfs_subr.c | |
parent | 0957112e3c431e30f0931bb908df03cded76c4d2 (diff) | |
download | FreeBSD-src-1a8d4344d0a617f3f123dabedfb9c1615b94ebfa.zip FreeBSD-src-1a8d4344d0a617f3f123dabedfb9c1615b94ebfa.tar.gz |
Add functions syncer_suspend() and syncer_resume(), which are supposed
to be called before suspension and after resume, correspondingly. The
syncer_suspend() ensures that all filesystems dirty data and metadata
are saved to the permanent storage, and stops kernel threads which
might modify filesystems. The syncer_resume() restores stopped
threads.
For now, only syncer is stopped. This is needed, because each sync
loop causes superblock updates for UFS.
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Diffstat (limited to 'sys/kern/vfs_subr.c')
-rw-r--r-- | sys/kern/vfs_subr.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 345aad6..b4dde06 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1773,6 +1773,8 @@ sync_vnode(struct synclist *slp, struct bufobj **bo, struct thread *td) return (0); } +static int first_printf = 1; + /* * System filesystem synchronizer daemon. */ @@ -1791,7 +1793,6 @@ sched_sync(void) last_work_seen = 0; syncer_final_iter = 0; - first_printf = 1; syncer_state = SYNCER_RUNNING; starttime = time_uptime; td->td_pflags |= TDP_NORUNNINGBUF; @@ -1955,6 +1956,25 @@ syncer_shutdown(void *arg, int howto) kproc_shutdown(arg, howto); } +void +syncer_suspend(void) +{ + + syncer_shutdown(updateproc, 0); +} + +void +syncer_resume(void) +{ + + mtx_lock(&sync_mtx); + first_printf = 1; + syncer_state = SYNCER_RUNNING; + mtx_unlock(&sync_mtx); + cv_broadcast(&sync_wakeup); + kproc_resume(updateproc); +} + /* * Reassign a buffer from one vnode to another. * Used to assign file specific control information |