From 9e6df35e0d6551e431511cbf6cacb04f49e6491e Mon Sep 17 00:00:00 2001 From: Krzysztof Mazur Date: Sat, 11 Feb 2012 22:23:52 +0100 Subject: [PATCH 68/84] lsbd: increase sector write throttling This patch extends sector write throttling, by throttling also LSBD_QUEUE_MOVE when there is large enough reserve of unused sectors. This improves real-time behaviour. Signed-off-by: Krzysztof Mazur --- drivers/block/lsbd.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/block/lsbd.c b/drivers/block/lsbd.c index 94bdc59..0b823fd 100644 --- a/drivers/block/lsbd.c +++ b/drivers/block/lsbd.c @@ -2115,18 +2115,40 @@ static struct lsbd_request *lsbd_request_dequeue(struct lsbd *p, int throttle) unsigned int i; unsigned long flags; unsigned int clean_blocks; + unsigned int min_clean_sects; + unsigned int data_sects; + int can_throttle; clean_blocks = lsbd_clean_blocks(p); + data_sects = p->sectors_per_block - 1; spin_lock_irqsave(&p->wqueue_lock, flags); + min_clean_sects = p->wqueue_qlen[LSBD_QUEUE_MOVE]; + + /* reserve */ + min_clean_sects += LSBD_CLEAN_LOW * data_sects; + for (i = 0; i < LSBD_QUEUE_COUNT; i++) { + can_throttle = 1; + + /* never throttle below LSBD_CLEAN_LOW clean blocks */ + if (clean_blocks < LSBD_CLEAN_LOW) + can_throttle = 0; + + /* never throttle when all sectors are needed for move */ + if (min_clean_sects >= clean_blocks * data_sects) + can_throttle = 0; + + /* never throttle when there are high-priority requests */ + if (p->wqueue_qlen[LSBD_QUEUE_HIGH]) + can_throttle = 0; + /* * High priority requests should be never throttled * to minimize write latency. Currently it is also * a good idea to not throttle move requests. */ - if ((i == LSBD_QUEUE_NORMAL) && throttle - && (clean_blocks >= LSBD_CLEAN_LOW)) + if (throttle && can_throttle) break; if (!list_empty(&p->wqueue[i])) { -- 1.8.4.652.g0d6e0ce