From: Mikulas Patocka Date: Wed, 13 Jul 2022 11:09:04 +0000 (-0400) Subject: dm writecache: set a default MAX_WRITEBACK_JOBS X-Git-Tag: baikal/mips/sdk5.9~63 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=6036df2c9c937d6c53cf1ec8cc36c7a4a687c0b2;p=kernel.git dm writecache: set a default MAX_WRITEBACK_JOBS [ Upstream commit 1e0cba17863a72714ee5764bfda25e877a534a5d ] dm-writecache has the capability to limit the number of writeback jobs in progress. However, this feature was off by default. As such there were some out-of-memory crashes observed when lowering the low watermark while the cache is full. This commit enables writeback limit by default. It is set to 256MiB or 1/16 of total system memory, whichever is smaller. Cc: stable@vger.kernel.org Signed-off-by: Mikulas Patocka Signed-off-by: Mike Snitzer Signed-off-by: Sasha Levin --- diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c index c3e59d8af76f9..dfb55fe09ce13 100644 --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -22,7 +22,7 @@ #define HIGH_WATERMARK 50 #define LOW_WATERMARK 45 -#define MAX_WRITEBACK_JOBS 0 +#define MAX_WRITEBACK_JOBS min(0x10000000 / PAGE_SIZE, totalram_pages() / 16) #define ENDIO_LATENCY 16 #define WRITEBACK_LATENCY 64 #define AUTOCOMMIT_BLOCKS_SSD 65536