[PATCH v2] dm-writecache: use low watermark

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a second version of the patche - it changes the condition in 
writecache_pop_from_freelist, to avoid wakeup storm if wc->writeback_size 
is greater than wc->freelist_low_watermark-wc->freelist_high_watermark.


From: Mikulas Patocka <mpatocka@xxxxxxxxxx>

Fix a bug that low watermark was ignored and high watermark was used as
both low and high.

The patch also verifies that high watermark is greater or equal than low
watermark - if this condition is violated, the driver would consume too
much CPU.

Signed-off-by: Mikulas Patocka <mpatocka@xxxxxxxxxx>

---
 drivers/md/dm-writecache.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Index: linux-2.6/drivers/md/dm-writecache.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-writecache.c	2018-06-07 22:37:48.000000000 +0200
+++ linux-2.6/drivers/md/dm-writecache.c	2018-06-07 22:38:18.000000000 +0200
@@ -644,7 +644,7 @@ static struct wc_entry *writecache_pop_f
 		list_del(&e->lru);
 	}
 	wc->freelist_size--;
-	if (unlikely(wc->freelist_size <= wc->freelist_high_watermark))
+	if (unlikely(wc->freelist_size + wc->writeback_size <= wc->freelist_high_watermark))
 		queue_work(wc->writeback_wq, &wc->writeback_work);
 
 	return e;
@@ -1590,7 +1590,7 @@ restart:
 	wbl.size = 0;
 	while (!list_empty(&wc->lru) &&
 	       (wc->writeback_all ||
-		wc->freelist_size + wc->writeback_size <= wc->freelist_high_watermark)) {
+		wc->freelist_size + wc->writeback_size <= wc->freelist_low_watermark)) {
 
 		n_walked++;
 		if (unlikely(n_walked > WRITEBACK_LATENCY) &&
@@ -2033,6 +2033,12 @@ invalid_optional:
 		}
 	}
 
+	if (high_wm_percent < low_wm_percent) {
+		r = -EINVAL;
+		ti->error = "High watermark must be greater or equal than low watermark";
+		goto bad;
+	}
+
 	if (!WC_MODE_PMEM(wc)) {
 		struct dm_io_region region;
 		struct dm_io_request req;

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel



[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux