From aa1bfd980e3d7a445119a5675015ac921274ace7 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Thu, 19 Aug 2010 22:33:35 -0700 Subject: [PATCH] kernel - limit running io writes during fsync * The fsync code was queueing an unlimited number of BUF/BIOs while flushing a file, which creates a very large write burden on the system, read stalls due to locked buffers, and can also blow out things like dm_target_crypt which must allocate side-buffers for the data. * Fixes kmalloc exhaustion panics with dm_crypt. * Improves read performance under heavy write loads (e.g. blogbench). --- sys/kern/vfs_bio.c | 2 +- sys/kern/vfs_subr.c | 1 + sys/sys/buf.h | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 0c25b037bc..0bb9198077 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -298,7 +298,7 @@ bufcountwakeup(void) * B_LOCKED dirty buffers, so also wait for at least one running buffer * to complete. */ -static __inline void +void waitrunningbufspace(void) { int limit = hirunningspace * 2 / 3; diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 2ca81a881e..6d0efe3e68 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -813,6 +813,7 @@ vfsync_bp(struct buf *bp, void *data) bremfree(bp); bawrite(bp); } + waitrunningbufspace(); if (info->lazylimit && info->lazycount >= info->lazylimit) error = 1; else diff --git a/sys/sys/buf.h b/sys/sys/buf.h index 23a9de38c8..3064ed0470 100644 --- a/sys/sys/buf.h +++ b/sys/sys/buf.h @@ -394,6 +394,7 @@ struct uio; void bufinit (void); int bd_heatup (void); void bd_wait (int count); +void waitrunningbufspace(void); int buf_dirty_count_severe (void); int buf_runningbufspace_severe (void); void initbufbio(struct buf *); -- 2.41.0