34 lines
1.2 KiB
Diff
34 lines
1.2 KiB
Diff
|
|
From 48c792a802c8cb0ab670ddf92920e2e5e96747a4 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Jinhua Cao <caojinhua1@huawei.com>
|
||
|
|
Date: Mon, 18 Mar 2024 10:04:42 +0800
|
||
|
|
Subject: [PATCH] qemu-img block: set zero flags only when discard_zeros of the
|
||
|
|
block supported
|
||
|
|
|
||
|
|
zero flags set for block discard_zeros, only when the block support
|
||
|
|
discard_zeros need set these flags.
|
||
|
|
|
||
|
|
old commit info:
|
||
|
|
qemu-img: block: dont blk_make_zero if discard_zeroes false
|
||
|
|
|
||
|
|
Signed-off-by: Jinhua Cao <caojinhua1@huawei.com>
|
||
|
|
---
|
||
|
|
block/file-posix.c | 2 +-
|
||
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||
|
|
|
||
|
|
diff --git a/block/file-posix.c b/block/file-posix.c
|
||
|
|
index 01ae5fd88c..4782aba59f 100644
|
||
|
|
--- a/block/file-posix.c
|
||
|
|
+++ b/block/file-posix.c
|
||
|
|
@@ -822,7 +822,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
|
||
|
|
#endif
|
||
|
|
s->needs_alignment = raw_needs_alignment(bs);
|
||
|
|
|
||
|
|
- bs->supported_zero_flags = BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK;
|
||
|
|
+ bs->supported_zero_flags = s->discard_zeroes ? (BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK) : 0;
|
||
|
|
if (S_ISREG(st.st_mode)) {
|
||
|
|
/* When extending regular files, we get zeros from the OS */
|
||
|
|
bs->supported_truncate_flags = BDRV_REQ_ZERO_WRITE;
|
||
|
|
--
|
||
|
|
2.27.0
|
||
|
|
|