[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 08/15] file-posix: Support BDRV_REQ_ZERO_WRITE for truncate
From: |
Kevin Wolf |
Subject: |
[PULL 08/15] file-posix: Support BDRV_REQ_ZERO_WRITE for truncate |
Date: |
Thu, 30 Apr 2020 17:52:24 +0200 |
For regular files, we always get BDRV_REQ_ZERO_WRITE behaviour from the
OS, so we can advertise the flag and just ignore it.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Reviewed-by: Alberto Garcia <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/file-posix.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/block/file-posix.c b/block/file-posix.c
index 58326a0a60..bf09ad8bc0 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -702,6 +702,10 @@ static int raw_open_common(BlockDriverState *bs, QDict
*options,
#endif
bs->supported_zero_flags = BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK;
+ if (S_ISREG(st.st_mode)) {
+ /* When extending regular files, we get zeros from the OS */
+ bs->supported_truncate_flags = BDRV_REQ_ZERO_WRITE;
+ }
ret = 0;
fail:
if (filename && (bdrv_flags & BDRV_O_TEMPORARY)) {
--
2.25.3
- [PULL 00/15] Block layer patches, Kevin Wolf, 2020/04/30
- [PULL 01/15] qcow2: Add incompatibility note between backing files and raw external data files, Kevin Wolf, 2020/04/30
- [PULL 02/15] qemu-iotests: allow qcow2 external discarded clusters to contain stale data, Kevin Wolf, 2020/04/30
- [PULL 03/15] block: Add flags to BlockDriver.bdrv_co_truncate(), Kevin Wolf, 2020/04/30
- [PULL 05/15] block-backend: Add flags to blk_truncate(), Kevin Wolf, 2020/04/30
- [PULL 04/15] block: Add flags to bdrv(_co)_truncate(), Kevin Wolf, 2020/04/30
- [PULL 06/15] qcow2: Support BDRV_REQ_ZERO_WRITE for truncate, Kevin Wolf, 2020/04/30
- [PULL 07/15] raw-format: Support BDRV_REQ_ZERO_WRITE for truncate, Kevin Wolf, 2020/04/30
- [PULL 08/15] file-posix: Support BDRV_REQ_ZERO_WRITE for truncate,
Kevin Wolf <=
- [PULL 09/15] block: truncate: Don't make backing file data visible, Kevin Wolf, 2020/04/30
- [PULL 10/15] iotests: Filter testfiles out in filter_img_info(), Kevin Wolf, 2020/04/30
- [PULL 12/15] qcow2: Forward ZERO_WRITE flag for full preallocation, Kevin Wolf, 2020/04/30
- [PULL 11/15] iotests: Test committing to short backing file, Kevin Wolf, 2020/04/30
- [PULL 13/15] nvme: introduce PMR support from NVMe 1.4 spec, Kevin Wolf, 2020/04/30
- [PULL 15/15] qemu-storage-daemon: Fix non-string --object properties, Kevin Wolf, 2020/04/30
- [PULL 14/15] qom: Factor out user_creatable_add_dict(), Kevin Wolf, 2020/04/30