diff options
author | Kevin Wolf <kwolf@redhat.com> | 2020-04-24 14:54:44 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2020-04-30 17:51:07 +0200 |
commit | 2f0c6e7a650de133eccd94e9bb6cf7b2070f07f1 (patch) | |
tree | 3f297a56f774a0e18cfcc5423b11969088275d90 /block | |
parent | 1ddaabaecb7eaeb6d8948a32340af95db44c54a1 (diff) |
file-posix: Support BDRV_REQ_ZERO_WRITE for truncate
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 <kwolf@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200424125448.63318-7-kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/file-posix.c | 4 |
1 files changed, 4 insertions, 0 deletions
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)) { |