Blame SOURCES/kvm-file-posix-Support-BDRV_REQ_ZERO_WRITE-for-truncate.patch

77c23f
From 55bfda3a0e077b822f57e8ed901f0cee848bc471 Mon Sep 17 00:00:00 2001
77c23f
From: Kevin Wolf <kwolf@redhat.com>
77c23f
Date: Mon, 8 Jun 2020 15:01:35 +0100
77c23f
Subject: [PATCH 07/17] file-posix: Support BDRV_REQ_ZERO_WRITE for truncate
77c23f
77c23f
RH-Author: Kevin Wolf <kwolf@redhat.com>
77c23f
Message-id: <20200608150140.38218-7-kwolf@redhat.com>
77c23f
Patchwork-id: 97452
77c23f
O-Subject: [RHEL-AV-8.2.1 qemu-kvm PATCH 06/11] file-posix: Support BDRV_REQ_ZERO_WRITE for truncate
77c23f
Bugzilla: 1780574
77c23f
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
77c23f
RH-Acked-by: Eric Blake <eblake@redhat.com>
77c23f
RH-Acked-by: Max Reitz <mreitz@redhat.com>
77c23f
77c23f
For regular files, we always get BDRV_REQ_ZERO_WRITE behaviour from the
77c23f
OS, so we can advertise the flag and just ignore it.
77c23f
77c23f
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
77c23f
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
77c23f
Reviewed-by: Alberto Garcia <berto@igalia.com>
77c23f
Reviewed-by: Max Reitz <mreitz@redhat.com>
77c23f
Message-Id: <20200424125448.63318-7-kwolf@redhat.com>
77c23f
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
77c23f
(cherry picked from commit 2f0c6e7a650de133eccd94e9bb6cf7b2070f07f1)
77c23f
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
77c23f
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
77c23f
---
77c23f
 block/file-posix.c | 4 ++++
77c23f
 1 file changed, 4 insertions(+)
77c23f
77c23f
diff --git a/block/file-posix.c b/block/file-posix.c
77c23f
index 7551e8d..adafbfa 100644
77c23f
--- a/block/file-posix.c
77c23f
+++ b/block/file-posix.c
77c23f
@@ -674,6 +674,10 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
77c23f
 #endif
77c23f
 
77c23f
     bs->supported_zero_flags = BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK;
77c23f
+    if (S_ISREG(st.st_mode)) {
77c23f
+        /* When extending regular files, we get zeros from the OS */
77c23f
+        bs->supported_truncate_flags = BDRV_REQ_ZERO_WRITE;
77c23f
+    }
77c23f
     ret = 0;
77c23f
 fail:
77c23f
     if (filename && (bdrv_flags & BDRV_O_TEMPORARY)) {
77c23f
-- 
77c23f
1.8.3.1
77c23f