diff options
author | John Baldwin <jhb@FreeBSD.org> | 2006-11-07 19:45:05 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2006-11-07 19:45:05 +0000 |
commit | 6b8de13ab47a828c872aa79e04b0a2b666a8109e (patch) | |
tree | dd396f33e49466af6664a21f71c0822a86831343 /sys/kern/vfs_subr.c | |
parent | 2d58d446512d3efdcc29c18ce9bc1a05b07b0815 (diff) | |
download | src-6b8de13ab47a828c872aa79e04b0a2b666a8109e.tar.gz src-6b8de13ab47a828c872aa79e04b0a2b666a8109e.zip |
Simplify operations with sync_mtx in sched_sync():
- Don't drop the lock just to reacquire it again to check rushjob, this
only wastes time.
- Use msleep() to drop the mutex while sleeping instead of explicitly
unlocking around tsleep.
Reviewed by: pjd
Notes
Notes:
svn path=/head/; revision=164073
Diffstat (limited to 'sys/kern/vfs_subr.c')
-rw-r--r-- | sys/kern/vfs_subr.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 2d9a9f8e9931..b9a65da96466 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1631,8 +1631,8 @@ sched_sync(void) EVENTHANDLER_REGISTER(shutdown_pre_sync, syncer_shutdown, td->td_proc, SHUTDOWN_PRI_LAST); + mtx_lock(&sync_mtx); for (;;) { - mtx_lock(&sync_mtx); if (syncer_state == SYNCER_FINAL_DELAY && syncer_final_iter == 0) { mtx_unlock(&sync_mtx); @@ -1697,7 +1697,6 @@ sched_sync(void) } if (syncer_state == SYNCER_FINAL_DELAY && syncer_final_iter > 0) syncer_final_iter--; - mtx_unlock(&sync_mtx); /* * The variable rushjob allows the kernel to speed up the * processing of the filesystem syncer process. A rushjob @@ -1708,13 +1707,10 @@ sched_sync(void) * ahead of the disk that the kernel memory pool is being * threatened with exhaustion. */ - mtx_lock(&sync_mtx); if (rushjob > 0) { rushjob -= 1; - mtx_unlock(&sync_mtx); continue; } - mtx_unlock(&sync_mtx); /* * Just sleep for a short period of time between * iterations when shutting down to allow some I/O @@ -1728,10 +1724,10 @@ sched_sync(void) * filesystem activity. */ if (syncer_state != SYNCER_RUNNING) - tsleep(&dummychan, PPAUSE, "syncfnl", + msleep(&dummychan, &sync_mtx, PPAUSE, "syncfnl", hz / SYNCER_SHUTDOWN_SPEEDUP); else if (time_uptime == starttime) - tsleep(&lbolt, PPAUSE, "syncer", 0); + msleep(&lbolt, &sync_mtx, PPAUSE, "syncer", 0); } } |