1 Star 0 Fork 121

wangziliang/qemu

forked from src-openEuler/qemu 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Revert-file-posix-Remove-unused-s-discard_zeroes.patch 1.67 KB
一键复制 编辑 原始数据 按行查看 历史
Jiabo Feng 提交于 2024-03-23 09:20 . QEMU update to version 8.2.0-2
From db37bc0d85e141a666dd287cdc562a47f29b4343 Mon Sep 17 00:00:00 2001
From: Jinhua Cao <caojinhua1@huawei.com>
Date: Mon, 18 Mar 2024 10:01:28 +0800
Subject: [PATCH] Revert "file-posix: Remove unused s->discard_zeroes"
This reverts commit a7ca2eb488ff149c898f43abe103f8bd8e3ca3c4.
---
block/file-posix.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/block/file-posix.c b/block/file-posix.c
index b862406c71..01ae5fd88c 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -158,6 +158,7 @@ typedef struct BDRVRawState {
bool has_discard:1;
bool has_write_zeroes:1;
+ bool discard_zeroes:1;
bool use_linux_aio:1;
bool use_linux_io_uring:1;
int page_cache_inconsistent; /* errno from fdatasync failure */
@@ -765,6 +766,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
ret = -EINVAL;
goto fail;
} else {
+ s->discard_zeroes = true;
s->has_fallocate = true;
}
} else {
@@ -790,12 +792,19 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
#endif
if (S_ISBLK(st.st_mode)) {
+#ifdef BLKDISCARDZEROES
+ unsigned int arg;
+ if (ioctl(s->fd, BLKDISCARDZEROES, &arg) == 0 && arg) {
+ s->discard_zeroes = true;
+ }
+#endif
#ifdef __linux__
/* On Linux 3.10, BLKDISCARD leaves stale data in the page cache. Do
* not rely on the contents of discarded blocks unless using O_DIRECT.
* Same for BLKZEROOUT.
*/
if (!(bs->open_flags & BDRV_O_NOCACHE)) {
+ s->discard_zeroes = false;
s->has_write_zeroes = false;
}
#endif
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/addrexist/qemu.git
git@gitee.com:addrexist/qemu.git
addrexist
qemu
qemu
master

搜索帮助