[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7 34/47] backup: Deal with filters
From: |
Max Reitz |
Subject: |
[PATCH v7 34/47] backup: Deal with filters |
Date: |
Thu, 25 Jun 2020 17:22:02 +0200 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
block/backup-top.c | 2 +-
block/backup.c | 9 +++++----
blockdev.c | 19 +++++++++++++++----
3 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/block/backup-top.c b/block/backup-top.c
index f304df8f26..89bd3937d0 100644
--- a/block/backup-top.c
+++ b/block/backup-top.c
@@ -291,7 +291,7 @@ void bdrv_backup_top_drop(BlockDriverState *bs)
s->active = false;
bdrv_child_refresh_perms(bs, bs->backing, &error_abort);
- bdrv_replace_node(bs, backing_bs(bs), &error_abort);
+ bdrv_replace_node(bs, bs->backing->bs, &error_abort);
bdrv_set_backing_hd(bs, NULL, &error_abort);
bdrv_drained_end(bs);
diff --git a/block/backup.c b/block/backup.c
index 4f13bb20a5..9afa0bf3b4 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -297,6 +297,7 @@ static int64_t
backup_calculate_cluster_size(BlockDriverState *target,
{
int ret;
BlockDriverInfo bdi;
+ bool target_does_cow = bdrv_backing_chain_next(target);
/*
* If there is no backing file on the target, we cannot rely on COW if our
@@ -304,7 +305,7 @@ 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->backing) {
+ 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 "
@@ -313,14 +314,14 @@ 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->backing) {
+ } 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->backing) {
+ } else if (ret < 0 && target_does_cow) {
/* Not fatal; just trudge on ahead. */
return BACKUP_CLUSTER_SIZE_DEFAULT;
}
@@ -371,7 +372,7 @@ BlockJob *backup_job_create(const char *job_id,
BlockDriverState *bs,
return NULL;
}
- if (compress && !block_driver_can_compress(target->drv)) {
+ if (compress && !bdrv_supports_compressed_writes(target)) {
error_setg(errp, "Compression is not supported for this drive %s",
bdrv_get_device_name(target));
return NULL;
diff --git a/blockdev.c b/blockdev.c
index 6ca9b19779..9ce99b9cbc 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1728,7 +1728,13 @@ static void drive_backup_prepare(BlkActionState *common,
Error **errp)
* on top of.
*/
if (backup->sync == MIRROR_SYNC_MODE_TOP) {
- source = backing_bs(bs);
+ /*
+ * Backup will not replace the source by the target, so none
+ * of the filters skipped here will be removed (in contrast to
+ * mirror). Therefore, we can skip all of them when looking
+ * for the first COW relationship.
+ */
+ source = bdrv_cow_bs(bdrv_skip_filters(bs));
if (!source) {
backup->sync = MIRROR_SYNC_MODE_FULL;
}
@@ -1748,9 +1754,14 @@ static void drive_backup_prepare(BlkActionState *common,
Error **errp)
if (backup->mode != NEW_IMAGE_MODE_EXISTING) {
assert(backup->format);
if (source) {
- bdrv_refresh_filename(source);
- bdrv_img_create(backup->target, backup->format, source->filename,
- source->drv->format_name, NULL,
+ /* Implicit filters should not appear in the filename */
+ BlockDriverState *explicit_backing =
+ bdrv_skip_implicit_filters(source);
+
+ bdrv_refresh_filename(explicit_backing);
+ bdrv_img_create(backup->target, backup->format,
+ explicit_backing->filename,
+ explicit_backing->drv->format_name, NULL,
size, flags, false, &local_err);
} else {
bdrv_img_create(backup->target, backup->format, NULL, NULL, NULL,
--
2.26.2
- [PATCH v7 25/47] block: Def. impl.s for get_allocated_file_size, (continued)
- [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
- [PATCH v7 28/47] block/null: Implement bdrv_get_allocated_file_size, Max Reitz, 2020/06/25
- [PATCH v7 31/47] block: Use child access functions for QAPI queries, Max Reitz, 2020/06/25
- [PATCH v7 32/47] block-copy: Use CAF to find sync=top base, Max Reitz, 2020/06/25
- [PATCH v7 33/47] mirror: Deal with filters, Max Reitz, 2020/06/25
- [PATCH v7 29/47] blockdev: Use CAF in external_snapshot_prepare(), Max Reitz, 2020/06/25
- [PATCH v7 27/47] blkverify: Use bdrv_sum_allocated_file_size(), Max Reitz, 2020/06/25
- [PATCH v7 30/47] block: Report data child for query-blockstats, Max Reitz, 2020/06/25
- [PATCH v7 34/47] backup: Deal with filters,
Max Reitz <=
- [PATCH v7 36/47] nbd: Use CAF when looking for dirty bitmap, Max Reitz, 2020/06/25
- [PATCH v7 37/47] qemu-img: Use child access functions, Max Reitz, 2020/06/25
- [PATCH v7 35/47] commit: Deal with filters, Max Reitz, 2020/06/25
- [PATCH v7 38/47] block: Drop backing_bs(), Max Reitz, 2020/06/25
- [PATCH v7 41/47] block: Leave BDS.backing_file constant, Max Reitz, 2020/06/25
- [PATCH v7 39/47] blockdev: Fix active commit choice, Max Reitz, 2020/06/25
- [PATCH v7 40/47] block: Inline bdrv_co_block_status_from_*(), Max Reitz, 2020/06/25
- [PATCH v7 43/47] iotests: Let complete_and_wait() work with commit, Max Reitz, 2020/06/25
- [PATCH v7 42/47] iotests: Test that qcow2's data-file is flushed, Max Reitz, 2020/06/25
- [PATCH v7 44/47] iotests: Add filter commit test cases, Max Reitz, 2020/06/25