[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7 16/47] block: Use bdrv_cow_child() in bdrv_co_truncate()
From: |
Max Reitz |
Subject: |
[PATCH v7 16/47] block: Use bdrv_cow_child() in bdrv_co_truncate() |
Date: |
Thu, 25 Jun 2020 17:21:44 +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>
---
block/io.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/block/io.c b/block/io.c
index dc9891d6ce..097a3861d8 100644
--- a/block/io.c
+++ b/block/io.c
@@ -3308,7 +3308,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;
@@ -3361,6 +3361,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
@@ -3372,10 +3373,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 v7 06/47] block: Drop bdrv_is_encrypted(), (continued)
- [PATCH v7 06/47] block: Drop bdrv_is_encrypted(), Max Reitz, 2020/06/25
- [PATCH v7 07/47] block: Add bdrv_supports_compressed_writes(), Max Reitz, 2020/06/25
- [PATCH v7 08/47] throttle: Support compressed writes, Max Reitz, 2020/06/25
- [PATCH v7 09/47] copy-on-read: Support compressed writes, Max Reitz, 2020/06/25
- [PATCH v7 11/47] backup-top: Support compressed writes, Max Reitz, 2020/06/25
- [PATCH v7 12/47] block: Use bdrv_filter_(bs|child) where obvious, Max Reitz, 2020/06/25
- [PATCH v7 15/47] block: Use CAFs when working with backing chains, Max Reitz, 2020/06/25
- [PATCH v7 10/47] mirror-top: Support compressed writes, Max Reitz, 2020/06/25
- [PATCH v7 13/47] block: Use CAFs in block status functions, Max Reitz, 2020/06/25
- [PATCH v7 14/47] stream: Deal with filters, Max Reitz, 2020/06/25
- [PATCH v7 16/47] block: Use bdrv_cow_child() in bdrv_co_truncate(),
Max Reitz <=
- [PATCH v7 18/47] block: Flush all children in generic code, Max Reitz, 2020/06/25
- [PATCH v7 17/47] block: Re-evaluate backing file handling in reopen, Max Reitz, 2020/06/25
- [PATCH v7 19/47] vmdk: Drop vmdk_co_flush(), Max Reitz, 2020/06/25
- [PATCH v7 20/47] block: Iterate over children in refresh_limits, Max Reitz, 2020/06/25
- [PATCH v7 21/47] block: Use CAFs in bdrv_refresh_filename(), Max Reitz, 2020/06/25
- [PATCH v7 22/47] block: Use CAF in bdrv_co_rw_vmstate(), Max Reitz, 2020/06/25
- [PATCH v7 23/47] block/snapshot: Fix fallback, Max Reitz, 2020/06/25
- [PATCH v7 25/47] block: Def. impl.s for get_allocated_file_size, Max Reitz, 2020/06/25
- [PATCH v7 24/47] block: Use CAFs for debug breakpoints, Max Reitz, 2020/06/25
- [PATCH v7 26/47] block: Improve get_allocated_file_size's default, Max Reitz, 2020/06/25