From a69fc433d95152b538fa6c3c52906acc4d321766 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Tue, 25 Jul 2017 14:05:08 +0200 Subject: [PATCH 219/325] cam_iosched: Add sysctl to flush quickly Obtained from: ElectroBSD --- sys/cam/cam_iosched.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/sys/cam/cam_iosched.c b/sys/cam/cam_iosched.c index e89b4674c156..1517f1ae5477 100644 --- a/sys/cam/cam_iosched.c +++ b/sys/cam/cam_iosched.c @@ -108,6 +108,11 @@ TUNABLE_INT("kern.cam.iosched_debug", &iosched_debug); SYSCTL_INT(_kern_cam, OID_AUTO, iosched_debug, CTLFLAG_RW, &iosched_debug, 1, "Dynamic I/O scheduler debug level"); +int iosched_flush_quickly = 0; +TUNABLE_INT("kern.cam.iosched_flush_quickly", &iosched_flush_quickly); +SYSCTL_INT(_kern_cam, OID_AUTO, iosched_flush_quickly, CTLFLAG_RW, + &iosched_flush_quickly, 1, "Let flushes through if they are at the beginning of the queue"); + typedef enum { none = 0, /* No limits */ queue_depth, /* Limit how many ops we queue to SIM */ @@ -357,6 +362,9 @@ cam_iosched_limiter_caniop(struct iop_stats *ios, struct bio *bp) { int lim = ios->limiter; + if (iosched_flush_quickly && bp->bio_cmd == BIO_FLUSH) { + return 0; + } /* maybe this should be a kassert */ if (lim < none || lim >= limiter_max) return EINVAL; @@ -1255,15 +1263,17 @@ cam_iosched_get_write(struct cam_iosched_softc *isc) * setting. */ if (bioq_first(&isc->bio_queue) && isc->current_read_bias) { - if (iosched_debug) - printf( - "Reads present and current_read_bias is %d queued " - "writes %d queued reads %d\n", - isc->current_read_bias, isc->write_stats.queued, - isc->read_stats.queued); - isc->current_read_bias--; - /* We're not limiting writes, per se, just doing reads first */ - return NULL; + if (iosched_flush_quickly && bp->bio_cmd == BIO_FLUSH) { + if (iosched_debug) + printf("Reads pending but op is flush. Allowing it.\n"); + } else { + if (iosched_debug) + printf("Reads present and current_read_bias is %d queued writes %d queued reads %d\n", + isc->current_read_bias, isc->write_stats.queued, isc->read_stats.queued); + isc->current_read_bias--; + /* We're not limiting writes, per se, just doing reads first */ + return NULL; + } } /* -- 2.32.0