[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 08/18] block/backup-top: fix flags handling
From: |
Max Reitz |
Subject: |
[PULL 08/18] block/backup-top: fix flags handling |
Date: |
Thu, 20 Feb 2020 17:07:00 +0100 |
From: Vladimir Sementsov-Ogievskiy <address@hidden>
backup-top "supports" write-unchanged, by skipping CBW operation in
backup_top_co_pwritev. But it forgets to do the same in
backup_top_co_pwrite_zeroes, as well as declare support for
BDRV_REQ_WRITE_UNCHANGED.
Fix this, and, while being here, declare also support for flags
supported by source child.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
---
block/backup-top.c | 31 ++++++++++++++++++++-----------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/block/backup-top.c b/block/backup-top.c
index fa78f3256d..1bfb360bd3 100644
--- a/block/backup-top.c
+++ b/block/backup-top.c
@@ -48,11 +48,17 @@ static coroutine_fn int backup_top_co_preadv(
}
static coroutine_fn int backup_top_cbw(BlockDriverState *bs, uint64_t offset,
- uint64_t bytes)
+ uint64_t bytes, BdrvRequestFlags flags)
{
BDRVBackupTopState *s = bs->opaque;
- uint64_t end = QEMU_ALIGN_UP(offset + bytes, s->bcs->cluster_size);
- uint64_t off = QEMU_ALIGN_DOWN(offset, s->bcs->cluster_size);
+ uint64_t off, end;
+
+ if (flags & BDRV_REQ_WRITE_UNCHANGED) {
+ return 0;
+ }
+
+ off = QEMU_ALIGN_DOWN(offset, s->bcs->cluster_size);
+ end = QEMU_ALIGN_UP(offset + bytes, s->bcs->cluster_size);
return block_copy(s->bcs, off, end - off, NULL);
}
@@ -60,7 +66,7 @@ static coroutine_fn int backup_top_cbw(BlockDriverState *bs,
uint64_t offset,
static int coroutine_fn backup_top_co_pdiscard(BlockDriverState *bs,
int64_t offset, int bytes)
{
- int ret = backup_top_cbw(bs, offset, bytes);
+ int ret = backup_top_cbw(bs, offset, bytes, 0);
if (ret < 0) {
return ret;
}
@@ -71,7 +77,7 @@ static int coroutine_fn
backup_top_co_pdiscard(BlockDriverState *bs,
static int coroutine_fn backup_top_co_pwrite_zeroes(BlockDriverState *bs,
int64_t offset, int bytes, BdrvRequestFlags flags)
{
- int ret = backup_top_cbw(bs, offset, bytes);
+ int ret = backup_top_cbw(bs, offset, bytes, flags);
if (ret < 0) {
return ret;
}
@@ -84,11 +90,9 @@ static coroutine_fn int
backup_top_co_pwritev(BlockDriverState *bs,
uint64_t bytes,
QEMUIOVector *qiov, int flags)
{
- if (!(flags & BDRV_REQ_WRITE_UNCHANGED)) {
- int ret = backup_top_cbw(bs, offset, bytes);
- if (ret < 0) {
- return ret;
- }
+ int ret = backup_top_cbw(bs, offset, bytes, flags);
+ if (ret < 0) {
+ return ret;
}
return bdrv_co_pwritev(bs->backing, offset, bytes, qiov, flags);
@@ -196,8 +200,13 @@ BlockDriverState *bdrv_backup_top_append(BlockDriverState
*source,
return NULL;
}
- top->total_sectors = source->total_sectors;
state = top->opaque;
+ top->total_sectors = source->total_sectors;
+ top->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED |
+ (BDRV_REQ_FUA & source->supported_write_flags);
+ top->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED |
+ ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK) &
+ source->supported_zero_flags);
bdrv_ref(target);
state->target = bdrv_attach_child(top, target, "target", &child_file,
errp);
--
2.24.1
- [PULL 00/18] Block patches, Max Reitz, 2020/02/20
- [PULL 01/18] docs: improve qcow2 spec about extending image header, Max Reitz, 2020/02/20
- [PULL 02/18] docs: qcow2: introduce compression type feature, Max Reitz, 2020/02/20
- [PULL 03/18] iotests: Remove the superfluous 2nd check for the availability of quorum, Max Reitz, 2020/02/20
- [PULL 04/18] iotests/147: Fix drive parameters, Max Reitz, 2020/02/20
- [PULL 05/18] qapi: Allow getting flat output from 'query-named-block-nodes', Max Reitz, 2020/02/20
- [PULL 06/18] qemu-img: Add --target-is-zero to convert, Max Reitz, 2020/02/20
- [PULL 07/18] block: always fill entire LUKS header space with zeros, Max Reitz, 2020/02/20
- [PULL 08/18] block/backup-top: fix flags handling,
Max Reitz <=
- [PULL 09/18] iotests/279: Fix for non-qcow2 formats, Max Reitz, 2020/02/20
- [PULL 10/18] block/nbd: Fix hang in .bdrv_close(), Max Reitz, 2020/02/20
- [PULL 11/18] block: Generic file creation fallback, Max Reitz, 2020/02/20
- [PULL 12/18] file-posix: Drop hdev_co_create_opts(), Max Reitz, 2020/02/20
- [PULL 13/18] iscsi: Drop iscsi_co_create_opts(), Max Reitz, 2020/02/20
- [PULL 14/18] iotests: Add test for image creation fallback, Max Reitz, 2020/02/20
- [PULL 15/18] qemu-img: Fix convert -n -B for backing-less targets, Max Reitz, 2020/02/20
- [PULL 16/18] iotests: Test convert -n -B to backing-less target, Max Reitz, 2020/02/20