[Devel] [PATCH hci-8.2 v2 1/2] dm-qcow2: zero qio pages with memzero_page() instead of kmap()
Denis V. Lunev
den at openvz.org
Thu Nov 19 15:51:20 MSK 2026
From: Denis V. Lunev <den at openvz.org>
zero_fill_iter_bvec() maps each page with kmap(), which may sleep, but
parse_l2() calls it through perform_zero_read() with md_pages_lock
held: a read of a cluster whose L2 entry is dirty or under writeback
reads as zeroes. A debug kernel then prints "BUG: sleeping function
called from invalid context" from the dm-qcow2 worker.
The loop also walks multi-page bvecs and clears across page boundaries
through the mapping of the first page, which works only without
highmem.
Walk single-page segments and clear each with memzero_page().
https://virtuozzo.atlassian.net/browse/VSTOR-155987
Fixes: 222b6f1291c1 ("dm-qcow2: Introduce driver to create block devices over QCOW2 files")
Feature: dm-qcow2: block device over QCOW2 files driver
Signed-off-by: Denis V. Lunev <den at openvz.org>
---
drivers/md/dm-qcow2-map.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
index 32373114580e..c7e186fa6115 100644
--- a/drivers/md/dm-qcow2-map.c
+++ b/drivers/md/dm-qcow2-map.c
@@ -283,9 +283,7 @@ static void zero_fill_iter_bvec(struct bvec_iter *bi_iter, struct bio_vec *bi_io
struct bio_vec bv;
u32 bytes;
- qcow2_for_each_bvec(iter, bv, *bi_iter, bi_io_vec) {
- void *data;
-
+ for_each_bvec(bv, bi_io_vec, iter, *bi_iter) {
if (!count)
break;
if (from >= bv.bv_len) {
@@ -297,10 +295,7 @@ static void zero_fill_iter_bvec(struct bvec_iter *bi_iter, struct bio_vec *bi_io
if (bytes > count)
bytes = count;
- data = kmap(bv.bv_page);
- memset(data + bv.bv_offset + from, 0, bytes);
- flush_dcache_page(bv.bv_page);
- kunmap(bv.bv_page);
+ memzero_page(bv.bv_page, bv.bv_offset + from, bytes);
from = 0;
count -= bytes;
}
--
2.55.0
More information about the Devel
mailing list