[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 6/9] file-posix: Support BDRV_REQ_ZERO_WRITE for truncate
From: |
Kevin Wolf |
Subject: |
[PATCH v5 6/9] file-posix: Support BDRV_REQ_ZERO_WRITE for truncate |
Date: |
Wed, 22 Apr 2020 17:21:26 +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>
---
block/file-posix.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/block/file-posix.c b/block/file-posix.c
index 53f475ed61..1dca220a81 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
- Re: [PATCH v5 4/9] qcow2: Support BDRV_REQ_ZERO_WRITE for truncate, (continued)
- Re: [PATCH v5 4/9] qcow2: Support BDRV_REQ_ZERO_WRITE for truncate, Eric Blake, 2020/04/23
- fdatasync semantics and block device backup, Bryan S Rosenburg, 2020/04/27
- Re: fdatasync semantics and block device backup, Kevin Wolf, 2020/04/28
- RE: fdatasync semantics and block device backup, Bryan S Rosenburg, 2020/04/28
- Re: fdatasync semantics and block device backup, Kevin Wolf, 2020/04/28
Re: [PATCH v5 4/9] qcow2: Support BDRV_REQ_ZERO_WRITE for truncate, Max Reitz, 2020/04/23
[PATCH v5 2/9] block: Add flags to bdrv(_co)_truncate(), Kevin Wolf, 2020/04/22
[PATCH v5 6/9] file-posix: Support BDRV_REQ_ZERO_WRITE for truncate,
Kevin Wolf <=
[PATCH v5 8/9] iotests: Filter testfiles out in filter_img_info(), Kevin Wolf, 2020/04/22
[PATCH v5 5/9] raw-format: Support BDRV_REQ_ZERO_WRITE for truncate, Kevin Wolf, 2020/04/22
[PATCH v5 9/9] iotests: Test committing to short backing file, Kevin Wolf, 2020/04/22
[PATCH v5 7/9] block: truncate: Don't make backing file data visible, Kevin Wolf, 2020/04/22