From adfcbd8c2348de6f511472ed143e2f49d21cbec9 Mon Sep 17 00:00:00 2001 From: Krzysztof Mazur Date: Sat, 11 Feb 2012 23:46:20 +0100 Subject: [PATCH 70/84] lsbd: write only when there are non-move requests When there was at least one request in write queue the new block was written. This lead to unnecessary writes when all request on write queue are move requests. Now the number on non-move requests in write queue is checked instead of a total number of requests. Signed-off-by: Krzysztof Mazur --- drivers/block/lsbd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/block/lsbd.c b/drivers/block/lsbd.c index 82a5002..0d267c4 100644 --- a/drivers/block/lsbd.c +++ b/drivers/block/lsbd.c @@ -1557,6 +1557,11 @@ static struct gendisk lsbd_gendisk = { .sizes = lsbd_sizes, .fops = &lsbd_fops, }; + +static int __lsbd_want_write(struct lsbd *p) +{ + return p->wqueue_len - p->wqueue_qlen[LSBD_QUEUE_MOVE]; +} /** * lsbd_queue_bh - queue write operation @@ -1597,7 +1602,7 @@ static int lsbd_queue_bh(struct lsbd *p, struct buffer_head *bh, spin_lock_irqsave(&p->wqueue_lock, flags); list_add_tail(&r->list, &p->wqueue[prio]); p->wqueue_qlen[prio]++; - if (!p->wqueue_len) + if (!__lsbd_want_write(p)) need_wakeup = 1; p->wqueue_len++; spin_unlock_irqrestore(&p->wqueue_lock, flags); @@ -2421,7 +2426,7 @@ static int lsbd_thread(void *data) __set_current_state(TASK_INTERRUPTIBLE); spin_lock_irq(&p->wqueue_lock); - if (p->wqueue_len || p->blocks_to_write) + if (__lsbd_want_write(p) || p->blocks_to_write) want_write = 1; spin_unlock_irq(&p->wqueue_lock); want_clean = (lsbd_clean_blocks(p) < LSBD_CLEAN_WINDOW); -- 1.8.4.652.g0d6e0ce