[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 08/21] block/backup: stricter backup_calculate_cluster_size()
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH 08/21] block/backup: stricter backup_calculate_cluster_size() |
Date: |
Mon, 17 May 2021 09:44:15 +0300 |
No reason to tolerate bdrv_get_info() errors except for ENOTSUP. Let's
just error-out, it's simpler and safer.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
block/backup.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/block/backup.c b/block/backup.c
index fe685e411b..fe7a1f1e37 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -367,7 +367,10 @@ static int64_t
backup_calculate_cluster_size(BlockDriverState *target,
* targets with a backing file, try to avoid COW if possible.
*/
ret = bdrv_get_info(target, &bdi);
- if (ret == -ENOTSUP && !target_does_cow) {
+ if (ret < 0 && ret != -ENOTSUP) {
+ error_setg_errno(errp, -ret, "Failed to get target info");
+ return ret;
+ } else if (ret == -ENOTSUP && !target_does_cow) {
/* Cluster size is not defined */
warn_report("The target block device doesn't provide "
"information about the block size and it doesn't have a "
@@ -376,14 +379,7 @@ static int64_t
backup_calculate_cluster_size(BlockDriverState *target,
"this default, the backup may be unusable",
BACKUP_CLUSTER_SIZE_DEFAULT);
return BACKUP_CLUSTER_SIZE_DEFAULT;
- } else if (ret < 0 && !target_does_cow) {
- error_setg_errno(errp, -ret,
- "Couldn't determine the cluster size of the target image, "
- "which has no backing file");
- error_append_hint(errp,
- "Aborting, since this may create an unusable destination image\n");
- return ret;
- } else if (ret < 0 && target_does_cow) {
+ } else if (ret == -ENOTSUP && target_does_cow) {
/* Not fatal; just trudge on ahead. */
return BACKUP_CLUSTER_SIZE_DEFAULT;
}
--
2.29.2
- [PATCH 11/21] block/copy-before-write: use file child instead of backing, (continued)
- [PATCH 11/21] block/copy-before-write: use file child instead of backing, Vladimir Sementsov-Ogievskiy, 2021/05/17
- [PATCH 07/21] block-copy: always set BDRV_REQ_SERIALISING flag, Vladimir Sementsov-Ogievskiy, 2021/05/17
- [PATCH 18/21] block/block-copy: make setting progress optional, Vladimir Sementsov-Ogievskiy, 2021/05/17
- [PATCH 13/21] block/copy-before-write: introduce cbw_init(), Vladimir Sementsov-Ogievskiy, 2021/05/17
- [PATCH 08/21] block/backup: stricter backup_calculate_cluster_size(),
Vladimir Sementsov-Ogievskiy <=
- [PATCH 14/21] block/copy-before-write: cbw_init(): rename variables, Vladimir Sementsov-Ogievskiy, 2021/05/17
- [PATCH 17/21] block/block-copy: switch to fully set bitmap by default, Vladimir Sementsov-Ogievskiy, 2021/05/17
- [PATCH 09/21] block/backup: move cluster size calculation to block-copy, Vladimir Sementsov-Ogievskiy, 2021/05/17
- [PATCH 16/21] block/copy-before-write: cbw_init(): use options, Vladimir Sementsov-Ogievskiy, 2021/05/17