From ae760dbc1d2203a84f3e43564b2dc5bdc8e77d1e Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Tue, 22 Aug 2023 02:12:12 +0300 Subject: [PATCH] Fix co_truncate size division by BDRV_SECTOR_SIZE --- src/qemu_driver.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/qemu_driver.c b/src/qemu_driver.c index 0e75c6cc..3f3c41ec 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -585,7 +585,11 @@ static int coroutine_fn vitastor_co_truncate(BlockDriverState *bs, int64_t offse } // TODO: Resize inode to bytes - client->size = offset / BDRV_SECTOR_SIZE; +#if QEMU_VERSION_MAJOR >= 4 + client->size = exact || client->size < offset ? offset : client->size; +#else + client->size = offset; +#endif return 0; }