[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 12/13] block/qcow2: simplify qcow2_co_invalidate_cache()
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH v3 12/13] block/qcow2: simplify qcow2_co_invalidate_cache() |
Date: |
Fri, 16 Oct 2020 20:10:56 +0300 |
qcow2_do_open correctly sets errp on each failure path. So, we can
simplify code in qcow2_co_invalidate_cache() and drop explicit error
propagation.
Add ERRP_GUARD() as mandated by the documentation in
include/qapi/error.h so that error_prepend() is actually called even if
errp is &error_fatal.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
---
block/qcow2.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/block/qcow2.c b/block/qcow2.c
index 2b6ec4b757..cd5f48d3fb 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -2702,11 +2702,11 @@ static void qcow2_close(BlockDriverState *bs)
static void coroutine_fn qcow2_co_invalidate_cache(BlockDriverState *bs,
Error **errp)
{
+ ERRP_GUARD();
BDRVQcow2State *s = bs->opaque;
int flags = s->flags;
QCryptoBlock *crypto = NULL;
QDict *options;
- Error *local_err = NULL;
int ret;
/*
@@ -2724,16 +2724,11 @@ static void coroutine_fn
qcow2_co_invalidate_cache(BlockDriverState *bs,
flags &= ~BDRV_O_INACTIVE;
qemu_co_mutex_lock(&s->lock);
- ret = qcow2_do_open(bs, options, flags, &local_err);
+ ret = qcow2_do_open(bs, options, flags, errp);
qemu_co_mutex_unlock(&s->lock);
qobject_unref(options);
- if (local_err) {
- error_propagate_prepend(errp, local_err,
- "Could not reopen qcow2 layer: ");
- bs->drv = NULL;
- return;
- } else if (ret < 0) {
- error_setg_errno(errp, -ret, "Could not reopen qcow2 layer");
+ if (ret < 0) {
+ error_prepend(errp, "Could not reopen qcow2 layer: ");
bs->drv = NULL;
return;
}
--
2.21.3
- Re: [PATCH v3 02/13] block: use return status of bdrv_append(), (continued)
- [PATCH v3 04/13] blockdev: fix drive_backup_prepare() missed error, Vladimir Sementsov-Ogievskiy, 2020/10/16
- [PATCH v3 05/13] block: drop extra error propagation for bdrv_set_backing_hd, Vladimir Sementsov-Ogievskiy, 2020/10/16
- [PATCH v3 07/13] blockjob: return status from block_job_set_speed(), Vladimir Sementsov-Ogievskiy, 2020/10/16
- [PATCH v3 03/13] block: check return value of bdrv_open_child and drop error propagation, Vladimir Sementsov-Ogievskiy, 2020/10/16
- [PATCH v3 06/13] block/mirror: drop extra error propagation in commit_active_start(), Vladimir Sementsov-Ogievskiy, 2020/10/16
- [PATCH v3 08/13] block/qcow2: qcow2_get_specific_info(): drop error propagation, Vladimir Sementsov-Ogievskiy, 2020/10/16
- [PATCH v3 10/13] block/qcow2-bitmap: return status from qcow2_store_persistent_dirty_bitmaps, Vladimir Sementsov-Ogievskiy, 2020/10/16
- [PATCH v3 09/13] block/qcow2-bitmap: improve qcow2_load_dirty_bitmaps() interface, Vladimir Sementsov-Ogievskiy, 2020/10/16
- [PATCH v3 11/13] block/qcow2: read_cache_sizes: return status value, Vladimir Sementsov-Ogievskiy, 2020/10/16
- [PATCH v3 12/13] block/qcow2: simplify qcow2_co_invalidate_cache(),
Vladimir Sementsov-Ogievskiy <=
- [PATCH v3 13/13] block/qed: bdrv_qed_do_open: deal with errp, Vladimir Sementsov-Ogievskiy, 2020/10/16