aboutsummaryrefslogtreecommitdiff
path: root/block/qed.c
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2019-09-18 11:51:43 +0200
committerMax Reitz <mreitz@redhat.com>2019-10-28 12:08:45 +0100
commite8d04f92378c2de7b464e04469a657fd37eb29ea (patch)
tree0a274a9f3c9716def5230a4f09463e9d23fdd432 /block/qed.c
parente61a28a9b6b43da6a7a48f6d325fceadf9769388 (diff)
block: Pass truncate exact=true where reasonable
This is a change in behavior, so all instances need a good justification. The comments added here should explain my reasoning. qed already had a comment that suggests it always expected bdrv_truncate()/blk_truncate() to behave as if exact=true were passed (c743849bee7 came eight months before 55b949c8476), so it was simply broken until now. Signed-off-by: Max Reitz <mreitz@redhat.com> Message-id: 20190918095144.955-8-mreitz@redhat.com Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> [mreitz: Changed comment in qed.c to explain why a new QED file must be empty, as requested and suggested by Maxim] Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'block/qed.c')
-rw-r--r--block/qed.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/block/qed.c b/block/qed.c
index 7c2a65af40..d8c4e5fb1e 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -673,8 +673,11 @@ static int coroutine_fn bdrv_qed_co_create(BlockdevCreateOptions *opts,
l1_size = header.cluster_size * header.table_size;
- /* File must start empty and grow, check truncate is supported */
- ret = blk_truncate(blk, 0, false, PREALLOC_MODE_OFF, errp);
+ /*
+ * The QED format associates file length with allocation status,
+ * so a new file (which is empty) must have a length of 0.
+ */
+ ret = blk_truncate(blk, 0, true, PREALLOC_MODE_OFF, errp);
if (ret < 0) {
goto out;
}