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 <[email protected]>

---
 drivers/md/dm-writecache.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Index: linux-2.6/drivers/md/dm-writecache.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-writecache.c   2018-06-07 21:21:47.000000000 
+0200
+++ linux-2.6/drivers/md/dm-writecache.c        2018-06-07 21:23:21.000000000 
+0200
@@ -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
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

Reply via email to