[Devel] [PATCH v2 VZ9] dm-qcow2-map: disable high-order allocation warning

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Mon Nov 11 12:23:51 MSK 2024


Disables the warning:

kernel: order 10 >= 10, gfp 0x40c00
kernel: WARNING: CPU: 5 PID: 182 at mm/page_alloc.c:5630 __alloc_pages+0x1d7/0x3f0
kernel: process_compressed_read+0x6f/0x590 [dm_qcow2]

As with 1M clusters and in case of zstd compression the buffer size
(clu_size + sizeof(ZSTD_DCtx) + ZSTD_BLOCKSIZE_MAX + clu_size +
ZSTD_BLOCKSIZE_MAX + 64 = 2520776) can only fit into 4M (10-th order)
allocation.

Let's add a separate warning to make sure we don't exceede currently
expected size of 4M.

Note: According to Documentation/core-api/gfp_mask-from-fs-io.rst
GFP_NOIO is not supported in vmalloc, so probably we don't have an
option to switch to kvmalloc here.

https://virtuozzo.atlassian.net/browse/VSTOR-94596
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>

Feature: dm-qcow2: ZSTD decompression

--
v2: add warning for >4M allocation and note about kvmalloc
---
 drivers/md/dm-qcow2-map.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
index 6585f3fac6e7b..6e738bbff13e1 100644
--- a/drivers/md/dm-qcow2-map.c
+++ b/drivers/md/dm-qcow2-map.c
@@ -10,6 +10,7 @@
 #include <linux/zlib.h>
 #include <linux/error-injection.h>
 #include <linux/zstd.h>
+#include <linux/sizes.h>
 
 #include "dm.h"
 #include "dm-rq.h"
@@ -3671,7 +3672,8 @@ static void process_compressed_read(struct qcow2 *qcow2, struct list_head *read_
 		dctxlen = zlib_inflate_workspacesize();
 
 
-	buf = kmalloc(qcow2->clu_size + dctxlen, GFP_NOIO);
+	WARN_ON(qcow2->clu_size + dctxlen > SZ_4M);
+	buf = kmalloc(qcow2->clu_size + dctxlen, GFP_NOIO | __GFP_ORDER_NOWARN);
 	if (!buf) {
 		end_qios(read_list, BLK_STS_RESOURCE);
 		return;
-- 
2.47.0



More information about the Devel mailing list