[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v8 14/43] block: Use bdrv_cow_child() in bdrv_co_truncate()
From: |
Max Reitz |
Subject: |
[PATCH v8 14/43] block: Use bdrv_cow_child() in bdrv_co_truncate() |
Date: |
Tue, 1 Sep 2020 16:33:55 +0200 |
The condition modified here is not about potentially filtered children,
but only about COW sources (i.e. traditional backing files).
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
---
block/io.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/block/io.c b/block/io.c
index 4ee8fe5465..6f9402117e 100644
--- a/block/io.c
+++ b/block/io.c
@@ -3310,7 +3310,7 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child,
int64_t offset, bool exact,
Error **errp)
{
BlockDriverState *bs = child->bs;
- BdrvChild *filtered;
+ BdrvChild *filtered, *backing;
BlockDriver *drv = bs->drv;
BdrvTrackedRequest req;
int64_t old_size, new_bytes;
@@ -3363,6 +3363,7 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child,
int64_t offset, bool exact,
}
filtered = bdrv_filter_child(bs);
+ backing = bdrv_cow_child(bs);
/*
* If the image has a backing file that is large enough that it would
@@ -3374,10 +3375,10 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child,
int64_t offset, bool exact,
* backing file, taking care of keeping things consistent with that backing
* file is the user's responsibility.
*/
- if (new_bytes && bs->backing) {
+ if (new_bytes && backing) {
int64_t backing_len;
- backing_len = bdrv_getlength(backing_bs(bs));
+ backing_len = bdrv_getlength(backing->bs);
if (backing_len < 0) {
ret = backing_len;
error_setg_errno(errp, -ret, "Could not get backing file size");
--
2.26.2
- [PATCH v8 04/43] block: bdrv_set_backing_hd() is about bs->backing, (continued)
- [PATCH v8 04/43] block: bdrv_set_backing_hd() is about bs->backing, Max Reitz, 2020/09/01
- [PATCH v8 06/43] block: Drop bdrv_is_encrypted(), Max Reitz, 2020/09/01
- [PATCH v8 05/43] block: Include filters when freezing backing chain, Max Reitz, 2020/09/01
- [PATCH v8 07/43] block: Add bdrv_supports_compressed_writes(), Max Reitz, 2020/09/01
- [PATCH v8 08/43] throttle: Support compressed writes, Max Reitz, 2020/09/01
- [PATCH v8 09/43] copy-on-read: Support compressed writes, Max Reitz, 2020/09/01
- [PATCH v8 10/43] block: Use bdrv_filter_(bs|child) where obvious, Max Reitz, 2020/09/01
- [PATCH v8 11/43] block: Use CAFs in block status functions, Max Reitz, 2020/09/01
- [PATCH v8 12/43] stream: Deal with filters, Max Reitz, 2020/09/01
- [PATCH v8 13/43] block: Use CAFs when working with backing chains, Max Reitz, 2020/09/01
- [PATCH v8 14/43] block: Use bdrv_cow_child() in bdrv_co_truncate(),
Max Reitz <=
- [PATCH v8 15/43] block: Re-evaluate backing file handling in reopen, Max Reitz, 2020/09/01
- [PATCH v8 17/43] vmdk: Drop vmdk_co_flush(), Max Reitz, 2020/09/01
- [PATCH v8 16/43] block: Flush all children in generic code, Max Reitz, 2020/09/01
- [PATCH v8 18/43] block: Iterate over children in refresh_limits, Max Reitz, 2020/09/01
- [PATCH v8 19/43] block: Use CAFs in bdrv_refresh_filename(), Max Reitz, 2020/09/01
- [PATCH v8 20/43] block: Use CAF in bdrv_co_rw_vmstate(), Max Reitz, 2020/09/01
- [PATCH v8 21/43] block/snapshot: Fix fallback, Max Reitz, 2020/09/01
- [PATCH v8 24/43] block/null: Implement bdrv_get_allocated_file_size, Max Reitz, 2020/09/01
- [PATCH v8 22/43] block: Use CAFs for debug breakpoints, Max Reitz, 2020/09/01
- [PATCH v8 23/43] block: Improve get_allocated_file_size's default, Max Reitz, 2020/09/01