diff options
author | Max Reitz | 2019-06-12 17:03:38 +0200 |
---|---|---|
committer | Kevin Wolf | 2020-09-07 12:31:31 +0200 |
commit | 93393e698c76c9b95b1fcf9649eef41f9cdbbb07 (patch) | |
tree | 4efe6b10f5caf6cfe4b75a15812aff8703e4df95 /block | |
parent | copy-on-read: Support compressed writes (diff) | |
download | qemu-93393e698c76c9b95b1fcf9649eef41f9cdbbb07.tar.gz qemu-93393e698c76c9b95b1fcf9649eef41f9cdbbb07.tar.xz qemu-93393e698c76c9b95b1fcf9649eef41f9cdbbb07.zip |
block: Use bdrv_filter_(bs|child) where obvious
Places that use patterns like
if (bs->drv->is_filter && bs->file) {
... something about bs->file->bs ...
}
should be
BlockDriverState *filtered = bdrv_filter_bs(bs);
if (filtered) {
... something about @filtered ...
}
instead.
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/io.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/block/io.c b/block/io.c index ad3a51ed53..01e3477a77 100644 --- a/block/io.c +++ b/block/io.c @@ -3309,6 +3309,7 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset, bool exact, Error **errp) { BlockDriverState *bs = child->bs; + BdrvChild *filtered; BlockDriver *drv = bs->drv; BdrvTrackedRequest req; int64_t old_size, new_bytes; @@ -3360,6 +3361,8 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset, bool exact, goto out; } + filtered = bdrv_filter_child(bs); + /* * If the image has a backing file that is large enough that it would * provide data for the new area, we cannot leave it unallocated because @@ -3392,8 +3395,8 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset, bool exact, goto out; } ret = drv->bdrv_co_truncate(bs, offset, exact, prealloc, flags, errp); - } else if (bs->file && drv->is_filter) { - ret = bdrv_co_truncate(bs->file, offset, exact, prealloc, flags, errp); + } else if (filtered) { + ret = bdrv_co_truncate(filtered, offset, exact, prealloc, flags, errp); } else { error_setg(errp, "Image format driver does not support resize"); ret = -ENOTSUP; |