qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: yuchenlin <yuchenlin@synology.com>
To: qemu-devel@nongnu.org
Cc: famz@redhat.com, qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] vmdk: align end of file to a sector boundary
Date: Wed, 5 Sep 2018 10:14:53 +0800	[thread overview]
Message-ID: <d83ea4f7-3d79-49b1-a067-4146e7cbc745@Mail> (raw)
In-Reply-To: <20180828031751.29507-1-yuchenlin@synology.com>

Ping!

yuchenlin@synology.com 於 2018-08-28 11:18 寫道:
> From: yuchenlin <yuchenlin@synology.com> There is a rare case which the size of last compressed cluster is larger than the cluster size, which will cause the file is not aligned at the sector boundary. Signed-off-by: yuchenlin <yuchenlin@synology.com> --- block/vmdk.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/block/vmdk.c b/block/vmdk.c index a9d0084e36..a8ae7c65d2 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1698,6 +1698,24 @@ static int coroutine_fn vmdk_co_pwritev_compressed(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov) { + if (bytes == 0) { + /* align end of file to a sector boundary. */ + BDRVVmdkState *s = bs->opaque; + int i, ret; + int64_t length; + + for (i = 0; i < s->num_extents; i++) { + length = bdrv_getlength(s->extents[i].file->bs); + if (length < 0) { + return length; + } + ret = bdrv_truncate(s->extents[i].file, length, PREALLOC_MODE_OFF, NULL); + if (ret < 0) { + return ret; + } + } + return 0; + } return vmdk_co_pwritev(bs, offset, bytes, qiov, 0); } -- 2.17.0   

  reply	other threads:[~2018-09-05  2:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-28  3:17 [Qemu-devel] [PATCH] vmdk: align end of file to a sector boundary yuchenlin
2018-09-05  2:14 ` yuchenlin [this message]
2018-09-12  9:34 ` Fam Zheng
2018-09-12  9:52   ` yuchenlin
2018-09-12 11:52     ` Fam Zheng
2018-09-12 11:54 ` Fam Zheng
2018-09-13  1:51   ` yuchenlin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d83ea4f7-3d79-49b1-a067-4146e7cbc745@Mail \
    --to=yuchenlin@synology.com \
    --cc=famz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).