Block replication for continuous checkpoints
Subsystems (2)
cover Block replication for continuous checkpoints
Block replication is a very important feature which is used for continuous checkpoints(for example: COLO).
Usage:
Primary:
-drive if=xxx,driver=quorum,read-pattern=first,\
children.0.file.filename=1.raw,\
children.0.driver=raw,\
children.1.file.driver=nbd+colo,\
children.1.file.host=xxx,\
children.1.file.port=xxx,\
children.1.file.export=xxx,\
children.1.driver=raw Note:
1. NBD Client should not be the first child of quorum.
2. There should be only one NBD Client.
3. host is the secondary physical machine's hostname or IP
4. Each disk must have its own export name.
Secondary:
-drive if=xxx,driver=blkcolo,export=xxx,\
backing.file.filename=1.raw,\
backing.driver=raw Then run qmp command:
nbd_server_start host:port
Note:
1. The export name for the same disk must be the same in primary and secondary QEMU command line
2. The qmp command nbd_server_start must be run before running the qmp command migrate on primary QEMU
3. Don't use nbd_server_start's other options
You can get the patch here:
https://github.com/wencongyang/qemu-colo/commits/block-replication-v1
Wen Congyang (14):
docs: block replication's description
quorom: add a new read pattern
quorum: ignore 0-length child
Add new block driver interfaces to control disk replication
quorom: implement block driver interfaces for block replication NBD client: connect to nbd server later
NBD client: implement block driver interfaces for block replication
block: add a new API to create a hidden BlockBackend
block: give backing image its own BlockBackend
allow the backing image access the origin BlockDriverState allow writing to the backing file
Add disk buffer for block replication
COW: move cow interfaces to a seperate file
COLO: implement a new block driver
Makefile.objs | 2 +- block.c | 53 +++++- block/Makefile.objs | 1 + block/backup.c | 52 +----- block/blkcolo-buffer.c | 324 ++++++++++++++++++++++++++++++++ block/blkcolo.c | 409 +++++++++++++++++++++++++++++++++++++++++ block/blkcolo.h | 35 ++++ block/block-backend.c | 29 ++- block/nbd.c | 155 ++++++++++++++-- block/quorum.c | 79 +++++++- blockcow.c | 52 ++++++ docs/block-replication.txt | 129 +++++++++++++ include/block/block.h | 27 +++ include/block/block_int.h | 14 ++ include/sysemu/block-backend.h | 2 + qapi/block-core.json | 4 +- 16 files changed, 1295 insertions(+), 72 deletions(-) create mode 100644 block/blkcolo-buffer.c create mode 100644 block/blkcolo.c create mode 100644 block/blkcolo.h create mode 100644 blockcow.c create mode 100644 docs/block-replication.txt
Signature · 1 line
2.1.0
RFC PATCH 1/14 docs: block replication's description
--- docs/block-replication.txt | 129 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 docs/block-replication.txt
docs/block-replication.txt new file +129 -0
@@ -0,0 +1,129 @@ +Block replication +---------------------------------------- +Copyright Fujitsu, Corp. 2015 +Copyright (c) 2015 Intel Corporation +Copyright (c) 2015 HUAWEI TECHNOLOGIES CO.,LTD. + +This work is licensed under the terms of the GNU GPL, version 2 or later. +See the COPYING file in the top-level directory. + +The block replication is used for continuous checkpoints. It is designed +for COLO that Secondary VM is running. It can also be applied for FT/HA +scene that Secondary VM is not running. + +This document gives an overview of block replication's design. + +== Background == +High availability solutions such as micro checkpoint and COLO will do +consecutive checkpoint. The VM state of Primary VM and Secondary VM is +identical right after a VM checkpoint, but becomes different as the VM +executes till the next checkpoint. To support disk contents checkpoint, +the modified disk contents in the Secondary VM must be buffered, and are +only dropped at next checkpoint time. To reduce the network transportation +effort at the time of checkpoint, the disk modification operations of +Primary disk are asynchronously forwarded to the Secondary node. + +== Workflow == +The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V | + +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer. + 3) Primary write requests will be written to Secondary disk. + 4) Secondary write requests will be buffered in the Disk buffer and it + will overwrite the existing sector content in the buffer. + +== Architecture == +We are going to implement COLO block replication from many basic +blocks that are already in QEMU. + + virtio-blk || + ^ || .---------- + | || | Secondary + 1 Quorum || '---------- + / \ || + / \ || + Primary 2 NBD -------> 2 NBD + disk client || server virtio-blk + || ^ ^ +--------. || | | +Primary | || Secondary disk <--------- COLO buffer 3 +--------' || backing + +1) The disk on the primary is represented by a block device with two +children, providing replication between a primary disk and the host that +runs the secondary VM. The read pattern for quorum can be extended to +make the primary always read from the local disk instead of going through +NBD. + +2) The secondary disk receives writes from the primary VM through QEMU's +embedded NBD server (speculative write-through). + +3) The disk on the secondary is represented by a custom block device +("COLO buffer"). The disk buffer's backing image is the secondary disk, +and the disk buffer uses bdrv_add_before_write_notifier to implement +copy-on-write, similar to block/backup.c. + +== New block driver interface == +We add three block driver interfaces to control block replication: +a. bdrv_start_replication() + Start block replication, called in migration/checkpoint thread. + We must call bdrv_start_replication() in secondary QEMU before + calling bdrv_start_replication() in primary QEMU. +b. bdrv_do_checkpoint() + This interface is called after all VM state is transfered to + Secondary QEMU. The Disk buffer will be dropped in this interface. +c. bdrv_stop_replication() + It is called when failover. We will flush the Disk buffer into + Secondary Disk and stop block replication. + +== Usage == +Primary: + -drive if=xxx,driver=quorum,read-pattern=first,\ + children.0.file.filename=1.raw,\ + children.0.driver=raw,\ + children.1.file.driver=nbd+colo,\ + children.1.file.host=xxx,\ + children.1.file.port=xxx,\ + children.1.file.export=xxx,\ + children.1.driver=raw + Note: + 1. NBD Client should not be the first child of quorum. + 2. There should be only one NBD Client. + 3. host is the secondary physical machine's hostname or IP + 4. Each disk must have its own export name. + +Secondary: + -drive if=xxx,driver=blkcolo,export=xxx,\ + backing.file.filename=1.raw,\ + backing.driver=raw + Then run qmp command: + nbd_server_start host:port + Note: + 1. The export name for the same disk must be the same in primary + and secondary QEMU command line + 2. The qmp command nbd_server_start must be run before running the + qmp command migrate on primary QEMU + 3. Don't use nbd_server_start's other options
Signature · 1 line
2.1.0
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Hi Congyang,
Quoted 18 lines · Wen Congyang
+== Workflow ==
docs/block-replication.txt new file +17
-0+The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V |
docs/block-replication.txt line 53
Quoted 10 lines
docs/block-replication.txt new file +10
-0+ +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.
I'm a little confused by the tenses ("will be" versus "are") and terms. I am reading them as "s/will be/are/g"
Why do you need this buffer?
If both primary and secondary write to the same sector, what is saved in the buffer?
Fam
Quoted 4 lines
docs/block-replication.txt new file +4
-0+ 3) Primary write requests will be written to Secondary disk. + 4) Secondary write requests will be buffered in the Disk buffer and it + will overwrite the existing sector content in the buffer. +
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 35 lines · Fam Zheng
Hi Congyang,
Quoted 18 lines · Wen Congyang
+== Workflow ==
docs/block-replication.txt new file +17
-0+The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V |docs/block-replication.txt line 53
Quoted 10 lines
docs/block-replication.txt new file +10
-0+ +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.I'm a little confused by the tenses ("will be" versus "are") and terms. I am reading them as "s/will be/are/g"
Quoted 1 line
Why do you need this buffer?
We only sync the disk till next checkpoint. Before next checkpoint, secondary vm write to the buffer.
Quoted 3 lines
If both primary and secondary write to the same sector, what is saved in the buffer?
The primary content will be written to the secondary disk, and the secondary content is saved in the buffer.
Thanks
Wen Congyang
Quoted 9 lines
Fam
docs/block-replication.txt line 57
Quoted 4 lines
docs/block-replication.txt new file +4
-0+ 3) Primary write requests will be written to Secondary disk. + 4) Secondary write requests will be buffered in the Disk buffer and it + will overwrite the existing sector content in the buffer. +.
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 42 lines · Wen Congyang
Quoted 35 lines · Fam Zheng
Hi Congyang,
Quoted 18 lines · Wen Congyang
+== Workflow ==
docs/block-replication.txt new file +17
-0+The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V |docs/block-replication.txt line 53
Quoted 10 lines
docs/block-replication.txt new file +10
-0+ +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.I'm a little confused by the tenses ("will be" versus "are") and terms. I am reading them as "s/will be/are/g"
Quoted 1 line
Why do you need this buffer?
We only sync the disk till next checkpoint. Before next checkpoint, secondary vm write to the buffer.
Quoted 1 line
Quoted 5 lines
Quoted 2 lines
If both primary and secondary write to the same sector, what is saved in the buffer?
The primary content will be written to the secondary disk, and the secondary content is saved in the buffer.
I wonder if alternatively this is possible with an imaginary "writable backing image" feature, as described below.
When we have a normal backing chain,
{virtio-blk dev 'foo'}
|
|
|
[base] <- [mid] <- (foo)Where [base] and [mid] are read only, (foo) is writable. When we add an overlay to an existing image on top,
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'}
| |
| |
| |
[base] <- [mid] <- (foo) <---------------------- (bar)It's important to make sure that writes to 'foo' doesn't break data for 'bar'. We can utilize an automatic hidden drive-backup target:
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'}
| |
| |
v v
[base] <- [mid] <- (foo) <----------------- (hidden target) <--------------- (bar)
v ^
v ^
v ^
v ^
>>>> drive-backup sync=none >>>>So when guest writes to 'foo', the old data is moved to (hidden target), which remains unchanged from (bar)'s PoV.
The drive in the middle is called hidden because QEMU creates it automatically, the naming is arbitrary.
It is interesting because it is a more generalized case of image fleecing, where the (hidden target) is exposed via NBD server for data scanning (read only) purpose.
More interestingly, with above facility, it is also possible to create a guest visible live snapshot (disk 'bar') of an existing device (disk 'foo') very cheaply. Or call it shadow copy if you will.
Back to the COLO case, the configuration will be very similar:
{primary wr} {secondary vm}
| |
| |
| |
v v[what] <- [ever] <- (nbd target) <------------ (hidden buf disk) <------------- (active disk)
v ^
v ^
v ^
v ^
>>>> drive-backup sync=none >>>>The workflow analogue is:
Quoted 2 lines
Quoted 2 lines
docs/block-replication.txt line 49
Quoted 2 lines
docs/block-replication.txt new file +2
-0+ 1) Primary write requests will be copied and forwarded to Secondary + QEMU.
Primary write requests are forwarded to secondary QEMU as well.
Quoted 4 lines
Quoted 4 lines
docs/block-replication.txt line 53
Quoted 4 lines
docs/block-replication.txt new file +4
-0+ 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.
Before Primary write requests are written to (nbd target), aka the Secondary disk, the orignal sector content is read from it and copied to (hidden buf disk) by drive-backup. It obviously will not overwrite the data in (active disk).
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ 3) Primary write requests will be written to Secondary disk.
Primary write requests are written to (nbd target).
Quoted 2 lines
Quoted 2 lines
docs/block-replication.txt line 56
Quoted 2 lines
docs/block-replication.txt new file +2
-0+ 4) Secondary write requests will be buffered in the Disk buffer and it + will overwrite the existing sector content in the buffer.
Secondary write request will be written in (active disk) as usual.
Finally, when checkpoint arrives, if you want to sync with primary, just drop data in (hidden buf disk) and (active disk); when failover happends, if you want to promote secondary vm, you can commit (active disk) to (nbd target), and drop data in (hidden buf disk).
Fam
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 108 lines · Fam Zheng
Quoted 42 lines · Wen Congyang
Quoted 35 lines · Fam Zheng
Hi Congyang,
Quoted 18 lines · Wen Congyang
+== Workflow ==
docs/block-replication.txt new file +17
-0+The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V |docs/block-replication.txt line 53
Quoted 10 lines
docs/block-replication.txt new file +10
-0+ +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.I'm a little confused by the tenses ("will be" versus "are") and terms. I am reading them as "s/will be/are/g"
Quoted 1 line
Why do you need this buffer?
We only sync the disk till next checkpoint. Before next checkpoint, secondary vm write to the buffer.
Quoted 1 line
Quoted 5 lines
Quoted 2 lines
If both primary and secondary write to the same sector, what is saved in the buffer?
The primary content will be written to the secondary disk, and the secondary content is saved in the buffer.
I wonder if alternatively this is possible with an imaginary "writable backing image" feature, as described below.
When we have a normal backing chain,
{virtio-blk dev 'foo'} | | | [base] <- [mid] <- (foo)Where [base] and [mid] are read only, (foo) is writable. When we add an overlay to an existing image on top,
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | | | [base] <- [mid] <- (foo) <---------------------- (bar)It's important to make sure that writes to 'foo' doesn't break data for 'bar'. We can utilize an automatic hidden drive-backup target:
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | v v [base] <- [mid] <- (foo) <----------------- (hidden target) <--------------- (bar) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>So when guest writes to 'foo', the old data is moved to (hidden target), which remains unchanged from (bar)'s PoV.
The drive in the middle is called hidden because QEMU creates it automatically, the naming is arbitrary.
It is interesting because it is a more generalized case of image fleecing, where the (hidden target) is exposed via NBD server for data scanning (read only) purpose.
More interestingly, with above facility, it is also possible to create a guest visible live snapshot (disk 'bar') of an existing device (disk 'foo') very cheaply. Or call it shadow copy if you will.
Back to the COLO case, the configuration will be very similar:
{primary wr} {secondary vm} | | | | | | v v
Quoted 7 lines
[what] <- [ever] <- (nbd target) <------------ (hidden buf disk) <------------- (active disk)
v ^
v ^
v ^
v ^
>>>> drive-backup sync=none >>>>What is active disk? There are two disk images?
Thanks
Wen Congyang
Quoted 35 lines
The workflow analogue is:
Quoted 2 lines
Quoted 2 lines
docs/block-replication.txt line 49
Quoted 2 lines
docs/block-replication.txt new file +2
-0+ 1) Primary write requests will be copied and forwarded to Secondary + QEMU.Primary write requests are forwarded to secondary QEMU as well.
Quoted 4 lines
Quoted 4 lines
docs/block-replication.txt line 53
Quoted 4 lines
docs/block-replication.txt new file +4
-0+ 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.Before Primary write requests are written to (nbd target), aka the Secondary disk, the orignal sector content is read from it and copied to (hidden buf disk) by drive-backup. It obviously will not overwrite the data in (active disk).
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ 3) Primary write requests will be written to Secondary disk.
Primary write requests are written to (nbd target).
Quoted 2 lines
Quoted 2 lines
docs/block-replication.txt line 56
Quoted 2 lines
docs/block-replication.txt new file +2
-0+ 4) Secondary write requests will be buffered in the Disk buffer and it + will overwrite the existing sector content in the buffer.Secondary write request will be written in (active disk) as usual.
Finally, when checkpoint arrives, if you want to sync with primary, just drop data in (hidden buf disk) and (active disk); when failover happends, if you want to promote secondary vm, you can commit (active disk) to (nbd target), and drop data in (hidden buf disk).
Fam
.
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 111 lines · Wen Congyang
Quoted 110 lines · Fam Zheng
Quoted 42 lines · Wen Congyang
Quoted 35 lines · Fam Zheng
Hi Congyang,
Quoted 18 lines · Wen Congyang
+== Workflow ==
docs/block-replication.txt new file +17
-0+The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V |docs/block-replication.txt line 53
Quoted 10 lines
docs/block-replication.txt new file +10
-0+ +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.I'm a little confused by the tenses ("will be" versus "are") and terms. I am reading them as "s/will be/are/g"
Quoted 1 line
Why do you need this buffer?
We only sync the disk till next checkpoint. Before next checkpoint, secondary vm write to the buffer.
Quoted 1 line
Quoted 5 lines
Quoted 2 lines
If both primary and secondary write to the same sector, what is saved in the buffer?
The primary content will be written to the secondary disk, and the secondary content is saved in the buffer.
I wonder if alternatively this is possible with an imaginary "writable backing image" feature, as described below.
When we have a normal backing chain,
{virtio-blk dev 'foo'} | | | [base] <- [mid] <- (foo)Where [base] and [mid] are read only, (foo) is writable. When we add an overlay to an existing image on top,
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | | | [base] <- [mid] <- (foo) <---------------------- (bar)It's important to make sure that writes to 'foo' doesn't break data for 'bar'. We can utilize an automatic hidden drive-backup target:
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | v v [base] <- [mid] <- (foo) <----------------- (hidden target) <--------------- (bar) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>So when guest writes to 'foo', the old data is moved to (hidden target), which remains unchanged from (bar)'s PoV.
The drive in the middle is called hidden because QEMU creates it automatically, the naming is arbitrary.
It is interesting because it is a more generalized case of image fleecing, where the (hidden target) is exposed via NBD server for data scanning (read only) purpose.
More interestingly, with above facility, it is also possible to create a guest visible live snapshot (disk 'bar') of an existing device (disk 'foo') very cheaply. Or call it shadow copy if you will.
Back to the COLO case, the configuration will be very similar:
{primary wr} {secondary vm} | | | | | | v v[what] <- [ever] <- (nbd target) <------------ (hidden buf disk) <------------- (active disk)
Quoted 7 lines
Quoted 5 lines
v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>What is active disk? There are two disk images?
It starts as an empty image with (hidden buf disk) as backing file, which in turn has (nbd target) as backing file.
Fam
Quoted 41 lines
Thanks
Wen CongyangQuoted 35 lines
The workflow analogue is:
Quoted 2 lines
Quoted 2 lines
docs/block-replication.txt line 49
Quoted 2 lines
docs/block-replication.txt new file +2
-0+ 1) Primary write requests will be copied and forwarded to Secondary + QEMU.Primary write requests are forwarded to secondary QEMU as well.
Quoted 4 lines
Quoted 4 lines
docs/block-replication.txt line 53
Quoted 4 lines
docs/block-replication.txt new file +4
-0+ 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.Before Primary write requests are written to (nbd target), aka the Secondary disk, the orignal sector content is read from it and copied to (hidden buf disk) by drive-backup. It obviously will not overwrite the data in (active disk).
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ 3) Primary write requests will be written to Secondary disk.
Primary write requests are written to (nbd target).
Quoted 2 lines
Quoted 2 lines
docs/block-replication.txt line 56
Quoted 2 lines
docs/block-replication.txt new file +2
-0+ 4) Secondary write requests will be buffered in the Disk buffer and it + will overwrite the existing sector content in the buffer.Secondary write request will be written in (active disk) as usual.
Finally, when checkpoint arrives, if you want to sync with primary, just drop data in (hidden buf disk) and (active disk); when failover happends, if you want to promote secondary vm, you can commit (active disk) to (nbd target), and drop data in (hidden buf disk).
Fam
.
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 118 lines · Fam Zheng
Quoted 117 lines · Wen Congyang
Quoted 115 lines · Fam Zheng
Quoted 42 lines · Wen Congyang
Quoted 35 lines · Fam Zheng
Hi Congyang,
Quoted 18 lines · Wen Congyang
+== Workflow ==
docs/block-replication.txt new file +17
-0+The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V |docs/block-replication.txt line 53
Quoted 10 lines
docs/block-replication.txt new file +10
-0+ +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.I'm a little confused by the tenses ("will be" versus "are") and terms. I am reading them as "s/will be/are/g"
Quoted 1 line
Why do you need this buffer?
We only sync the disk till next checkpoint. Before next checkpoint, secondary vm write to the buffer.
Quoted 1 line
Quoted 5 lines
Quoted 2 lines
If both primary and secondary write to the same sector, what is saved in the buffer?
The primary content will be written to the secondary disk, and the secondary content is saved in the buffer.
I wonder if alternatively this is possible with an imaginary "writable backing image" feature, as described below.
When we have a normal backing chain,
{virtio-blk dev 'foo'} | | | [base] <- [mid] <- (foo)Where [base] and [mid] are read only, (foo) is writable. When we add an overlay to an existing image on top,
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | | | [base] <- [mid] <- (foo) <---------------------- (bar)It's important to make sure that writes to 'foo' doesn't break data for 'bar'. We can utilize an automatic hidden drive-backup target:
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | v v [base] <- [mid] <- (foo) <----------------- (hidden target) <--------------- (bar) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>So when guest writes to 'foo', the old data is moved to (hidden target), which remains unchanged from (bar)'s PoV.
The drive in the middle is called hidden because QEMU creates it automatically, the naming is arbitrary.
It is interesting because it is a more generalized case of image fleecing, where the (hidden target) is exposed via NBD server for data scanning (read only) purpose.
More interestingly, with above facility, it is also possible to create a guest visible live snapshot (disk 'bar') of an existing device (disk 'foo') very cheaply. Or call it shadow copy if you will.
Back to the COLO case, the configuration will be very similar:
{primary wr} {secondary vm} | | | | | | v v[what] <- [ever] <- (nbd target) <------------ (hidden buf disk) <------------- (active disk) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>
Quoted 4 lines
Quoted 1 line
What is active disk? There are two disk images?
It starts as an empty image with (hidden buf disk) as backing file, which in turn has (nbd target) as backing file.
It's too complicated..., and I don't understand it.
1. What is active disk? Use raw or a new block driver?
2. Hidden buf disk use new block driver?
3. nbd target is hidden buf disk's backing image? If it is opened read-only, we will export a nbd with read-only BlockDriverState, but nbd server needs to write it.
Thanks
Wen Congyang
Quoted 46 lines
Fam
Quoted 41 lines
Thanks
Wen CongyangQuoted 35 lines
The workflow analogue is:
Quoted 2 lines
Quoted 2 lines
docs/block-replication.txt line 49
Quoted 2 lines
docs/block-replication.txt new file +2
-0+ 1) Primary write requests will be copied and forwarded to Secondary + QEMU.Primary write requests are forwarded to secondary QEMU as well.
Quoted 4 lines
Quoted 4 lines
docs/block-replication.txt line 53
Quoted 4 lines
docs/block-replication.txt new file +4
-0+ 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.Before Primary write requests are written to (nbd target), aka the Secondary disk, the orignal sector content is read from it and copied to (hidden buf disk) by drive-backup. It obviously will not overwrite the data in (active disk).
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ 3) Primary write requests will be written to Secondary disk.
Primary write requests are written to (nbd target).
Quoted 2 lines
Quoted 2 lines
docs/block-replication.txt line 56
Quoted 2 lines
docs/block-replication.txt new file +2
-0+ 4) Secondary write requests will be buffered in the Disk buffer and it + will overwrite the existing sector content in the buffer.Secondary write request will be written in (active disk) as usual.
Finally, when checkpoint arrives, if you want to sync with primary, just drop data in (hidden buf disk) and (active disk); when failover happends, if you want to promote secondary vm, you can commit (active disk) to (nbd target), and drop data in (hidden buf disk).
Fam
..
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 119 lines · Wen Congyang
Quoted 118 lines · Fam Zheng
Quoted 117 lines · Wen Congyang
Quoted 115 lines · Fam Zheng
Quoted 42 lines · Wen Congyang
Quoted 35 lines · Fam Zheng
Hi Congyang,
Quoted 18 lines · Wen Congyang
+== Workflow ==
(quoted diff) +17
-0+The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V |Review
Quoted 10 lines
(quoted diff) +10
-0+ +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.I'm a little confused by the tenses ("will be" versus "are") and terms. I am reading them as "s/will be/are/g"
Quoted 1 line
Why do you need this buffer?
We only sync the disk till next checkpoint. Before next checkpoint, secondary vm write to the buffer.
Quoted 1 line
Quoted 5 lines
Quoted 2 lines
If both primary and secondary write to the same sector, what is saved in the buffer?
The primary content will be written to the secondary disk, and the secondary content is saved in the buffer.
I wonder if alternatively this is possible with an imaginary "writable backing image" feature, as described below.
When we have a normal backing chain,
{virtio-blk dev 'foo'} | | | [base] <- [mid] <- (foo)Where [base] and [mid] are read only, (foo) is writable. When we add an overlay to an existing image on top,
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | | | [base] <- [mid] <- (foo) <---------------------- (bar)It's important to make sure that writes to 'foo' doesn't break data for 'bar'. We can utilize an automatic hidden drive-backup target:
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | v v [base] <- [mid] <- (foo) <----------------- (hidden target) <--------------- (bar) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>So when guest writes to 'foo', the old data is moved to (hidden target), which remains unchanged from (bar)'s PoV.
The drive in the middle is called hidden because QEMU creates it automatically, the naming is arbitrary.
It is interesting because it is a more generalized case of image fleecing, where the (hidden target) is exposed via NBD server for data scanning (read only) purpose.
More interestingly, with above facility, it is also possible to create a guest visible live snapshot (disk 'bar') of an existing device (disk 'foo') very cheaply. Or call it shadow copy if you will.
Back to the COLO case, the configuration will be very similar:
{primary wr} {secondary vm} | | | | | | v v[what] <- [ever] <- (nbd target) <------------ (hidden buf disk) <------------- (active disk) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
What is active disk? There are two disk images?
It starts as an empty image with (hidden buf disk) as backing file, which in turn has (nbd target) as backing file.
It's too complicated..., and I don't understand it.
1. What is active disk? Use raw or a new block driver?
It is an empty qcow2 image with the same lenght as your Secondary Disk.
Quoted 1 line
2. Hidden buf disk use new block driver?
It is an empty qcow2 image with the same lenght as your Secondary Disk, too.
Quoted 2 lines
3. nbd target is hidden buf disk's backing image? If it is opened read-only, we will export a nbd with read-only BlockDriverState, but nbd server needs to write it.
NBD target is your Secondary Disk. It is opened read-write.
The patches to enable opening it as read-write, and starting drive-backup between it and hidden buf disk, are all work in progress (the core concept) of image fleecing.
Fam
Quoted 40 lines
Quoted 39 lines
Quoted 27 lines
Quoted 27 lines
The workflow analogue is:
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ 1) Primary write requests will be copied and forwarded to Secondary + QEMU.Primary write requests are forwarded to secondary QEMU as well.
Quoted 4 lines
Quoted 4 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.Before Primary write requests are written to (nbd target), aka the Secondary disk, the orignal sector content is read from it and copied to (hidden buf disk) by drive-backup. It obviously will not overwrite the data in (active disk).
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ 3) Primary write requests will be written to Secondary disk.
Primary write requests are written to (nbd target).
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ 4) Secondary write requests will be buffered in the Disk buffer and it + will overwrite the existing sector content in the buffer.Secondary write request will be written in (active disk) as usual.
Quoted 10 lines
Quoted 8 lines
Finally, when checkpoint arrives, if you want to sync with primary, just drop data in (hidden buf disk) and (active disk); when failover happends, if you want to promote secondary vm, you can commit (active disk) to (nbd target), and drop data in (hidden buf disk).
Fam
..
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 134 lines · On 02/12/2015 06:26 PM, [email protected] wrote:
Quoted 119 lines · Wen Congyang
Quoted 118 lines · Fam Zheng
Quoted 117 lines · Wen Congyang
Quoted 115 lines · Fam Zheng
Quoted 42 lines · Wen Congyang
Quoted 35 lines · Fam Zheng
Hi Congyang,
Quoted 18 lines · Wen Congyang
+== Workflow ==
(quoted diff) +17
-0+The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V |Review
Quoted 10 lines
(quoted diff) +10
-0+ +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.I'm a little confused by the tenses ("will be" versus "are") and terms. I am reading them as "s/will be/are/g"
Quoted 1 line
Why do you need this buffer?
We only sync the disk till next checkpoint. Before next checkpoint, secondary vm write to the buffer.
Quoted 1 line
Quoted 5 lines
Quoted 2 lines
If both primary and secondary write to the same sector, what is saved in the buffer?
The primary content will be written to the secondary disk, and the secondary content is saved in the buffer.
I wonder if alternatively this is possible with an imaginary "writable backing image" feature, as described below.
When we have a normal backing chain,
{virtio-blk dev 'foo'} | | | [base] <- [mid] <- (foo)Where [base] and [mid] are read only, (foo) is writable. When we add an overlay to an existing image on top,
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | | | [base] <- [mid] <- (foo) <---------------------- (bar)It's important to make sure that writes to 'foo' doesn't break data for 'bar'. We can utilize an automatic hidden drive-backup target:
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | v v [base] <- [mid] <- (foo) <----------------- (hidden target) <--------------- (bar) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>So when guest writes to 'foo', the old data is moved to (hidden target), which remains unchanged from (bar)'s PoV.
The drive in the middle is called hidden because QEMU creates it automatically, the naming is arbitrary.
It is interesting because it is a more generalized case of image fleecing, where the (hidden target) is exposed via NBD server for data scanning (read only) purpose.
More interestingly, with above facility, it is also possible to create a guest visible live snapshot (disk 'bar') of an existing device (disk 'foo') very cheaply. Or call it shadow copy if you will.
Back to the COLO case, the configuration will be very similar:
{primary wr} {secondary vm} | | | | | | v v[what] <- [ever] <- (nbd target) <------------ (hidden buf disk) <------------- (active disk) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>Quoted 7 lines
Quoted 4 lines
Quoted 1 line
What is active disk? There are two disk images?
It starts as an empty image with (hidden buf disk) as backing file, which in turn has (nbd target) as backing file.
It's too complicated..., and I don't understand it.
1. What is active disk? Use raw or a new block driver?It is an empty qcow2 image with the same lenght as your Secondary Disk.
Quoted 1 line
2. Hidden buf disk use new block driver?
It is an empty qcow2 image with the same lenght as your Secondary Disk, too.
Quoted 8 lines
Quoted 2 lines
3. nbd target is hidden buf disk's backing image? If it is opened read-only, we will export a nbd with read-only BlockDriverState, but nbd server needs to write it.
NBD target is your Secondary Disk. It is opened read-write.
The patches to enable opening it as read-write, and starting drive-backup between it and hidden buf disk, are all work in progress (the core concept) of image fleecing.
What is image fleecing? Are you implementing it now?
Thanks
Wen Congyang
Quoted 45 lines
Fam
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
The workflow analogue is:
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ 1) Primary write requests will be copied and forwarded to Secondary + QEMU.Primary write requests are forwarded to secondary QEMU as well.
Quoted 4 lines
Quoted 4 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.Before Primary write requests are written to (nbd target), aka the Secondary disk, the orignal sector content is read from it and copied to (hidden buf disk) by drive-backup. It obviously will not overwrite the data in (active disk).
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ 3) Primary write requests will be written to Secondary disk.
Primary write requests are written to (nbd target).
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ 4) Secondary write requests will be buffered in the Disk buffer and it + will overwrite the existing sector content in the buffer.Secondary write request will be written in (active disk) as usual.
Finally, when checkpoint arrives, if you want to sync with primary, just drop data in (hidden buf disk) and (active disk); when failover happends, if you want to promote secondary vm, you can commit (active disk) to (nbd target), and drop data in (hidden buf disk).
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Fam
..
.
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 2 lines · Wen Congyang
What is image fleecing?
It's the name of the feature which enables the built-in NBD server to exporting a thin point-in-time snapshot created via drive-backup sync=none.
It's for host side data scanning tool to access a disk snapshot of running VM. The workflow in theory is:
1. guest uses "disk0" as its virtio-blk device.
2. in qmp, use blockdev-add (drive-backup) to add an empty "target0" qcow2 image, that uses "disk0" as its backing file, and use nbd-server-add to export this empty image with NBD. This way, all reads coming from NBD client will produce data of "disk0".
3. in qmp, start blockdev-backup from "disk0" to "target0" with "sync=none". After this point, all guest data written to "disk0" will COW the original data to "target0", in other words, reading "target0" will effectively produce a point-in-time snapshot of the time when blockdev-backup started.
4. after step 3, the disk data seen by the NBD client is the stable snapshot. Because of the COW mechanism in blockdev-backup, "target0" is thin, and can be dropped once the inspection process is done.
Quoted 1 line
Are you implementing it now?
I worked on it. Most parts of the series is merged, the remaining part is relatively small, namely to
1) enable adding "target0" in step 2 (currently in blockdev-add it's not possible to reference an existing drive as backing file);
2) enable "blockdev-backup" from "disk0" to "target0", which is obviously not possible because 1) is not done.
I do have the patches at my tree, just that they need to be refreshed. :)
https://github.com/famz/qemu/tree/image-fleecing
Fam
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 34 lines · Fam Zheng
Quoted 2 lines · Wen Congyang
What is image fleecing?
It's the name of the feature which enables the built-in NBD server to exporting a thin point-in-time snapshot created via drive-backup sync=none.
It's for host side data scanning tool to access a disk snapshot of running VM. The workflow in theory is:
1. guest uses "disk0" as its virtio-blk device.
2. in qmp, use blockdev-add (drive-backup) to add an empty "target0" qcow2 image, that uses "disk0" as its backing file, and use nbd-server-add to export this empty image with NBD. This way, all reads coming from NBD client will produce data of "disk0".
3. in qmp, start blockdev-backup from "disk0" to "target0" with "sync=none". After this point, all guest data written to "disk0" will COW the original data to "target0", in other words, reading "target0" will effectively produce a point-in-time snapshot of the time when blockdev-backup started.
4. after step 3, the disk data seen by the NBD client is the stable snapshot. Because of the COW mechanism in blockdev-backup, "target0" is thin, and can be dropped once the inspection process is done.
Quoted 1 line
Are you implementing it now?
I worked on it. Most parts of the series is merged, the remaining part is relatively small, namely to
1) enable adding "target0" in step 2 (currently in blockdev-add it's not possible to reference an existing drive as backing file);
Quoted 9 lines
2) enable "blockdev-backup" from "disk0" to "target0", which is obviously not possible because 1) is not done.
I do have the patches at my tree, just that they need to be refreshed. :)
https://github.com/famz/qemu/tree/image-fleecing
Fam
I had intended to pick up these patches after I got incremental backup working, as Fam had started both of these projects and I inherited them -- though I hadn't begun work in earnest on refining and testing this particular feature yet.
--js
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
In reply to [email protected]Quoted 122 lines · On 02/12/2015 06:26 PM, [email protected] wrote:
Quoted 121 lines · Wen Congyang
Quoted 120 lines · Fam Zheng
Quoted 118 lines · Wen Congyang
Quoted 108 lines · Fam Zheng
Quoted 42 lines · Wen Congyang
Quoted 35 lines · Fam Zheng
Hi Congyang,
Quoted 18 lines · Wen Congyang
+== Workflow ==
(quoted diff) +17
-0+The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V |Review
Quoted 10 lines
(quoted diff) +10
-0+ +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.I'm a little confused by the tenses ("will be" versus "are") and terms. I am reading them as "s/will be/are/g"
Quoted 1 line
Why do you need this buffer?
We only sync the disk till next checkpoint. Before next checkpoint, secondary vm write to the buffer.
Quoted 1 line
Quoted 5 lines
Quoted 2 lines
If both primary and secondary write to the same sector, what is saved in the buffer?
The primary content will be written to the secondary disk, and the secondary content is saved in the buffer.
I wonder if alternatively this is possible with an imaginary "writable backing image" feature, as described below.
When we have a normal backing chain,
{virtio-blk dev 'foo'} | | | [base] <- [mid] <- (foo)Where [base] and [mid] are read only, (foo) is writable. When we add an overlay to an existing image on top,
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | | | [base] <- [mid] <- (foo) <---------------------- (bar)It's important to make sure that writes to 'foo' doesn't break data for 'bar'. We can utilize an automatic hidden drive-backup target:
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | v v [base] <- [mid] <- (foo) <----------------- (hidden target) <--------------- (bar) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>So when guest writes to 'foo', the old data is moved to (hidden target), which remains unchanged from (bar)'s PoV.
The drive in the middle is called hidden because QEMU creates it automatically, the naming is arbitrary.
It is interesting because it is a more generalized case of image fleecing, where the (hidden target) is exposed via NBD server for data scanning (read only) purpose.
More interestingly, with above facility, it is also possible to create a guest visible live snapshot (disk 'bar') of an existing device (disk 'foo') very cheaply. Or call it shadow copy if you will.
Back to the COLO case, the configuration will be very similar:
{primary wr} {secondary vm} | | | | | | v vQuoted 7 lines
[what] <- [ever] <- (nbd target) <------------ (hidden buf disk) <------------- (active disk) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>What is active disk? There are two disk images?
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
It starts as an empty image with (hidden buf disk) as backing file, which in turn has (nbd target) as backing file.
It's too complicated..., and I don't understand it.
1. What is active disk? Use raw or a new block driver?It is an empty qcow2 image with the same lenght as your Secondary Disk.
I test qcow2_make_empty()'s performance. The result shows that it may take about 100ms(normal sata disk). It is not acceptable for COLO. So I think disk buff is necessary(just use it to replace qcow2).
Thanks
Wen Congyang
Quoted 58 lines
Quoted 2 lines
2. Hidden buf disk use new block driver?
It is an empty qcow2 image with the same lenght as your Secondary Disk, too.
Quoted 2 lines
3. nbd target is hidden buf disk's backing image? If it is opened read-only, we will export a nbd with read-only BlockDriverState, but nbd server needs to write it.
NBD target is your Secondary Disk. It is opened read-write.
The patches to enable opening it as read-write, and starting drive-backup between it and hidden buf disk, are all work in progress (the core concept) of image fleecing.
Fam
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
The workflow analogue is:
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ 1) Primary write requests will be copied and forwarded to Secondary + QEMU.Primary write requests are forwarded to secondary QEMU as well.
Quoted 4 lines
Quoted 4 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.Before Primary write requests are written to (nbd target), aka the Secondary disk, the orignal sector content is read from it and copied to (hidden buf disk) by drive-backup. It obviously will not overwrite the data in (active disk).
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ 3) Primary write requests will be written to Secondary disk.
Primary write requests are written to (nbd target).
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ 4) Secondary write requests will be buffered in the Disk buffer and it + will overwrite the existing sector content in the buffer.Secondary write request will be written in (active disk) as usual.
Finally, when checkpoint arrives, if you want to sync with primary, just drop data in (hidden buf disk) and (active disk); when failover happends, if you want to promote secondary vm, you can commit (active disk) to (nbd target), and drop data in (hidden buf disk).
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Fam
..
.
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 3 lines · Wen Congyang
I test qcow2_make_empty()'s performance. The result shows that it may take about 100ms(normal sata disk). It is not acceptable for COLO. So I think disk buff is necessary(just use it to replace qcow2).
Why not tmpfs or ramdisk?
Fam
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 6 lines · Fam Zheng
Quoted 3 lines · Wen Congyang
I test qcow2_make_empty()'s performance. The result shows that it may take about 100ms(normal sata disk). It is not acceptable for COLO. So I think disk buff is necessary(just use it to replace qcow2).
Why not tmpfs or ramdisk?
I test it, and it only takes 2-3ms.
Thanks
Wen Congyang
Quoted 4 lines
Fam
.
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
In reply to Fam ZhengQuoted 6 lines · Fam Zheng
Quoted 3 lines · Wen Congyang
I test qcow2_make_empty()'s performance. The result shows that it may take about 100ms(normal sata disk). It is not acceptable for COLO. So I think disk buff is necessary(just use it to replace qcow2).
Why not tmpfs or ramdisk?
Another problem:
After failover, secondary write request will be written in (active disk)? It is better to write request to (nbd target). Is there any feature can be reused to implement it?
Thanks
Wen Congyang
Quoted 4 lines
Fam
.
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 6 lines · Wen Congyang
Quoted 5 lines · Fam Zheng
Quoted 3 lines · Wen Congyang
I test qcow2_make_empty()'s performance. The result shows that it may take about 100ms(normal sata disk). It is not acceptable for COLO. So I think disk buff is necessary(just use it to replace qcow2).
Quoted 6 lines
Quoted 1 line
Why not tmpfs or ramdisk?
Another problem:
After failover, secondary write request will be written in (active disk)? It is better to write request to (nbd target). Is there any feature can be reused to implement it?
You can use block commit or stream to move the data.
Fam
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 7 lines · Fam Zheng
Quoted 6 lines · Wen Congyang
Quoted 5 lines · Fam Zheng
Quoted 3 lines · Wen Congyang
I test qcow2_make_empty()'s performance. The result shows that it may take about 100ms(normal sata disk). It is not acceptable for COLO. So I think disk buff is necessary(just use it to replace qcow2).
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Why not tmpfs or ramdisk?
Another problem:
After failover, secondary write request will be written in (active disk)? It is better to write request to (nbd target). Is there any feature can be reused to implement it?You can use block commit or stream to move the data.
When doing failover, we can use it to move the data. After failover, I need an endless job to move the data.
Thanks
Wen Congyang
Quoted 5 lines
Fam
.
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 15 lines · Wen Congyang
Quoted 14 lines · Fam Zheng
Quoted 12 lines · Wen Congyang
Quoted 6 lines · Fam Zheng
Quoted 3 lines · Wen Congyang
I test qcow2_make_empty()'s performance. The result shows that it may take about 100ms(normal sata disk). It is not acceptable for COLO. So I think disk buff is necessary(just use it to replace qcow2).
Why not tmpfs or ramdisk?
Another problem:
After failover, secondary write request will be written in (active disk)? It is better to write request to (nbd target). Is there any feature can be reused to implement it?
Quoted 5 lines
Quoted 1 line
You can use block commit or stream to move the data.
When doing failover, we can use it to move the data. After failover, I need an endless job to move the data.
I see what you mean. After failover, does the nbd server receive more data (i.e. do you need a buffer to stash data from the other side)? If you commit (active disk) to (nbd target), all the writes will go to a single image.
Fam
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 18 lines · Fam Zheng
Quoted 17 lines · Wen Congyang
Quoted 15 lines · Fam Zheng
Quoted 6 lines · Wen Congyang
Quoted 5 lines · Fam Zheng
Quoted 3 lines · Wen Congyang
I test qcow2_make_empty()'s performance. The result shows that it may take about 100ms(normal sata disk). It is not acceptable for COLO. So I think disk buff is necessary(just use it to replace qcow2).
Quoted 6 lines
Quoted 1 line
Why not tmpfs or ramdisk?
Another problem:
After failover, secondary write request will be written in (active disk)? It is better to write request to (nbd target). Is there any feature can be reused to implement it?You can use block commit or stream to move the data.
Quoted 7 lines
Quoted 3 lines
When doing failover, we can use it to move the data. After failover, I need an endless job to move the data.
I see what you mean. After failover, does the nbd server receive more data (i.e. do you need a buffer to stash data from the other side)? If you commit (active disk) to (nbd target), all the writes will go to a single image.
After failover(primary host downs), only secondary qemu works, and nbd server doesn't receive any more data.
Thanks
Wen Congyang
Quoted 5 lines
Fam
.
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
In reply to Fam ZhengQuoted 7 lines · Fam Zheng
Quoted 6 lines · Wen Congyang
Quoted 5 lines · Fam Zheng
Quoted 3 lines · Wen Congyang
I test qcow2_make_empty()'s performance. The result shows that it may take about 100ms(normal sata disk). It is not acceptable for COLO. So I think disk buff is necessary(just use it to replace qcow2).
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Why not tmpfs or ramdisk?
Another problem:
After failover, secondary write request will be written in (active disk)? It is better to write request to (nbd target). Is there any feature can be reused to implement it?You can use block commit or stream to move the data.
Can the job stream move the data? I don't find the write ops in block/stream.c.
Thanks
Wen Congyang
Quoted 5 lines
Fam
.
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 10 lines · Wen Congyang
Quoted 9 lines · Fam Zheng
Quoted 8 lines · Wen Congyang
Quoted 6 lines · Fam Zheng
Quoted 3 lines · Wen Congyang
I test qcow2_make_empty()'s performance. The result shows that it may take about 100ms(normal sata disk). It is not acceptable for COLO. So I think disk buff is necessary(just use it to replace qcow2).
Why not tmpfs or ramdisk?
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Another problem:
After failover, secondary write request will be written in (active disk)? It is better to write request to (nbd target). Is there any feature can be reused to implement it?You can use block commit or stream to move the data.
Can the job stream move the data? I don't find the write ops in
block/stream.c.
It is bdrv_co_copy_on_readv that moves data.
Fam
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 16 lines · Fam Zheng
Quoted 15 lines · Wen Congyang
Quoted 14 lines · Fam Zheng
Quoted 12 lines · Wen Congyang
Quoted 6 lines · Fam Zheng
Quoted 3 lines · Wen Congyang
I test qcow2_make_empty()'s performance. The result shows that it may take about 100ms(normal sata disk). It is not acceptable for COLO. So I think disk buff is necessary(just use it to replace qcow2).
Why not tmpfs or ramdisk?
Another problem:
After failover, secondary write request will be written in (active disk)? It is better to write request to (nbd target). Is there any feature can be reused to implement it?
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
You can use block commit or stream to move the data.
Can the job stream move the data? I don't find the write ops in
block/stream.c.It is
bdrv_co_copy_on_readvthat moves data.
Does the job stream move the data from base to top?
Thanks
Wen Congyang
Quoted 4 lines
Fam
.
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 17 lines · Wen Congyang
Quoted 16 lines · Fam Zheng
Quoted 15 lines · Wen Congyang
Quoted 14 lines · Fam Zheng
Quoted 12 lines · Wen Congyang
Quoted 6 lines · Fam Zheng
Quoted 3 lines · Wen Congyang
I test qcow2_make_empty()'s performance. The result shows that it may take about 100ms(normal sata disk). It is not acceptable for COLO. So I think disk buff is necessary(just use it to replace qcow2).
Why not tmpfs or ramdisk?
Another problem:
After failover, secondary write request will be written in (active disk)? It is better to write request to (nbd target). Is there any feature can be reused to implement it?
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
You can use block commit or stream to move the data.
Can the job stream move the data? I don't find the write ops in
block/stream.c.It is
bdrv_co_copy_on_readvthat moves data.Does the job stream move the data from base to top?
Yes. block-commit goes in the other direction.
Paolo
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
In reply to Fam ZhengHi Fam,
Quoted 140 lines · Fam Zheng
Quoted 42 lines · Wen Congyang
Quoted 35 lines · Fam Zheng
Hi Congyang,
Quoted 18 lines · Wen Congyang
+== Workflow ==
docs/block-replication.txt new file +17
-0+The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V |docs/block-replication.txt line 53
Quoted 10 lines
docs/block-replication.txt new file +10
-0+ +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.I'm a little confused by the tenses ("will be" versus "are") and terms. I am reading them as "s/will be/are/g"
Quoted 1 line
Why do you need this buffer?
We only sync the disk till next checkpoint. Before next checkpoint, secondary vm write to the buffer.
Quoted 1 line
Quoted 5 lines
Quoted 2 lines
If both primary and secondary write to the same sector, what is saved in the buffer?
The primary content will be written to the secondary disk, and the secondary content is saved in the buffer.
I wonder if alternatively this is possible with an imaginary "writable backing image" feature, as described below.
When we have a normal backing chain,
{virtio-blk dev 'foo'} | | | [base] <- [mid] <- (foo)Where [base] and [mid] are read only, (foo) is writable. When we add an overlay to an existing image on top,
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | | | [base] <- [mid] <- (foo) <---------------------- (bar)It's important to make sure that writes to 'foo' doesn't break data for 'bar'. We can utilize an automatic hidden drive-backup target:
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | v v [base] <- [mid] <- (foo) <----------------- (hidden target) <--------------- (bar) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>So when guest writes to 'foo', the old data is moved to (hidden target), which remains unchanged from (bar)'s PoV.
The drive in the middle is called hidden because QEMU creates it automatically, the naming is arbitrary.
It is interesting because it is a more generalized case of image fleecing, where the (hidden target) is exposed via NBD server for data scanning (read only) purpose.
More interestingly, with above facility, it is also possible to create a guest visible live snapshot (disk 'bar') of an existing device (disk 'foo') very cheaply. Or call it shadow copy if you will.
Back to the COLO case, the configuration will be very similar:
{primary wr} {secondary vm} | | | | | | v v [what] <- [ever] <- (nbd target) <------------ (hidden buf disk) <------------- (active disk) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>The workflow analogue is:
Quoted 2 lines
Quoted 2 lines
docs/block-replication.txt line 49
Quoted 2 lines
docs/block-replication.txt new file +2
-0+ 1) Primary write requests will be copied and forwarded to Secondary + QEMU.Primary write requests are forwarded to secondary QEMU as well.
Quoted 4 lines
Quoted 4 lines
docs/block-replication.txt line 53
Quoted 4 lines
docs/block-replication.txt new file +4
-0+ 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.Before Primary write requests are written to (nbd target), aka the Secondary disk, the orignal sector content is read from it and copied to (hidden buf disk) by drive-backup. It obviously will not overwrite the data in (active disk).
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ 3) Primary write requests will be written to Secondary disk.
Primary write requests are written to (nbd target).
Quoted 2 lines
Quoted 2 lines
docs/block-replication.txt line 56
Quoted 2 lines
docs/block-replication.txt new file +2
-0+ 4) Secondary write requests will be buffered in the Disk buffer and it + will overwrite the existing sector content in the buffer.
Quoted 6 lines
Secondary write request will be written in (active disk) as usual.
Finally, when checkpoint arrives, if you want to sync with primary, just drop data in (hidden buf disk) and (active disk); when failover happends, if you want to promote secondary vm, you can commit (active disk) to (nbd target), and drop data in (hidden buf disk).
If I understand correctly, you split the Disk Buffer into a hidden buf disk + an active disk. What we need to do is only to implement a buf disk(will be used as hidden buf disk and active disk as mentioned), apart from this, we can use the existing mechinism like backing-file/drive-backup?
Quoted 4 lines
Fam
.
Signature · 2 lines
Thanks, Yang.
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 150 lines · Hongyang Yang
Hi Fam,
Quoted 140 lines · Fam Zheng
Quoted 42 lines · Wen Congyang
Quoted 35 lines · Fam Zheng
Hi Congyang,
Quoted 18 lines · Wen Congyang
+== Workflow ==
docs/block-replication.txt new file +17
-0+The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V |docs/block-replication.txt line 53
Quoted 10 lines
docs/block-replication.txt new file +10
-0+ +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.I'm a little confused by the tenses ("will be" versus "are") and terms. I am reading them as "s/will be/are/g"
Quoted 1 line
Why do you need this buffer?
We only sync the disk till next checkpoint. Before next checkpoint, secondary vm write to the buffer.
Quoted 1 line
Quoted 5 lines
Quoted 2 lines
If both primary and secondary write to the same sector, what is saved in the buffer?
The primary content will be written to the secondary disk, and the secondary content is saved in the buffer.
I wonder if alternatively this is possible with an imaginary "writable backing image" feature, as described below.
When we have a normal backing chain,
{virtio-blk dev 'foo'} | | | [base] <- [mid] <- (foo)Where [base] and [mid] are read only, (foo) is writable. When we add an overlay to an existing image on top,
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | | | [base] <- [mid] <- (foo) <---------------------- (bar)It's important to make sure that writes to 'foo' doesn't break data for 'bar'. We can utilize an automatic hidden drive-backup target:
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | v v [base] <- [mid] <- (foo) <----------------- (hidden target) <--------------- (bar) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>So when guest writes to 'foo', the old data is moved to (hidden target), which remains unchanged from (bar)'s PoV.
The drive in the middle is called hidden because QEMU creates it automatically, the naming is arbitrary.
It is interesting because it is a more generalized case of image fleecing, where the (hidden target) is exposed via NBD server for data scanning (read only) purpose.
More interestingly, with above facility, it is also possible to create a guest visible live snapshot (disk 'bar') of an existing device (disk 'foo') very cheaply. Or call it shadow copy if you will.
Back to the COLO case, the configuration will be very similar:
{primary wr} {secondary vm} | | | | | | v v[what] <- [ever] <- (nbd target) <------------ (hidden buf disk) <------------- (active disk) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>The workflow analogue is:
Quoted 2 lines
Quoted 2 lines
docs/block-replication.txt line 49
Quoted 2 lines
docs/block-replication.txt new file +2
-0+ 1) Primary write requests will be copied and forwarded to Secondary + QEMU.Primary write requests are forwarded to secondary QEMU as well.
Quoted 4 lines
Quoted 4 lines
docs/block-replication.txt line 53
Quoted 4 lines
docs/block-replication.txt new file +4
-0+ 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.Before Primary write requests are written to (nbd target), aka the Secondary disk, the orignal sector content is read from it and copied to (hidden buf disk) by drive-backup. It obviously will not overwrite the data in (active disk).
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ 3) Primary write requests will be written to Secondary disk.
Primary write requests are written to (nbd target).
Quoted 2 lines
Quoted 2 lines
docs/block-replication.txt line 56
Quoted 2 lines
docs/block-replication.txt new file +2
-0+ 4) Secondary write requests will be buffered in the Disk buffer and it + will overwrite the existing sector content in the buffer.Quoted 6 lines
Secondary write request will be written in (active disk) as usual.
Finally, when checkpoint arrives, if you want to sync with primary, just drop data in (hidden buf disk) and (active disk); when failover happends, if you want to promote secondary vm, you can commit (active disk) to (nbd target), and drop data in (hidden buf disk).
Quoted 5 lines
If I understand correctly, you split the Disk Buffer into a hidden buf disk + an active disk. What we need to do is only to implement a buf disk(will be used as hidden buf disk and active disk as mentioned), apart from this, we can use the existing mechinism like backing-file/drive-backup?
Yes, but you need a separate driver to take care of the buffer logic as introduced in this series, which is less generic, but does the same thing we will need in the image fleecing use case.
Fam
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
In reply to Fam ZhengQuoted 85 lines · Fam Zheng
Quoted 42 lines · Wen Congyang
Quoted 35 lines · Fam Zheng
Hi Congyang,
Quoted 18 lines · Wen Congyang
+== Workflow ==
docs/block-replication.txt new file +17
-0+The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V |docs/block-replication.txt line 53
Quoted 10 lines
docs/block-replication.txt new file +10
-0+ +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.I'm a little confused by the tenses ("will be" versus "are") and terms. I am reading them as "s/will be/are/g"
Quoted 1 line
Why do you need this buffer?
We only sync the disk till next checkpoint. Before next checkpoint, secondary vm write to the buffer.
Quoted 1 line
Quoted 5 lines
Quoted 2 lines
If both primary and secondary write to the same sector, what is saved in the buffer?
The primary content will be written to the secondary disk, and the secondary content is saved in the buffer.
I wonder if alternatively this is possible with an imaginary "writable backing image" feature, as described below.
When we have a normal backing chain,
{virtio-blk dev 'foo'} | | | [base] <- [mid] <- (foo)Where [base] and [mid] are read only, (foo) is writable. When we add an overlay to an existing image on top,
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | | | [base] <- [mid] <- (foo) <---------------------- (bar)It's important to make sure that writes to 'foo' doesn't break data for 'bar'. We can utilize an automatic hidden drive-backup target:
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | v v [base] <- [mid] <- (foo) <----------------- (hidden target) <--------------- (bar) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>
Quoted 5 lines
So when guest writes to 'foo', the old data is moved to (hidden target), which remains unchanged from (bar)'s PoV.
The drive in the middle is called hidden because QEMU creates it automatically, the naming is arbitrary.
I don't understand this. In which function, the hidden target is created automatically?
Thanks
Wen Congyang
Quoted 60 lines
It is interesting because it is a more generalized case of image fleecing, where the (hidden target) is exposed via NBD server for data scanning (read only) purpose.
More interestingly, with above facility, it is also possible to create a guest visible live snapshot (disk 'bar') of an existing device (disk 'foo') very cheaply. Or call it shadow copy if you will.
Back to the COLO case, the configuration will be very similar:
{primary wr} {secondary vm} | | | | | | v v[what] <- [ever] <- (nbd target) <------------ (hidden buf disk) <------------- (active disk) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>The workflow analogue is:
Quoted 2 lines
Quoted 2 lines
docs/block-replication.txt line 49
Quoted 2 lines
docs/block-replication.txt new file +2
-0+ 1) Primary write requests will be copied and forwarded to Secondary + QEMU.Primary write requests are forwarded to secondary QEMU as well.
Quoted 4 lines
Quoted 4 lines
docs/block-replication.txt line 53
Quoted 4 lines
docs/block-replication.txt new file +4
-0+ 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.Before Primary write requests are written to (nbd target), aka the Secondary disk, the orignal sector content is read from it and copied to (hidden buf disk) by drive-backup. It obviously will not overwrite the data in (active disk).
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ 3) Primary write requests will be written to Secondary disk.
Primary write requests are written to (nbd target).
Quoted 2 lines
Quoted 2 lines
docs/block-replication.txt line 56
Quoted 2 lines
docs/block-replication.txt new file +2
-0+ 4) Secondary write requests will be buffered in the Disk buffer and it + will overwrite the existing sector content in the buffer.Secondary write request will be written in (active disk) as usual.
Finally, when checkpoint arrives, if you want to sync with primary, just drop data in (hidden buf disk) and (active disk); when failover happends, if you want to promote secondary vm, you can commit (active disk) to (nbd target), and drop data in (hidden buf disk).
Fam
.
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 86 lines · Wen Congyang
Quoted 85 lines · Fam Zheng
Quoted 42 lines · Wen Congyang
Quoted 35 lines · Fam Zheng
Hi Congyang,
Quoted 18 lines · Wen Congyang
+== Workflow ==
docs/block-replication.txt new file +17
-0+The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V |docs/block-replication.txt line 53
Quoted 10 lines
docs/block-replication.txt new file +10
-0+ +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.I'm a little confused by the tenses ("will be" versus "are") and terms. I am reading them as "s/will be/are/g"
Quoted 1 line
Why do you need this buffer?
We only sync the disk till next checkpoint. Before next checkpoint, secondary vm write to the buffer.
Quoted 1 line
Quoted 5 lines
Quoted 2 lines
If both primary and secondary write to the same sector, what is saved in the buffer?
The primary content will be written to the secondary disk, and the secondary content is saved in the buffer.
I wonder if alternatively this is possible with an imaginary "writable backing image" feature, as described below.
When we have a normal backing chain,
{virtio-blk dev 'foo'} | | | [base] <- [mid] <- (foo)Where [base] and [mid] are read only, (foo) is writable. When we add an overlay to an existing image on top,
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | | | [base] <- [mid] <- (foo) <---------------------- (bar)It's important to make sure that writes to 'foo' doesn't break data for 'bar'. We can utilize an automatic hidden drive-backup target:
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | v v [base] <- [mid] <- (foo) <----------------- (hidden target) <--------------- (bar) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>
Quoted 8 lines
Quoted 5 lines
So when guest writes to 'foo', the old data is moved to (hidden target), which remains unchanged from (bar)'s PoV.
The drive in the middle is called hidden because QEMU creates it automatically, the naming is arbitrary.
I don't understand this. In which function, the hidden target is created automatically?
It's to be determined. This part is only in my mind :)
Fam
Quoted 62 lines
Quoted 61 lines
It is interesting because it is a more generalized case of image fleecing, where the (hidden target) is exposed via NBD server for data scanning (read only) purpose.
More interestingly, with above facility, it is also possible to create a guest visible live snapshot (disk 'bar') of an existing device (disk 'foo') very cheaply. Or call it shadow copy if you will.
Back to the COLO case, the configuration will be very similar:
{primary wr} {secondary vm} | | | | | | v v[what] <- [ever] <- (nbd target) <------------ (hidden buf disk) <------------- (active disk) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>The workflow analogue is:
Quoted 2 lines
Quoted 2 lines
docs/block-replication.txt line 49
Quoted 2 lines
docs/block-replication.txt new file +2
-0+ 1) Primary write requests will be copied and forwarded to Secondary + QEMU.Primary write requests are forwarded to secondary QEMU as well.
Quoted 4 lines
Quoted 4 lines
docs/block-replication.txt line 53
Quoted 4 lines
docs/block-replication.txt new file +4
-0+ 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.Before Primary write requests are written to (nbd target), aka the Secondary disk, the orignal sector content is read from it and copied to (hidden buf disk) by drive-backup. It obviously will not overwrite the data in (active disk).
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ 3) Primary write requests will be written to Secondary disk.
Primary write requests are written to (nbd target).
Quoted 2 lines
Quoted 2 lines
docs/block-replication.txt line 56
Quoted 2 lines
docs/block-replication.txt new file +2
-0+ 4) Secondary write requests will be buffered in the Disk buffer and it + will overwrite the existing sector content in the buffer.Secondary write request will be written in (active disk) as usual.
Finally, when checkpoint arrives, if you want to sync with primary, just drop data in (hidden buf disk) and (active disk); when failover happends, if you want to promote secondary vm, you can commit (active disk) to (nbd target), and drop data in (hidden buf disk).
Fam
.
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 90 lines · Fam Zheng
Quoted 89 lines · Wen Congyang
Quoted 88 lines · Fam Zheng
Quoted 42 lines · Wen Congyang
Quoted 35 lines · Fam Zheng
Hi Congyang,
Quoted 18 lines · Wen Congyang
+== Workflow ==
docs/block-replication.txt new file +17
-0+The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V |docs/block-replication.txt line 53
Quoted 10 lines
docs/block-replication.txt new file +10
-0+ +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.I'm a little confused by the tenses ("will be" versus "are") and terms. I am reading them as "s/will be/are/g"
Quoted 1 line
Why do you need this buffer?
We only sync the disk till next checkpoint. Before next checkpoint, secondary vm write to the buffer.
Quoted 1 line
Quoted 5 lines
Quoted 2 lines
If both primary and secondary write to the same sector, what is saved in the buffer?
The primary content will be written to the secondary disk, and the secondary content is saved in the buffer.
I wonder if alternatively this is possible with an imaginary "writable backing image" feature, as described below.
When we have a normal backing chain,
{virtio-blk dev 'foo'} | | | [base] <- [mid] <- (foo)Where [base] and [mid] are read only, (foo) is writable. When we add an overlay to an existing image on top,
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | | | [base] <- [mid] <- (foo) <---------------------- (bar)It's important to make sure that writes to 'foo' doesn't break data for 'bar'. We can utilize an automatic hidden drive-backup target:
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | v v [base] <- [mid] <- (foo) <----------------- (hidden target) <--------------- (bar) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>So when guest writes to 'foo', the old data is moved to (hidden target), which remains unchanged from (bar)'s PoV.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
The drive in the middle is called hidden because QEMU creates it automatically, the naming is arbitrary.
I don't understand this. In which function, the hidden target is created automatically?
It's to be determined. This part is only in my mind :)
Does hidden target is only used for COLO?
Thanks
Wen Congyang
Quoted 67 lines
Fam
Quoted 53 lines
Quoted 53 lines
It is interesting because it is a more generalized case of image fleecing, where the (hidden target) is exposed via NBD server for data scanning (read only) purpose.
More interestingly, with above facility, it is also possible to create a guest visible live snapshot (disk 'bar') of an existing device (disk 'foo') very cheaply. Or call it shadow copy if you will.
Back to the COLO case, the configuration will be very similar:
{primary wr} {secondary vm} | | | | | | v v[what] <- [ever] <- (nbd target) <------------ (hidden buf disk) <------------- (active disk) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>The workflow analogue is:
Quoted 2 lines
Quoted 2 lines
docs/block-replication.txt line 49
Quoted 2 lines
docs/block-replication.txt new file +2
-0+ 1) Primary write requests will be copied and forwarded to Secondary + QEMU.Primary write requests are forwarded to secondary QEMU as well.
Quoted 4 lines
Quoted 4 lines
docs/block-replication.txt line 53
Quoted 4 lines
docs/block-replication.txt new file +4
-0+ 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.Before Primary write requests are written to (nbd target), aka the Secondary disk, the orignal sector content is read from it and copied to (hidden buf disk) by drive-backup. It obviously will not overwrite the data in (active disk).
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ 3) Primary write requests will be written to Secondary disk.
Primary write requests are written to (nbd target).
Quoted 2 lines
Quoted 2 lines
docs/block-replication.txt line 56
Quoted 2 lines
docs/block-replication.txt new file +2
-0+ 4) Secondary write requests will be buffered in the Disk buffer and it + will overwrite the existing sector content in the buffer.Secondary write request will be written in (active disk) as usual.
Quoted 9 lines
Quoted 8 lines
Finally, when checkpoint arrives, if you want to sync with primary, just drop data in (hidden buf disk) and (active disk); when failover happends, if you want to promote secondary vm, you can commit (active disk) to (nbd target), and drop data in (hidden buf disk).
Fam
..
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 94 lines · Wen Congyang
Quoted 93 lines · Fam Zheng
Quoted 92 lines · Wen Congyang
Quoted 90 lines · Fam Zheng
Quoted 42 lines · Wen Congyang
Quoted 35 lines · Fam Zheng
Hi Congyang,
Quoted 18 lines · Wen Congyang
+== Workflow ==
(quoted diff) +17
-0+The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V |Review
Quoted 10 lines
(quoted diff) +10
-0+ +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.I'm a little confused by the tenses ("will be" versus "are") and terms. I am reading them as "s/will be/are/g"
Quoted 1 line
Why do you need this buffer?
We only sync the disk till next checkpoint. Before next checkpoint, secondary vm write to the buffer.
Quoted 1 line
Quoted 5 lines
Quoted 2 lines
If both primary and secondary write to the same sector, what is saved in the buffer?
The primary content will be written to the secondary disk, and the secondary content is saved in the buffer.
I wonder if alternatively this is possible with an imaginary "writable backing image" feature, as described below.
When we have a normal backing chain,
{virtio-blk dev 'foo'} | | | [base] <- [mid] <- (foo)Where [base] and [mid] are read only, (foo) is writable. When we add an overlay to an existing image on top,
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | | | [base] <- [mid] <- (foo) <---------------------- (bar)It's important to make sure that writes to 'foo' doesn't break data for 'bar'. We can utilize an automatic hidden drive-backup target:
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | v v [base] <- [mid] <- (foo) <----------------- (hidden target) <--------------- (bar) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>So when guest writes to 'foo', the old data is moved to (hidden target), which remains unchanged from (bar)'s PoV.
The drive in the middle is called hidden because QEMU creates it automatically, the naming is arbitrary.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
I don't understand this. In which function, the hidden target is created automatically?
It's to be determined. This part is only in my mind :)
Does hidden target is only used for COLO?
I'm not sure I get your question.
In this case yes, this is a dedicate target that's only written to by COLO's secondary VM.
In other general cases, this infrastructure could also be used for backup or image fleecing.
Fam
Quoted 70 lines
Quoted 68 lines
Fam
Quoted 53 lines
Quoted 53 lines
It is interesting because it is a more generalized case of image fleecing, where the (hidden target) is exposed via NBD server for data scanning (read only) purpose.
More interestingly, with above facility, it is also possible to create a guest visible live snapshot (disk 'bar') of an existing device (disk 'foo') very cheaply. Or call it shadow copy if you will.
Back to the COLO case, the configuration will be very similar:
{primary wr} {secondary vm} | | | | | | v v[what] <- [ever] <- (nbd target) <------------ (hidden buf disk) <------------- (active disk) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>The workflow analogue is:
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ 1) Primary write requests will be copied and forwarded to Secondary + QEMU.Primary write requests are forwarded to secondary QEMU as well.
Quoted 4 lines
Quoted 4 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.Before Primary write requests are written to (nbd target), aka the Secondary disk, the orignal sector content is read from it and copied to (hidden buf disk) by drive-backup. It obviously will not overwrite the data in (active disk).
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ 3) Primary write requests will be written to Secondary disk.
Primary write requests are written to (nbd target).
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ 4) Secondary write requests will be buffered in the Disk buffer and it + will overwrite the existing sector content in the buffer.Secondary write request will be written in (active disk) as usual.
Quoted 9 lines
Quoted 8 lines
Finally, when checkpoint arrives, if you want to sync with primary, just drop data in (hidden buf disk) and (active disk); when failover happends, if you want to promote secondary vm, you can commit (active disk) to (nbd target), and drop data in (hidden buf disk).
Fam
..
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 103 lines · Fam Zheng
Quoted 94 lines · Wen Congyang
Quoted 93 lines · Fam Zheng
Quoted 92 lines · Wen Congyang
Quoted 90 lines · Fam Zheng
Quoted 42 lines · Wen Congyang
Quoted 35 lines · Fam Zheng
Hi Congyang,
Quoted 18 lines · Wen Congyang
+== Workflow ==
(quoted diff) +17
-0+The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V |Review
Quoted 10 lines
(quoted diff) +10
-0+ +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.I'm a little confused by the tenses ("will be" versus "are") and terms. I am reading them as "s/will be/are/g"
Quoted 1 line
Why do you need this buffer?
We only sync the disk till next checkpoint. Before next checkpoint, secondary vm write to the buffer.
Quoted 1 line
Quoted 5 lines
Quoted 2 lines
If both primary and secondary write to the same sector, what is saved in the buffer?
The primary content will be written to the secondary disk, and the secondary content is saved in the buffer.
I wonder if alternatively this is possible with an imaginary "writable backing image" feature, as described below.
When we have a normal backing chain,
{virtio-blk dev 'foo'} | | | [base] <- [mid] <- (foo)Where [base] and [mid] are read only, (foo) is writable. When we add an overlay to an existing image on top,
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | | | [base] <- [mid] <- (foo) <---------------------- (bar)It's important to make sure that writes to 'foo' doesn't break data for 'bar'. We can utilize an automatic hidden drive-backup target:
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | v v [base] <- [mid] <- (foo) <----------------- (hidden target) <--------------- (bar) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>So when guest writes to 'foo', the old data is moved to (hidden target), which remains unchanged from (bar)'s PoV.
The drive in the middle is called hidden because QEMU creates it automatically, the naming is arbitrary.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
I don't understand this. In which function, the hidden target is created automatically?
It's to be determined. This part is only in my mind :)
Does hidden target is only used for COLO?
Quoted 7 lines
I'm not sure I get your question.
In this case yes, this is a dedicate target that's only written to by COLO's secondary VM.
In other general cases, this infrastructure could also be used for backup or image fleecing.
In COLO case, we can create (hidden buf disk) when starting block replication. In other general cases, I don't know when to create (hidden buf disk)?
Thanks
Wen Congyang
Quoted 75 lines
Fam
Quoted 62 lines
Quoted 62 lines
Fam
Quoted 58 lines
Quoted 58 lines
It is interesting because it is a more generalized case of image fleecing, where the (hidden target) is exposed via NBD server for data scanning (read only) purpose.
More interestingly, with above facility, it is also possible to create a guest visible live snapshot (disk 'bar') of an existing device (disk 'foo') very cheaply. Or call it shadow copy if you will.
Back to the COLO case, the configuration will be very similar:
{primary wr} {secondary vm} | | | | | | v v[what] <- [ever] <- (nbd target) <------------ (hidden buf disk) <------------- (active disk) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>The workflow analogue is:
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ 1) Primary write requests will be copied and forwarded to Secondary + QEMU.Primary write requests are forwarded to secondary QEMU as well.
Quoted 4 lines
Quoted 4 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.Before Primary write requests are written to (nbd target), aka the Secondary disk, the orignal sector content is read from it and copied to (hidden buf disk) by drive-backup. It obviously will not overwrite the data in (active disk).
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ 3) Primary write requests will be written to Secondary disk.
Primary write requests are written to (nbd target).
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ 4) Secondary write requests will be buffered in the Disk buffer and it + will overwrite the existing sector content in the buffer.Secondary write request will be written in (active disk) as usual.
Finally, when checkpoint arrives, if you want to sync with primary, just drop data in (hidden buf disk) and (active disk); when failover happends, if you want to promote secondary vm, you can commit (active disk) to (nbd target), and drop data in (hidden buf disk).
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines
Fam
..
.
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
In reply to Fam ZhengQuoted 90 lines · Fam Zheng
Quoted 89 lines · Wen Congyang
Quoted 88 lines · Fam Zheng
Quoted 42 lines · Wen Congyang
Quoted 35 lines · Fam Zheng
Hi Congyang,
Quoted 18 lines · Wen Congyang
+== Workflow ==
docs/block-replication.txt new file +17
-0+The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V |docs/block-replication.txt line 53
Quoted 10 lines
docs/block-replication.txt new file +10
-0+ +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.I'm a little confused by the tenses ("will be" versus "are") and terms. I am reading them as "s/will be/are/g"
Quoted 1 line
Why do you need this buffer?
We only sync the disk till next checkpoint. Before next checkpoint, secondary vm write to the buffer.
Quoted 1 line
Quoted 5 lines
Quoted 2 lines
If both primary and secondary write to the same sector, what is saved in the buffer?
The primary content will be written to the secondary disk, and the secondary content is saved in the buffer.
I wonder if alternatively this is possible with an imaginary "writable backing image" feature, as described below.
When we have a normal backing chain,
{virtio-blk dev 'foo'} | | | [base] <- [mid] <- (foo)Where [base] and [mid] are read only, (foo) is writable. When we add an overlay to an existing image on top,
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | | | [base] <- [mid] <- (foo) <---------------------- (bar)It's important to make sure that writes to 'foo' doesn't break data for 'bar'. We can utilize an automatic hidden drive-backup target:
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | v v [base] <- [mid] <- (foo) <----------------- (hidden target) <--------------- (bar) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>So when guest writes to 'foo', the old data is moved to (hidden target), which remains unchanged from (bar)'s PoV.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
The drive in the middle is called hidden because QEMU creates it automatically, the naming is arbitrary.
I don't understand this. In which function, the hidden target is created automatically?
It's to be determined. This part is only in my mind :)
What about this:
-drive file=nbd-target,if=none,id=nbd-target0 \
-drive file=active-disk,if=virtio,driver=qcow2,backing.file.filename=hidden-disk,backing.driver=qcow2,backing.backing=nbd-target0
Thanks
Wen Congyang
Quoted 3 lines
Fam
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 101 lines · Wen Congyang
Quoted 90 lines · Fam Zheng
Quoted 89 lines · Wen Congyang
Quoted 88 lines · Fam Zheng
Quoted 42 lines · Wen Congyang
Quoted 35 lines · Fam Zheng
Hi Congyang,
Quoted 18 lines · Wen Congyang
+== Workflow ==
(quoted diff) +17
-0+The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V |Review
Quoted 10 lines
(quoted diff) +10
-0+ +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.I'm a little confused by the tenses ("will be" versus "are") and terms. I am reading them as "s/will be/are/g"
Quoted 1 line
Why do you need this buffer?
We only sync the disk till next checkpoint. Before next checkpoint, secondary vm write to the buffer.
Quoted 1 line
Quoted 5 lines
Quoted 2 lines
If both primary and secondary write to the same sector, what is saved in the buffer?
The primary content will be written to the secondary disk, and the secondary content is saved in the buffer.
I wonder if alternatively this is possible with an imaginary "writable backing image" feature, as described below.
When we have a normal backing chain,
{virtio-blk dev 'foo'} | | | [base] <- [mid] <- (foo)Where [base] and [mid] are read only, (foo) is writable. When we add an overlay to an existing image on top,
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | | | [base] <- [mid] <- (foo) <---------------------- (bar)It's important to make sure that writes to 'foo' doesn't break data for 'bar'. We can utilize an automatic hidden drive-backup target:
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | v v [base] <- [mid] <- (foo) <----------------- (hidden target) <--------------- (bar) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>So when guest writes to 'foo', the old data is moved to (hidden target), which remains unchanged from (bar)'s PoV.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
The drive in the middle is called hidden because QEMU creates it automatically, the naming is arbitrary.
I don't understand this. In which function, the hidden target is created automatically?
It's to be determined. This part is only in my mind :)
What about this:
Review
Quoted 2 lines
(quoted diff) +0
-2-drive file=nbd-target,if=none,id=nbd-target0 \ -drive file=active-disk,if=virtio,driver=qcow2,backing.file.filename=hidden-disk,backing.driver=qcow2,backing.backing=nbd-target0
It's close. I suppose backing.backing is referencing another drive as its backing_hd, then you cannot have the other backing.file.* option - they conflict. It would be something along:
-drive file=nbd-target,if=none,id=nbd-target0 \
-drive file=hidden-disk,if=none,id=hidden0,backing.backing=nbd-target0 \
-drive file=active-disk,if=virtio,driver=qcow2,backing.backing=hidden0
Or for simplicity, s/backing.backing=/backing=/g
Yes, adding these "backing=$drive_id" option is also exactly what we expect in order to support image-fleecing, but we haven't figured how to allow that without breaking other qmp operations like block jobs, etc.
Fam
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 113 lines · Fam Zheng
Quoted 101 lines · Wen Congyang
Quoted 90 lines · Fam Zheng
Quoted 89 lines · Wen Congyang
Quoted 88 lines · Fam Zheng
Quoted 42 lines · Wen Congyang
Quoted 35 lines · Fam Zheng
Hi Congyang,
Quoted 18 lines · Wen Congyang
+== Workflow ==
(quoted diff) +17
-0+The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V |Review
Quoted 10 lines
(quoted diff) +10
-0+ +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.I'm a little confused by the tenses ("will be" versus "are") and terms. I am reading them as "s/will be/are/g"
Quoted 1 line
Why do you need this buffer?
We only sync the disk till next checkpoint. Before next checkpoint, secondary vm write to the buffer.
Quoted 1 line
Quoted 5 lines
Quoted 2 lines
If both primary and secondary write to the same sector, what is saved in the buffer?
The primary content will be written to the secondary disk, and the secondary content is saved in the buffer.
I wonder if alternatively this is possible with an imaginary "writable backing image" feature, as described below.
When we have a normal backing chain,
{virtio-blk dev 'foo'} | | | [base] <- [mid] <- (foo)Where [base] and [mid] are read only, (foo) is writable. When we add an overlay to an existing image on top,
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | | | [base] <- [mid] <- (foo) <---------------------- (bar)It's important to make sure that writes to 'foo' doesn't break data for 'bar'. We can utilize an automatic hidden drive-backup target:
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | v v [base] <- [mid] <- (foo) <----------------- (hidden target) <--------------- (bar) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>So when guest writes to 'foo', the old data is moved to (hidden target), which remains unchanged from (bar)'s PoV.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
The drive in the middle is called hidden because QEMU creates it automatically, the naming is arbitrary.
I don't understand this. In which function, the hidden target is created automatically?
It's to be determined. This part is only in my mind :)
What about this:
Review
Quoted 2 lines
(quoted diff) +0
-2-drive file=nbd-target,if=none,id=nbd-target0 \ -drive file=active-disk,if=virtio,driver=qcow2,backing.file.filename=hidden-disk,backing.driver=qcow2,backing.backing=nbd-target0It's close. I suppose backing.backing is referencing another drive as its
backing_hd, then you cannot have the other backing.file.* option - they conflict. It would be something along:(quoted diff) +0
-3-drive file=nbd-target,if=none,id=nbd-target0 \ -drive file=hidden-disk,if=none,id=hidden0,backing.backing=nbd-target0 \ -drive file=active-disk,if=virtio,driver=qcow2,backing.backing=hidden0
Quoted 1 line
Or for simplicity, s/backing.backing=/backing=/g
If using backing=drive_id, backing.backing and backing.file.* are not conflict. backing.backing=$drive_id means that: backing file's backing file's id is $drive_id.
Quoted 4 lines
Yes, adding these "backing=$drive_id" option is also exactly what we expect in order to support image-fleecing, but we haven't figured how to allow that without breaking other qmp operations like block jobs, etc.
I don't understand this. In which case, qmp operations will be broken? Can you give me some examples?
Thanks
Wen Congyang
Quoted 4 lines
Fam
.
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 110 lines · Wen Congyang
Quoted 109 lines · Fam Zheng
Quoted 101 lines · Wen Congyang
Quoted 90 lines · Fam Zheng
Quoted 89 lines · Wen Congyang
Quoted 88 lines · Fam Zheng
Quoted 42 lines · Wen Congyang
Quoted 35 lines · Fam Zheng
Hi Congyang,
Quoted 18 lines · Wen Congyang
+== Workflow ==
(quoted diff) +17
-0+The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V |Review
Quoted 10 lines
(quoted diff) +10
-0+ +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.I'm a little confused by the tenses ("will be" versus "are") and terms. I am reading them as "s/will be/are/g"
Quoted 1 line
Why do you need this buffer?
We only sync the disk till next checkpoint. Before next checkpoint, secondary vm write to the buffer.
Quoted 1 line
Quoted 5 lines
Quoted 2 lines
If both primary and secondary write to the same sector, what is saved in the buffer?
The primary content will be written to the secondary disk, and the secondary content is saved in the buffer.
I wonder if alternatively this is possible with an imaginary "writable backing image" feature, as described below.
When we have a normal backing chain,
{virtio-blk dev 'foo'} | | | [base] <- [mid] <- (foo)Where [base] and [mid] are read only, (foo) is writable. When we add an overlay to an existing image on top,
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | | | [base] <- [mid] <- (foo) <---------------------- (bar)It's important to make sure that writes to 'foo' doesn't break data for 'bar'. We can utilize an automatic hidden drive-backup target:
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | v v [base] <- [mid] <- (foo) <----------------- (hidden target) <--------------- (bar) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>So when guest writes to 'foo', the old data is moved to (hidden target), which remains unchanged from (bar)'s PoV.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
The drive in the middle is called hidden because QEMU creates it automatically, the naming is arbitrary.
I don't understand this. In which function, the hidden target is created automatically?
It's to be determined. This part is only in my mind :)
What about this:
Review
Quoted 2 lines
(quoted diff) +0
-2-drive file=nbd-target,if=none,id=nbd-target0 \ -drive file=active-disk,if=virtio,driver=qcow2,backing.file.filename=hidden-disk,backing.driver=qcow2,backing.backing=nbd-target0It's close. I suppose backing.backing is referencing another drive as its
backing_hd, then you cannot have the other backing.file.* option - they conflict. It would be something along:
Quoted 8 lines
Quoted 5 lines
(quoted diff) +0
-3-drive file=nbd-target,if=none,id=nbd-target0 \ -drive file=hidden-disk,if=none,id=hidden0,backing.backing=nbd-target0 \ -drive file=active-disk,if=virtio,driver=qcow2,backing.backing=hidden0Or for simplicity, s/backing.backing=/backing=/g
If using backing=drive_id, backing.backing and backing.file.* are not conflict. backing.backing=$drive_id means that: backing file's backing file's id is $drive_id.
I see.
Quoted 9 lines
Quoted 5 lines
Yes, adding these "backing=$drive_id" option is also exactly what we expect in order to support image-fleecing, but we haven't figured how to allow that without breaking other qmp operations like block jobs, etc.
I don't understand this. In which case, qmp operations will be broken? Can you give me some examples?
I don't mean there is a fundamental stopper for this, but in order to relax the assumption that "only top BDS can have a BlockBackend", we need to think through the whole block layer, and add new finer checks/restrictions where it's necessary, otherwise it will be a mess to allow arbitrary backing reference.
Some random questions I'm now aware of:
1. nbd-target0 is writable here, without the drive-backup, hidden0 could be corrupted by writings to it. So there need to be a new convention and invariance to follow.
2. in qmp, block-commit hidden0 to nbd-target0 or it's backing file, will corrupt data (from nbd-target0's perspective).
3. unclear implications of "change" and "eject" when there is backing reference.
4. can a drive be backing referenced by more than one other drives?
Just two cents, and I still need to think about it systematically.
Fam
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 137 lines · Fam Zheng
Quoted 110 lines · Wen Congyang
Quoted 109 lines · Fam Zheng
Quoted 101 lines · Wen Congyang
Quoted 90 lines · Fam Zheng
Quoted 89 lines · Wen Congyang
Quoted 88 lines · Fam Zheng
Quoted 42 lines · Wen Congyang
Quoted 35 lines · Fam Zheng
Hi Congyang,
Quoted 18 lines · Wen Congyang
+== Workflow ==
(quoted diff) +17
-0+The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V |Review
Quoted 10 lines
(quoted diff) +10
-0+ +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.I'm a little confused by the tenses ("will be" versus "are") and terms. I am reading them as "s/will be/are/g"
Quoted 1 line
Why do you need this buffer?
We only sync the disk till next checkpoint. Before next checkpoint, secondary vm write to the buffer.
Quoted 1 line
Quoted 5 lines
Quoted 2 lines
If both primary and secondary write to the same sector, what is saved in the buffer?
The primary content will be written to the secondary disk, and the secondary content is saved in the buffer.
I wonder if alternatively this is possible with an imaginary "writable backing image" feature, as described below.
When we have a normal backing chain,
{virtio-blk dev 'foo'} | | | [base] <- [mid] <- (foo)Where [base] and [mid] are read only, (foo) is writable. When we add an overlay to an existing image on top,
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | | | [base] <- [mid] <- (foo) <---------------------- (bar)It's important to make sure that writes to 'foo' doesn't break data for 'bar'. We can utilize an automatic hidden drive-backup target:
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | v v [base] <- [mid] <- (foo) <----------------- (hidden target) <--------------- (bar) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>So when guest writes to 'foo', the old data is moved to (hidden target), which remains unchanged from (bar)'s PoV.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
The drive in the middle is called hidden because QEMU creates it automatically, the naming is arbitrary.
I don't understand this. In which function, the hidden target is created automatically?
It's to be determined. This part is only in my mind :)
What about this:
Review
Quoted 2 lines
(quoted diff) +0
-2-drive file=nbd-target,if=none,id=nbd-target0 \ -drive file=active-disk,if=virtio,driver=qcow2,backing.file.filename=hidden-disk,backing.driver=qcow2,backing.backing=nbd-target0It's close. I suppose backing.backing is referencing another drive as its
backing_hd, then you cannot have the other backing.file.* option - they conflict. It would be something along:Quoted 8 lines
Quoted 5 lines
(quoted diff) +0
-3-drive file=nbd-target,if=none,id=nbd-target0 \ -drive file=hidden-disk,if=none,id=hidden0,backing.backing=nbd-target0 \ -drive file=active-disk,if=virtio,driver=qcow2,backing.backing=hidden0Or for simplicity, s/backing.backing=/backing=/g
If using backing=drive_id, backing.backing and backing.file.* are not conflict. backing.backing=$drive_id means that: backing file's backing file's id is $drive_id.
I see.
Quoted 9 lines
Quoted 5 lines
Yes, adding these "backing=$drive_id" option is also exactly what we expect in order to support image-fleecing, but we haven't figured how to allow that without breaking other qmp operations like block jobs, etc.
I don't understand this. In which case, qmp operations will be broken? Can you give me some examples?
I don't mean there is a fundamental stopper for this, but in order to relax the assumption that "only top BDS can have a BlockBackend", we need to think through the whole block layer, and add new finer checks/restrictions where it's necessary, otherwise it will be a mess to allow arbitrary backing reference.
Quoted 5 lines
Some random questions I'm now aware of:
1. nbd-target0 is writable here, without the drive-backup, hidden0 could be corrupted by writings to it. So there need to be a new convention and invariance to follow.
Hmm, I understand while the hidden-disk should be opened automatically now. If we use backing reference, I think we should open a hindden-disk, and set drive backup automatically. Block any conflict operations(commit, change, eject?)
Quoted 8 lines
2. in qmp, block-commit hidden0 to nbd-target0 or it's backing file, will corrupt data (from nbd-target0's perspective).
3. unclear implications of "change" and "eject" when there is backing reference.
4. can a drive be backing referenced by more than one other drives?
We can forbid it first.
Thanks
Wen Congyang
Quoted 6 lines
Just two cents, and I still need to think about it systematically.
Fam
.
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 7 lines · Wen Congyang
Quoted 3 lines
1. nbd-target0 is writable here, without the drive-backup, hidden0 could be corrupted by writings to it. So there need to be a new convention and invariance to follow.
Hmm, I understand while the hidden-disk should be opened automatically now. If we use backing reference, I think we should open a hindden-disk, and set drive backup automatically. Block any conflict
operations(commit, change, eject?)
This might be a good idea.
Quoted 5 lines
Quoted 5 lines
2. in qmp, block-commit hidden0 to nbd-target0 or it's backing file, will corrupt data (from nbd-target0's perspective).
Quoted 7 lines
Quoted 4 lines
3. unclear implications of "change" and "eject" when there is backing reference.
4. can a drive be backing referenced by more than one other drives?
We can forbid it first.
Yes, probably with a new op blocker type.
Fam
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
In reply to Fam ZhengQuoted 52 lines · Fam Zheng
Quoted 42 lines · Wen Congyang
Quoted 35 lines · Fam Zheng
Hi Congyang,
Quoted 18 lines · Wen Congyang
+== Workflow ==
docs/block-replication.txt new file +17
-0+The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V |docs/block-replication.txt line 53
Quoted 10 lines
docs/block-replication.txt new file +10
-0+ +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.I'm a little confused by the tenses ("will be" versus "are") and terms. I am reading them as "s/will be/are/g"
Quoted 1 line
Why do you need this buffer?
We only sync the disk till next checkpoint. Before next checkpoint, secondary vm write to the buffer.
Quoted 1 line
Quoted 5 lines
Quoted 2 lines
If both primary and secondary write to the same sector, what is saved in the buffer?
The primary content will be written to the secondary disk, and the secondary content is saved in the buffer.
I wonder if alternatively this is possible with an imaginary "writable backing image" feature, as described below.
Quoted 7 lines
When we have a normal backing chain,
{virtio-blk dev 'foo'} | | | [base] <- [mid] <- (foo)
foo's backing is mid, and mid's backing is base?
The foo is a base's snapshot?
Thanks
Wen Congyang
Quoted 91 lines
Where [base] and [mid] are read only, (foo) is writable. When we add an overlay to an existing image on top,
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | | | [base] <- [mid] <- (foo) <---------------------- (bar)It's important to make sure that writes to 'foo' doesn't break data for 'bar'. We can utilize an automatic hidden drive-backup target:
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | v v [base] <- [mid] <- (foo) <----------------- (hidden target) <--------------- (bar) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>So when guest writes to 'foo', the old data is moved to (hidden target), which remains unchanged from (bar)'s PoV.
The drive in the middle is called hidden because QEMU creates it automatically, the naming is arbitrary.
It is interesting because it is a more generalized case of image fleecing, where the (hidden target) is exposed via NBD server for data scanning (read only) purpose.
More interestingly, with above facility, it is also possible to create a guest visible live snapshot (disk 'bar') of an existing device (disk 'foo') very cheaply. Or call it shadow copy if you will.
Back to the COLO case, the configuration will be very similar:
{primary wr} {secondary vm} | | | | | | v v[what] <- [ever] <- (nbd target) <------------ (hidden buf disk) <------------- (active disk) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>The workflow analogue is:
Quoted 2 lines
Quoted 2 lines
docs/block-replication.txt line 49
Quoted 2 lines
docs/block-replication.txt new file +2
-0+ 1) Primary write requests will be copied and forwarded to Secondary + QEMU.Primary write requests are forwarded to secondary QEMU as well.
Quoted 4 lines
Quoted 4 lines
docs/block-replication.txt line 53
Quoted 4 lines
docs/block-replication.txt new file +4
-0+ 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.Before Primary write requests are written to (nbd target), aka the Secondary disk, the orignal sector content is read from it and copied to (hidden buf disk) by drive-backup. It obviously will not overwrite the data in (active disk).
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ 3) Primary write requests will be written to Secondary disk.
Primary write requests are written to (nbd target).
Quoted 2 lines
Quoted 2 lines
docs/block-replication.txt line 56
Quoted 2 lines
docs/block-replication.txt new file +2
-0+ 4) Secondary write requests will be buffered in the Disk buffer and it + will overwrite the existing sector content in the buffer.Secondary write request will be written in (active disk) as usual.
Finally, when checkpoint arrives, if you want to sync with primary, just drop data in (hidden buf disk) and (active disk); when failover happends, if you want to promote secondary vm, you can commit (active disk) to (nbd target), and drop data in (hidden buf disk).
Fam
.
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 8 lines · Wen Congyang
Quoted 6 lines
{virtio-blk dev 'foo'} | | | [base] <- [mid] <- (foo)foo's backing is mid, and mid's backing is base?
Yes.
Fam
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
In reply to Fam ZhengQuoted 108 lines · Fam Zheng
Quoted 42 lines · Wen Congyang
Quoted 35 lines · Fam Zheng
Hi Congyang,
Quoted 18 lines · Wen Congyang
+== Workflow ==
docs/block-replication.txt new file +17
-0+The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V |docs/block-replication.txt line 53
Quoted 10 lines
docs/block-replication.txt new file +10
-0+ +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.I'm a little confused by the tenses ("will be" versus "are") and terms. I am reading them as "s/will be/are/g"
Quoted 1 line
Why do you need this buffer?
We only sync the disk till next checkpoint. Before next checkpoint, secondary vm write to the buffer.
Quoted 1 line
Quoted 5 lines
Quoted 2 lines
If both primary and secondary write to the same sector, what is saved in the buffer?
The primary content will be written to the secondary disk, and the secondary content is saved in the buffer.
I wonder if alternatively this is possible with an imaginary "writable backing image" feature, as described below.
When we have a normal backing chain,
{virtio-blk dev 'foo'} | | | [base] <- [mid] <- (foo)Where [base] and [mid] are read only, (foo) is writable. When we add an overlay to an existing image on top,
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | | | [base] <- [mid] <- (foo) <---------------------- (bar)It's important to make sure that writes to 'foo' doesn't break data for 'bar'. We can utilize an automatic hidden drive-backup target:
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | v v [base] <- [mid] <- (foo) <----------------- (hidden target) <--------------- (bar) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>So when guest writes to 'foo', the old data is moved to (hidden target), which remains unchanged from (bar)'s PoV.
The drive in the middle is called hidden because QEMU creates it automatically, the naming is arbitrary.
It is interesting because it is a more generalized case of image fleecing, where the (hidden target) is exposed via NBD server for data scanning (read only) purpose.
More interestingly, with above facility, it is also possible to create a guest visible live snapshot (disk 'bar') of an existing device (disk 'foo') very cheaply. Or call it shadow copy if you will.
Back to the COLO case, the configuration will be very similar:
{primary wr} {secondary vm} | | | | | | v v
Quoted 7 lines
[what] <- [ever] <- (nbd target) <------------ (hidden buf disk) <------------- (active disk)
v ^
v ^
v ^
v ^
>>>> drive-backup sync=none >>>>Why nbd target has backing image ever?
Quoted 25 lines
The workflow analogue is:
Quoted 2 lines
Quoted 2 lines
docs/block-replication.txt line 49
Quoted 2 lines
docs/block-replication.txt new file +2
-0+ 1) Primary write requests will be copied and forwarded to Secondary + QEMU.Primary write requests are forwarded to secondary QEMU as well.
Quoted 4 lines
Quoted 4 lines
docs/block-replication.txt line 53
Quoted 4 lines
docs/block-replication.txt new file +4
-0+ 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.Before Primary write requests are written to (nbd target), aka the Secondary disk, the orignal sector content is read from it and copied to (hidden buf disk) by drive-backup. It obviously will not overwrite the data in (active disk).
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ 3) Primary write requests will be written to Secondary disk.
Primary write requests are written to (nbd target).
Quoted 2 lines
Quoted 2 lines
docs/block-replication.txt line 56
Quoted 2 lines
docs/block-replication.txt new file +2
-0+ 4) Secondary write requests will be buffered in the Disk buffer and it + will overwrite the existing sector content in the buffer.
Quoted 6 lines
Secondary write request will be written in (active disk) as usual.
Finally, when checkpoint arrives, if you want to sync with primary, just drop data in (hidden buf disk) and (active disk); when failover happends, if you want to promote secondary vm, you can commit (active disk) to (nbd target), and drop data in (hidden buf disk).
We cannot drop data in (hidden buf disk). Commit (hidden buf disk) to (nbd target) first, and then commit (active disk) to (nbd target).
Thanks
Wen Congyang
Quoted 4 lines
Fam
.
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 111 lines · Wen Congyang
Quoted 110 lines · Fam Zheng
Quoted 42 lines · Wen Congyang
Quoted 35 lines · Fam Zheng
Hi Congyang,
Quoted 18 lines · Wen Congyang
+== Workflow ==
docs/block-replication.txt new file +17
-0+The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V |docs/block-replication.txt line 53
Quoted 10 lines
docs/block-replication.txt new file +10
-0+ +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer.I'm a little confused by the tenses ("will be" versus "are") and terms. I am reading them as "s/will be/are/g"
Quoted 1 line
Why do you need this buffer?
We only sync the disk till next checkpoint. Before next checkpoint, secondary vm write to the buffer.
Quoted 1 line
Quoted 5 lines
Quoted 2 lines
If both primary and secondary write to the same sector, what is saved in the buffer?
The primary content will be written to the secondary disk, and the secondary content is saved in the buffer.
I wonder if alternatively this is possible with an imaginary "writable backing image" feature, as described below.
When we have a normal backing chain,
{virtio-blk dev 'foo'} | | | [base] <- [mid] <- (foo)Where [base] and [mid] are read only, (foo) is writable. When we add an overlay to an existing image on top,
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | | | [base] <- [mid] <- (foo) <---------------------- (bar)It's important to make sure that writes to 'foo' doesn't break data for 'bar'. We can utilize an automatic hidden drive-backup target:
{virtio-blk dev 'foo'} {virtio-blk dev 'bar'} | | | | v v [base] <- [mid] <- (foo) <----------------- (hidden target) <--------------- (bar) v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>So when guest writes to 'foo', the old data is moved to (hidden target), which remains unchanged from (bar)'s PoV.
The drive in the middle is called hidden because QEMU creates it automatically, the naming is arbitrary.
It is interesting because it is a more generalized case of image fleecing, where the (hidden target) is exposed via NBD server for data scanning (read only) purpose.
More interestingly, with above facility, it is also possible to create a guest visible live snapshot (disk 'bar') of an existing device (disk 'foo') very cheaply. Or call it shadow copy if you will.
Back to the COLO case, the configuration will be very similar:
{primary wr} {secondary vm} | | | | | | v v[what] <- [ever] <- (nbd target) <------------ (hidden buf disk) <------------- (active disk)
Quoted 7 lines
Quoted 5 lines
v ^ v ^ v ^ v ^ >>>> drive-backup sync=none >>>>Why nbd target has backing image ever?
It's not strictly necessary, depending on your VM disk configuration. (for example at the time of vm booting, your image already points to a backing file, etc.
Fam
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
In reply to Wen CongyangQuoted 5 lines · * Wen Congyang ([email protected]) wrote:
Signed-off-by Wen Congyang <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>Signed-off-by Yang Hongyang <[email protected]>Signed-off-by zhanghailiang <[email protected]>Signed-off-by Gonglei <[email protected]>
Hi,
Quoted 25 lines
--- docs/block-replication.txt | 129 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 docs/block-replication.txtdocs/block-replication.txt new file +14
-0@@ -0,0 +1,129 @@ +Block replication +---------------------------------------- +Copyright Fujitsu, Corp. 2015 +Copyright (c) 2015 Intel Corporation +Copyright (c) 2015 HUAWEI TECHNOLOGIES CO.,LTD. + +This work is licensed under the terms of the GNU GPL, version 2 or later. +See the COPYING file in the top-level directory. + +The block replication is used for continuous checkpoints. It is designed +for COLO that Secondary VM is running. It can also be applied for FT/HA +scene that Secondary VM is not running. + +This document gives an overview of block replication's design.
docs/block-replication.txt line 24
Quoted 10 lines
docs/block-replication.txt new file +10
-0+ +== Background == +High availability solutions such as micro checkpoint and COLO will do +consecutive checkpoint. The VM state of Primary VM and Secondary VM is +identical right after a VM checkpoint, but becomes different as the VM +executes till the next checkpoint. To support disk contents checkpoint, +the modified disk contents in the Secondary VM must be buffered, and are +only dropped at next checkpoint time. To reduce the network transportation +effort at the time of checkpoint, the disk modification operations of +Primary disk are asynchronously forwarded to the Secondary node.
Can you explain how the block data is synchronised with the main checkpoint stream? i.e. when the secondary receives a new checkpoint how does it know it's received all of the block writes from the primary associated with that checkpoint and that all the following writes that it receives are for the next checkpoint period?
Dave
Quoted 108 lines
docs/block-replication.txt new file +105
-0+ +== Workflow == +The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V | + +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer. + 3) Primary write requests will be written to Secondary disk. + 4) Secondary write requests will be buffered in the Disk buffer and it + will overwrite the existing sector content in the buffer. + +== Architecture == +We are going to implement COLO block replication from many basic +blocks that are already in QEMU. + + virtio-blk || + ^ || .---------- + | || | Secondary + 1 Quorum || '---------- + / \ || + / \ || + Primary 2 NBD -------> 2 NBD + disk client || server virtio-blk + || ^ ^ +--------. || | | +Primary | || Secondary disk <--------- COLO buffer 3 +--------' || backing + +1) The disk on the primary is represented by a block device with two +children, providing replication between a primary disk and the host that +runs the secondary VM. The read pattern for quorum can be extended to +make the primary always read from the local disk instead of going through +NBD. + +2) The secondary disk receives writes from the primary VM through QEMU's +embedded NBD server (speculative write-through). + +3) The disk on the secondary is represented by a custom block device +("COLO buffer"). The disk buffer's backing image is the secondary disk, +and the disk buffer uses bdrv_add_before_write_notifier to implement +copy-on-write, similar to block/backup.c. + +== New block driver interface == +We add three block driver interfaces to control block replication: +a. bdrv_start_replication() + Start block replication, called in migration/checkpoint thread. + We must call bdrv_start_replication() in secondary QEMU before + calling bdrv_start_replication() in primary QEMU. +b. bdrv_do_checkpoint() + This interface is called after all VM state is transfered to + Secondary QEMU. The Disk buffer will be dropped in this interface. +c. bdrv_stop_replication() + It is called when failover. We will flush the Disk buffer into + Secondary Disk and stop block replication. + +== Usage == +Primary: + -drive if=xxx,driver=quorum,read-pattern=first,\ + children.0.file.filename=1.raw,\ + children.0.driver=raw,\ + children.1.file.driver=nbd+colo,\ + children.1.file.host=xxx,\ + children.1.file.port=xxx,\ + children.1.file.export=xxx,\ + children.1.driver=raw + Note: + 1. NBD Client should not be the first child of quorum. + 2. There should be only one NBD Client. + 3. host is the secondary physical machine's hostname or IP + 4. Each disk must have its own export name. + +Secondary: + -drive if=xxx,driver=blkcolo,export=xxx,\ + backing.file.filename=1.raw,\ + backing.driver=raw + Then run qmp command: + nbd_server_start host:port + Note: + 1. The export name for the same disk must be the same in primary + and secondary QEMU command line + 2. The qmp command nbd_server_start must be run before running the + qmp command migrate on primary QEMU + 3. Don't use nbd_server_start's other optionsSignature · 1 line
2.1.0
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 42 lines · Dr. David Alan Gilbert
Quoted 5 lines · * Wen Congyang ([email protected]) wrote:
Signed-off-by Wen Congyang <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>Signed-off-by Yang Hongyang <[email protected]>Signed-off-by zhanghailiang <[email protected]>Signed-off-by Gonglei <[email protected]>Hi,
Quoted 33 lines
--- docs/block-replication.txt | 129 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 docs/block-replication.txtdocs/block-replication.txt new file +22
-0@@ -0,0 +1,129 @@ +Block replication +---------------------------------------- +Copyright Fujitsu, Corp. 2015 +Copyright (c) 2015 Intel Corporation +Copyright (c) 2015 HUAWEI TECHNOLOGIES CO.,LTD. + +This work is licensed under the terms of the GNU GPL, version 2 or later. +See the COPYING file in the top-level directory. + +The block replication is used for continuous checkpoints. It is designed +for COLO that Secondary VM is running. It can also be applied for FT/HA +scene that Secondary VM is not running. + +This document gives an overview of block replication's design. + +== Background == +High availability solutions such as micro checkpoint and COLO will do +consecutive checkpoint. The VM state of Primary VM and Secondary VM is +identical right after a VM checkpoint, but becomes different as the VM +executes till the next checkpoint. To support disk contents checkpoint, +the modified disk contents in the Secondary VM must be buffered, and are +only dropped at next checkpoint time. To reduce the network transportation
Quoted 8 lines
docs/block-replication.txt line 24
Quoted 2 lines
docs/block-replication.txt new file +2
-0+effort at the time of checkpoint, the disk modification operations of +Primary disk are asynchronously forwarded to the Secondary node.Can you explain how the block data is synchronised with the main checkpoint stream? i.e. when the secondary receives a new checkpoint how does it know it's received all of the block writes from the primary associated with that checkpoint and that all the following writes that it receives are for the next checkpoint period?
NBD server will do it. Writing to NBD client will return after NBD server replies the result(ACK or error).
Thanks
Wen Congyang
Quoted 115 lines
Dave
Quoted 108 lines
docs/block-replication.txt new file +105
-0+ +== Workflow == +The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V | + +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer. + 3) Primary write requests will be written to Secondary disk. + 4) Secondary write requests will be buffered in the Disk buffer and it + will overwrite the existing sector content in the buffer. + +== Architecture == +We are going to implement COLO block replication from many basic +blocks that are already in QEMU. + + virtio-blk || + ^ || .---------- + | || | Secondary + 1 Quorum || '---------- + / \ || + / \ || + Primary 2 NBD -------> 2 NBD + disk client || server virtio-blk + || ^ ^ +--------. || | | +Primary | || Secondary disk <--------- COLO buffer 3 +--------' || backing + +1) The disk on the primary is represented by a block device with two +children, providing replication between a primary disk and the host that +runs the secondary VM. The read pattern for quorum can be extended to +make the primary always read from the local disk instead of going through +NBD. + +2) The secondary disk receives writes from the primary VM through QEMU's +embedded NBD server (speculative write-through). + +3) The disk on the secondary is represented by a custom block device +("COLO buffer"). The disk buffer's backing image is the secondary disk, +and the disk buffer uses bdrv_add_before_write_notifier to implement +copy-on-write, similar to block/backup.c. + +== New block driver interface == +We add three block driver interfaces to control block replication: +a. bdrv_start_replication() + Start block replication, called in migration/checkpoint thread. + We must call bdrv_start_replication() in secondary QEMU before + calling bdrv_start_replication() in primary QEMU. +b. bdrv_do_checkpoint() + This interface is called after all VM state is transfered to + Secondary QEMU. The Disk buffer will be dropped in this interface. +c. bdrv_stop_replication() + It is called when failover. We will flush the Disk buffer into + Secondary Disk and stop block replication. + +== Usage == +Primary: + -drive if=xxx,driver=quorum,read-pattern=first,\ + children.0.file.filename=1.raw,\ + children.0.driver=raw,\ + children.1.file.driver=nbd+colo,\ + children.1.file.host=xxx,\ + children.1.file.port=xxx,\ + children.1.file.export=xxx,\ + children.1.driver=raw + Note: + 1. NBD Client should not be the first child of quorum. + 2. There should be only one NBD Client. + 3. host is the secondary physical machine's hostname or IP + 4. Each disk must have its own export name. + +Secondary: + -drive if=xxx,driver=blkcolo,export=xxx,\ + backing.file.filename=1.raw,\ + backing.driver=raw + Then run qmp command: + nbd_server_start host:port + Note: + 1. The export name for the same disk must be the same in primary + and secondary QEMU command line + 2. The qmp command nbd_server_start must be run before running the + qmp command migrate on primary QEMU + 3. Don't use nbd_server_start's other optionsSignature · 1 line
2.1.0--
Dr. David Alan Gilbert / [email protected] / Manchester, UK .
Re: [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description
Quoted 52 lines · * Wen Congyang ([email protected]) wrote:
Quoted 42 lines · Dr. David Alan Gilbert
Quoted 5 lines · * Wen Congyang ([email protected]) wrote:
Signed-off-by Wen Congyang <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>Signed-off-by Yang Hongyang <[email protected]>Signed-off-by zhanghailiang <[email protected]>Signed-off-by Gonglei <[email protected]>Hi,
Quoted 33 lines
--- docs/block-replication.txt | 129 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 docs/block-replication.txtdocs/block-replication.txt new file +22
-0@@ -0,0 +1,129 @@ +Block replication +---------------------------------------- +Copyright Fujitsu, Corp. 2015 +Copyright (c) 2015 Intel Corporation +Copyright (c) 2015 HUAWEI TECHNOLOGIES CO.,LTD. + +This work is licensed under the terms of the GNU GPL, version 2 or later. +See the COPYING file in the top-level directory. + +The block replication is used for continuous checkpoints. It is designed +for COLO that Secondary VM is running. It can also be applied for FT/HA +scene that Secondary VM is not running. + +This document gives an overview of block replication's design. + +== Background == +High availability solutions such as micro checkpoint and COLO will do +consecutive checkpoint. The VM state of Primary VM and Secondary VM is +identical right after a VM checkpoint, but becomes different as the VM +executes till the next checkpoint. To support disk contents checkpoint, +the modified disk contents in the Secondary VM must be buffered, and are +only dropped at next checkpoint time. To reduce the network transportationQuoted 8 lines
docs/block-replication.txt line 24
Quoted 2 lines
docs/block-replication.txt new file +2
-0+effort at the time of checkpoint, the disk modification operations of +Primary disk are asynchronously forwarded to the Secondary node.Can you explain how the block data is synchronised with the main checkpoint stream? i.e. when the secondary receives a new checkpoint how does it know it's received all of the block writes from the primary associated with that checkpoint and that all the following writes that it receives are for the next checkpoint period?
Quoted 2 lines
NBD server will do it. Writing to NBD client will return after NBD server replies the result(ACK or error).
Ah OK, so if the NBD client is synchronous then yes I can see that; (I was confused by the word 'asynchronously' in your description above but I guess that means asynchronous to the checkpoint stream). I see that 'do_colo_transaction' keeps the primary stopped until after the secondary does blk_do_checkpoint and then sends 'LOADED'.
I think yes that should work; although potentially you could make it faster; since the primary doesn't need to know that it's write has been commited until the next checkpoint, and if you could mark the separation in the two checkpoints, then you could start the primary running again earlier. But that's all more complicated; this should work OK.
Thanks for the explanation,
Dave
Quoted 119 lines
Thanks
Wen CongyangQuoted 115 lines
Dave
Quoted 108 lines
docs/block-replication.txt new file +105
-0+ +== Workflow == +The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V | + +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content in the Disk buffer. + 3) Primary write requests will be written to Secondary disk. + 4) Secondary write requests will be buffered in the Disk buffer and it + will overwrite the existing sector content in the buffer. + +== Architecture == +We are going to implement COLO block replication from many basic +blocks that are already in QEMU. + + virtio-blk || + ^ || .---------- + | || | Secondary + 1 Quorum || '---------- + / \ || + / \ || + Primary 2 NBD -------> 2 NBD + disk client || server virtio-blk + || ^ ^ +--------. || | | +Primary | || Secondary disk <--------- COLO buffer 3 +--------' || backing + +1) The disk on the primary is represented by a block device with two +children, providing replication between a primary disk and the host that +runs the secondary VM. The read pattern for quorum can be extended to +make the primary always read from the local disk instead of going through +NBD. + +2) The secondary disk receives writes from the primary VM through QEMU's +embedded NBD server (speculative write-through). + +3) The disk on the secondary is represented by a custom block device +("COLO buffer"). The disk buffer's backing image is the secondary disk, +and the disk buffer uses bdrv_add_before_write_notifier to implement +copy-on-write, similar to block/backup.c. + +== New block driver interface == +We add three block driver interfaces to control block replication: +a. bdrv_start_replication() + Start block replication, called in migration/checkpoint thread. + We must call bdrv_start_replication() in secondary QEMU before + calling bdrv_start_replication() in primary QEMU. +b. bdrv_do_checkpoint() + This interface is called after all VM state is transfered to + Secondary QEMU. The Disk buffer will be dropped in this interface. +c. bdrv_stop_replication() + It is called when failover. We will flush the Disk buffer into + Secondary Disk and stop block replication. + +== Usage == +Primary: + -drive if=xxx,driver=quorum,read-pattern=first,\ + children.0.file.filename=1.raw,\ + children.0.driver=raw,\ + children.1.file.driver=nbd+colo,\ + children.1.file.host=xxx,\ + children.1.file.port=xxx,\ + children.1.file.export=xxx,\ + children.1.driver=raw + Note: + 1. NBD Client should not be the first child of quorum. + 2. There should be only one NBD Client. + 3. host is the secondary physical machine's hostname or IP + 4. Each disk must have its own export name. + +Secondary: + -drive if=xxx,driver=blkcolo,export=xxx,\ + backing.file.filename=1.raw,\ + backing.driver=raw + Then run qmp command: + nbd_server_start host:port + Note: + 1. The export name for the same disk must be the same in primary + and secondary QEMU command line + 2. The qmp command nbd_server_start must be run before running the + qmp command migrate on primary QEMU + 3. Don't use nbd_server_start's other optionsSignature · 1 line
2.1.0--
Dr. David Alan Gilbert / [email protected] / Manchester, UK .
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
RFC PATCH 2/14 quorom: add a new read pattern
In reply to Wen CongyangTo block replication, we only need to read from the first child.
--- block/quorum.c | 5 +++-- qapi/block-core.json | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-)
block/quorum.c +3 -2
@@ -286,9 +286,10 @@ static void quorum_aio_cb(void *opaque, int ret)BDRVQuorumState *s = acb->common.bs->opaque;bool rewrite = false; -if (acb->is_read && s->read_pattern ==QUORUM_READ_PATTERN_FIFO ) { +if (acb->is_read && s->read_pattern !=QUORUM_READ_PATTERN_QUORUM ) {/* We try to read next child in FIFO order if we fail to read */ -if (ret <0 && ++acb->child_iter < s->num_children) { +if (s->read_pattern ==QUORUM_READ_PATTERN_FIFO && + ret <0 && ++acb->child_iter < s->num_children) {read_fifo_child (acb);return ; }
qapi/block-core.json +3 -1
@@ -1618,9 +1618,11 @@ # # @fifo: read only from the first child that has not failed # +# @first: read only from the first child +# # Since: 2.2 ## -{ 'enum': 'QuorumReadPattern', 'data': [ 'quorum', 'fifo' ] } +{ 'enum': 'QuorumReadPattern', 'data': [ 'quorum', 'fifo', 'first' ] } ## # @BlockdevOptionsQuorum
Signature · 1 line
2.1.0
Re: [Qemu-devel] [RFC PATCH 02/14] quorom: add a new read pattern
Quoted 7 lines · Wen Congyang
To block replication, we only need to read from the first child.
Signed-off-by Wen Congyang <[email protected]>Signed-off-by zhanghailiang <[email protected]>Signed-off-by Gonglei <[email protected]>Cc Luiz Capitulino <[email protected]>Cc Michael Roth <[email protected]>
A little typo in title of patch 2 and patch 5:
s/quorom/quorum/
Regards,
-Gonglei
Re: [Qemu-devel] [RFC PATCH 02/14] quorom: add a new read pattern
In reply to Wen CongyangQuoted 17 lines · Wen Congyang
To block replication, we only need to read from the first child.
Signed-off-by Wen Congyang <[email protected]>Signed-off-by zhanghailiang <[email protected]>Signed-off-by Gonglei <[email protected]>Cc Luiz Capitulino <[email protected]>Cc Michael Roth <[email protected]>--- block/quorum.c | 5 +++-- qapi/block-core.json | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-)block/quorum.c +0
-0
block/quorum.c static void quorum_aio_cb(void *opaque, int ret) · line 289
Quoted 5 lines
block/quorum.c +1
-1@@ -286,9 +286,10 @@ static void quorum_aio_cb(void *opaque, int ret)BDRVQuorumState *s = acb->common.bs->opaque;bool rewrite = false; -if (acb->is_read && s->read_pattern ==QUORUM_READ_PATTERN_FIFO ) { +if (acb->is_read && s->read_pattern !=QUORUM_READ_PATTERN_QUORUM ) {
Maybe I'd prefer "&& (s->read_pattern == QUORUM_READ_PATTERN_FIFO || s->read_pattern == QUORUM_READ_PATTERN_FIRST)"; but it does fit with what quorum_aio_readv() does, so I'm fine with it.
block/quorum.c static void quorum_aio_cb(void *opaque, int ret) · line 290
Quoted 1 line
block/quorum.c +0
-0/* We try to read next child in FIFO order if we fail to read */
However, I think this comment should be modified, because in fact we do not try to read the next child if s->read_pattern == QUORUM_READ_PATTERN_FIRST.
Quoted 11 lines
block/quorum.c +2
-1-if (ret <0 && ++acb->child_iter < s->num_children) { +if (s->read_pattern ==QUORUM_READ_PATTERN_FIFO && + ret <0 && ++acb->child_iter < s->num_children) {read_fifo_child (acb);return ; }qapi/block-core.json +0
-0
qapi/block-core.json line 1621
Quoted 4 lines
qapi/block-core.json +1
-0@@ -1618,9 +1618,11 @@ # # @fifo: read only from the first child that has not failed # +# @first: read only from the first child
There should be version info here (like "(Since 2.3)").
Max
Quoted 8 lines
qapi/block-core.json +2
-1+# # Since: 2.2 ## -{ 'enum': 'QuorumReadPattern', 'data': [ 'quorum', 'fifo' ] } +{ 'enum': 'QuorumReadPattern', 'data': [ 'quorum', 'fifo', 'first' ] } ## # @BlockdevOptionsQuorum
Re: [Qemu-devel] [RFC PATCH 02/14] quorom: add a new read pattern
In reply to Wen CongyangQuoted 1 line · Wen Congyang
To block replication, we only need to read from the first child.
s/quorom/quorum/ in the subject line
s/To block/For block/
Quoted 13 lines
Signed-off-by Wen Congyang <[email protected]>Signed-off-by zhanghailiang <[email protected]>Signed-off-by Gonglei <[email protected]>Cc Luiz Capitulino <[email protected]>Cc Michael Roth <[email protected]>--- block/quorum.c | 5 +++-- qapi/block-core.json | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-)+++
b/qapi/block-core.json
qapi/block-core.json line 1622
Quoted 5 lines
qapi/block-core.json +2
-0@@ -1618,9 +1618,11 @@ # # @fifo: read only from the first child that has not failed # +# @first: read only from the first child +
Missing a 'since 2.3' designation. Otherwise looks okay.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
RFC PATCH 3/14 quorum: ignore 0-length child
In reply to Wen CongyangWe connect to NBD server when starting block replication, so the length is 0 before starting block replication.
--- block/quorum.c | 5 +++++ 1 file changed, 5 insertions(+)
block/quorum.c +5 -0
@@ -734,6 +734,11 @@ static int64_t quorum_getlength(BlockDriverState *bs)if (value <0 ) {return value; } + +if (!value) { +continue ; + } +if (value != result) {return -EIO ; }
Signature · 1 line
2.1.0
Re: [Qemu-devel] [RFC PATCH 03/14] quorum: ignore 0-length child
Quoted 16 lines · Wen Congyang
We connect to NBD server when starting block replication, so the length is 0 before starting block replication.
Signed-off-by Wen Congyang <[email protected]>Signed-off-by zhanghailiang <[email protected]>Signed-off-by Gonglei <[email protected]>--- block/quorum.c | 5 +++++ 1 file changed, 5 insertions(+)block/quorum.c +0
-0@@ -734,6 +734,11 @@ static int64_t quorum_getlength(BlockDriverState *bs)if (value <0 ) {
block/quorum.c static int64_t quorum_getlength(BlockDriverState *bs) · line 744
Quoted 10 lines
block/quorum.c +5
-0return value; } + +if (!value) { +continue ; + } +if (value != result) {return -EIO ; }
Hm, what do you think about some specific error value returned by your delayed NBD implementation? Like -ENOTCONN or something like that? Then we'd be able to discern a real 0-length block device from a not-yet-connected NBD server.
Also, while you did write that one shouldn't be using the NBD client as the first quorum child, I think we should try to support that case anyway. For this patch, that means accepting that bdrv_getlength(s->bs[0]) may be off.
Max
Re: [Qemu-devel] [RFC PATCH 03/14] quorum: ignore 0-length child
Quoted 30 lines · Max Reitz
Quoted 16 lines · Wen Congyang
We connect to NBD server when starting block replication, so the length is 0 before starting block replication.
Signed-off-by Wen Congyang <[email protected]>Signed-off-by zhanghailiang <[email protected]>Signed-off-by Gonglei <[email protected]>--- block/quorum.c | 5 +++++ 1 file changed, 5 insertions(+)block/quorum.c +0
-0@@ -734,6 +734,11 @@ static int64_t quorum_getlength(BlockDriverState *bs)if (value <0 ) {block/quorum.c static int64_t quorum_getlength(BlockDriverState *bs) · line 744
Quoted 10 lines
block/quorum.c +5
-0return value; } + +if (!value) { +continue ; + } +if (value != result) {return -EIO ; }Hm, what do you think about some specific error value returned by your delayed NBD implementation? Like
-ENOTCONNor something like that? Then we'd be able to discern a real 0-length block device from a not-yet-connected NBD server.
Quoted 1 line
Also, while you did write that one shouldn't be using the NBD client as the first quorum child, I think we should try to support that case anyway. For this patch, that means accepting that
bdrv_getlength(s->bs[0])may be off.
Good idea. I will try it.
Thanks
Wen Congyang
Quoted 4 lines
Max
.
Re: [Qemu-devel] [RFC PATCH 03/14] quorum: ignore 0-length child
In reply to Max ReitzQuoted 21 lines · Max Reitz
Quoted 20 lines · Wen Congyang
We connect to NBD server when starting block replication, so the length is 0 before starting block replication.
Signed-off-by Wen Congyang <[email protected]>Signed-off-by zhanghailiang <[email protected]>Signed-off-by Gonglei <[email protected]>--- block/quorum.c | 5 +++++ 1 file changed, 5 insertions(+)block/quorum.c +2
-0@@ -734,6 +734,11 @@ static int64_t quorum_getlength(BlockDriverState *bs)if (value <0 ) {return value; } + +if (!value) {
Quoted 8 lines
block/quorum.c static int64_t quorum_getlength(BlockDriverState *bs) · line 744
Quoted 6 lines
block/quorum.c +3
-0+continue ; + } +if (value != result) {return -EIO ; }Hm, what do you think about some specific error value returned by your delayed NBD implementation? Like
-ENOTCONNor something like that? Then we'd be able to discern a real 0-length block device from a not-yet-connected NBD server.
In my newest test, it cannot return -ENOTCONN, otherwise bdrv_open() will fail when we open the child. Here is the backtrace:
(gdb) bt
#0 bdrv_open_common (bs=0x5555563b2230, file=0x0, options=0x5555563b55a0, flags=57410, drv=0x555555e90c00, errp=0x7fffffffd460) at block.c:1070 #1 0x000055555595ea72 in bdrv_open (pbs=0x7fffffffd5f8, filename=0x0, reference=0x0, options=0x5555563b55a0, flags=57410, drv=0x555555e90c00, errp=0x7fffffffd5e0) at block.c:1677 #2 0x000055555595e3a9 in bdrv_open_image (pbs=0x7fffffffd5f8, filename=0x0, options=0x5555563a6730, bdref_key=0x555555a86b4c "file", flags=57410, allow_none=true, errp=0x7fffffffd5e0) at block.c:1481 #3 0x000055555595e9ae in bdrv_open (pbs=0x555556388008, filename=0x0, reference=0x0, options=0x5555563a6730, flags=8258, drv=0x555555e8b800, errp=0x7fffffffd6b8) at block.c:1655 #4 0x00005555559b0058 in quorum_open (bs=0x55555639bd90, options=0x55555639f100, flags=8258, errp=0x7fffffffd758) at block/quorum.c:1000 #5 0x000055555595d0b8 in bdrv_open_common (bs=0x55555639bd90, file=0x0, options=0x55555639f100, flags=8258, drv=0x555555e8e5c0, errp=0x7fffffffd840) at block.c:1045 #6 0x000055555595ea72 in bdrv_open (pbs=0x55555639bd50, filename=0x0, reference=0x0, options=0x55555639f100, flags=8258, drv=0x555555e8e5c0, errp=0x7fffffffdb70) at block.c:1677 #7 0x00005555559b3bd3 in blk_new_open (name=0x55555639bc60 "virtio0", filename=0x0, reference=0x0, options=0x55555639a420, flags=66, errp=0x7fffffffdb70) at block/block-backend.c:129 #8 0x0000555555754f78 in blockdev_init (file=0x0, bs_opts=0x55555639a420, errp=0x7fffffffdb70) at blockdev.c:536 #9 0x0000555555755d90 in drive_new (all_opts=0x5555563777e0, block_default_type=IF_IDE) at blockdev.c:971
#10 0x000055555576b1f0 in drive_init_func (opts=0x5555563777e0, opaque=0x555556372b48) at vl.c:1104
#11 0x0000555555a1b019 in qemu_opts_foreach (list=0x555555e44060, func=0x55555576b1ba <drive_init_func>, opaque=0x555556372b48, abort_on_failure=1) at util/qemu-option.c:1059 #12 0x00005555557743dd in main (argc=25, argv=0x7fffffffe0c8, envp=0x7fffffffe198) at vl.c:4191
refresh_total_sectors() will fail if we return -ENOTCONN.
Thanks
Wen Congyang
Quoted 6 lines
Also, while you did write that one shouldn't be using the NBD client as the first quorum child, I think we should try to support that case anyway. For this patch, that means accepting that
bdrv_getlength(s->bs[0])may be off.Max
.
Re: [Qemu-devel] [RFC PATCH 03/14] quorum: ignore 0-length child
Quoted 42 lines · Wen Congyang
Quoted 20 lines · Max Reitz
Quoted 19 lines · Wen Congyang
We connect to NBD server when starting block replication, so the length is 0 before starting block replication.
Signed-off-by Wen Congyang <[email protected]>Signed-off-by zhanghailiang <[email protected]>Signed-off-by Gonglei <[email protected]>--- block/quorum.c | 5 +++++ 1 file changed, 5 insertions(+)block/quorum.c +1
-0@@ -734,6 +734,11 @@ static int64_t quorum_getlength(BlockDriverState *bs)if (value <0 ) {return value; } +Quoted 8 lines
block/quorum.c static int64_t quorum_getlength(BlockDriverState *bs) · line 744
Quoted 7 lines
block/quorum.c +4
-0+if (!value) { +continue ; + } +if (value != result) {return -EIO ; }Hm, what do you think about some specific error value returned by your delayed NBD implementation? Like
-ENOTCONNor something like that? Then we'd be able to discern a real 0-length block device from a not-yet-connected NBD server.In my newest test, it cannot return
-ENOTCONN, otherwisebdrv_open()will fail when we open the child. Here is the backtrace:
(gdb) bt#0 bdrv_open_common (bs=0x5555563b2230, file=0x0, options=0x5555563b55a0, flags=57410, drv=0x555555e90c00, errp=0x7fffffffd460) at block.c:1070 #1 0x000055555595ea72 in bdrv_open (pbs=0x7fffffffd5f8, filename=0x0, reference=0x0, options=0x5555563b55a0, flags=57410, drv=0x555555e90c00, errp=0x7fffffffd5e0) at block.c:1677 #2 0x000055555595e3a9 in bdrv_open_image (pbs=0x7fffffffd5f8, filename=0x0, options=0x5555563a6730, bdref_key=0x555555a86b4c "file", flags=57410, allow_none=true, errp=0x7fffffffd5e0) at block.c:1481 #3 0x000055555595e9ae in bdrv_open (pbs=0x555556388008, filename=0x0, reference=0x0, options=0x5555563a6730, flags=8258, drv=0x555555e8b800, errp=0x7fffffffd6b8) at block.c:1655 #4 0x00005555559b0058 in quorum_open (bs=0x55555639bd90, options=0x55555639f100, flags=8258, errp=0x7fffffffd758) at block/quorum.c:1000 #5 0x000055555595d0b8 in bdrv_open_common (bs=0x55555639bd90, file=0x0, options=0x55555639f100, flags=8258, drv=0x555555e8e5c0, errp=0x7fffffffd840) at block.c:1045 #6 0x000055555595ea72 in bdrv_open (pbs=0x55555639bd50, filename=0x0, reference=0x0, options=0x55555639f100, flags=8258, drv=0x555555e8e5c0, errp=0x7fffffffdb70) at block.c:1677 #7 0x00005555559b3bd3 in blk_new_open (name=0x55555639bc60 "virtio0", filename=0x0, reference=0x0, options=0x55555639a420, flags=66, errp=0x7fffffffdb70) at block/block-backend.c:129 #8 0x0000555555754f78 in blockdev_init (file=0x0, bs_opts=0x55555639a420, errp=0x7fffffffdb70) at blockdev.c:536 #9 0x0000555555755d90 in drive_new (all_opts=0x5555563777e0, block_default_type=IF_IDE) at blockdev.c:971
Quoted 5 lines
#10
0x000055555576b1f0indrive_init_func(opts=0x5555563777e0, opaque=0x555556372b48) at vl.c:1104
#110x0000555555a1b019inqemu_opts_foreach(list=0x555555e44060, func=0x55555576b1ba <drive_init_func>, opaque=0x555556372b48, abort_on_failure=1) atutil/qemu-option.c:1059#120x00005555557743ddin main (argc=25, argv=0x7fffffffe0c8, envp=0x7fffffffe198) at vl.c:4191
refresh_total_sectors()will fail if we return-ENOTCONN.
Okay, then 0 will be fine, too.
Max
RFC PATCH 4/14 Add new block driver interfaces to control disk replication
In reply to Wen Congyang--- block.c | 36 ++++++++++++++++++++++++++++++++++++ include/block/block.h | 10 ++++++++++ include/block/block_int.h | 12 ++++++++++++ 3 files changed, 58 insertions(+)
block.c +36 -0
@@ -6156,3 +6156,39 @@ BlockAcctStats *bdrv_get_stats(BlockDriverState *bs) {return &bs->stats; } + +int bdrv_start_replication (BlockDriverState *bs,int mode) +{ +BlockDriver *drv = bs->drv; +if (drv && drv->bdrv_start_replication) { +return drv->bdrv_start_replication (bs, mode); + }else if (bs->file) { +return bdrv_start_replication (bs->file, mode); + } + +return -1 ; +} + +int bdrv_do_checkpoint (BlockDriverState *bs) +{ +BlockDriver *drv = bs->drv; +if (drv && drv->bdrv_do_checkpoint) { +return drv->bdrv_do_checkpoint (bs); + }else if (bs->file) { +return bdrv_do_checkpoint (bs->file); + } + +return -1 ; +} + +int bdrv_stop_replication (BlockDriverState *bs) +{ +BlockDriver *drv = bs->drv; +if (drv && drv->bdrv_stop_replication) { +return drv->bdrv_stop_replication (bs); + }else if (bs->file) { +return bdrv_stop_replication (bs->file); + } + +return -1 ; +}
include/block/block.h +10 -0
@@ -557,4 +557,14 @@ void bdrv_flush_io_queue(BlockDriverState *bs);BlockAcctStats *bdrv_get_stats (BlockDriverState *bs); +/* Checkpoint control, called in migration/checkpoint thread */ +enum { +COLO_UNPROTECTED_MODE =0 , +COLO_PRIMARY_MODE , +COLO_SECONDARY_MODE , +}; +int bdrv_start_replication (BlockDriverState *bs,int mode); +int bdrv_do_checkpoint (BlockDriverState *bs); +int bdrv_stop_replication (BlockDriverState *bs); +#endif
include/block/block_int.h +12 -0
@@ -273,6 +273,18 @@ struct BlockDriver {void (*bdrv_io_unplug)(BlockDriverState *bs);void (*bdrv_flush_io_queue)(BlockDriverState *bs); + +/* Checkpoint control, called in migration/checkpoint thread */ +int (*bdrv_start_replication)(BlockDriverState *bs,int mode); +/* +* Drop Disk buffer when doing checkpoint. +*/ +int (*bdrv_do_checkpoint)(BlockDriverState *bs); +/* After failover, we should flush Disk buffer into secondary disk +* and stop block replication. +*/ +int (*bdrv_stop_replication)(BlockDriverState *bs); +QLIST_ENTRY (BlockDriver) list; };
Signature · 1 line
2.1.0
Re: [Qemu-devel] [RFC PATCH 04/14] Add new block driver interfaces to control disk replication
Quoted 18 lines · Wen Congyang
Signed-off-by Wen Congyang <[email protected]>Signed-off-by zhanghailiang <[email protected]>Signed-off-by Gonglei <[email protected]>--- block.c | 36 ++++++++++++++++++++++++++++++++++++ include/block/block.h | 10 ++++++++++ include/block/block_int.h | 12 ++++++++++++ 3 files changed, 58 insertions(+)block.c +1
-0@@ -6156,3 +6156,39 @@ BlockAcctStats *bdrv_get_stats(BlockDriverState *bs) {return &bs->stats; } +
block.c BlockAcctStats *bdrv_get_stats(BlockDriverState *bs) · line 6169
Quoted 10 lines
block.c +10
-0+int bdrv_start_replication (BlockDriverState *bs,int mode) +{ +BlockDriver *drv = bs->drv; +if (drv && drv->bdrv_start_replication) { +return drv->bdrv_start_replication (bs, mode); + }else if (bs->file) { +return bdrv_start_replication (bs->file, mode); + } + +return -1 ;
I'd prefer returning -errno here (like -ENOTSUP). Alternatively, you may want to use Error objects (which would probably actually be the preferable way).
block.c BlockAcctStats *bdrv_get_stats(BlockDriverState *bs) · line 6181
Quoted 12 lines
block.c +12
-0+} + +int bdrv_do_checkpoint (BlockDriverState *bs) +{ +BlockDriver *drv = bs->drv; +if (drv && drv->bdrv_do_checkpoint) { +return drv->bdrv_do_checkpoint (bs); + }else if (bs->file) { +return bdrv_do_checkpoint (bs->file); + } + +return -1 ;
Same here.
block.c BlockAcctStats *bdrv_get_stats(BlockDriverState *bs) · line 6193
Quoted 12 lines
block.c +12
-0+} + +int bdrv_stop_replication (BlockDriverState *bs) +{ +BlockDriver *drv = bs->drv; +if (drv && drv->bdrv_stop_replication) { +return drv->bdrv_stop_replication (bs); + }else if (bs->file) { +return bdrv_stop_replication (bs->file); + } + +return -1 ;
And here.
Quoted 6 lines
block.c +1
-0+}include/block/block.h +0
-0
include/block/block.h void bdrv_flush_io_queue(BlockDriverState *bs); · line 565
Quoted 9 lines
include/block/block.h +6
-0@@ -557,4 +557,14 @@ void bdrv_flush_io_queue(BlockDriverState *bs);BlockAcctStats *bdrv_get_stats (BlockDriverState *bs); +/* Checkpoint control, called in migration/checkpoint thread */ +enum { +COLO_UNPROTECTED_MODE =0 , +COLO_PRIMARY_MODE , +COLO_SECONDARY_MODE , +};
I have a feeling that you may want to define these values through QAPI...
There's nothing wrong with this patch, but I don't yet really know what you want to do with these functions (the doc didn't really help me with them), so I'll have to look into the rest of the series before I can really say something useful about it.
Max
Quoted 28 lines
include/block/block.h +4
-0+int bdrv_start_replication (BlockDriverState *bs,int mode); +int bdrv_do_checkpoint (BlockDriverState *bs); +int bdrv_stop_replication (BlockDriverState *bs); +#endif include/block/block_int.h +12
-0@@ -273,6 +273,18 @@ struct BlockDriver {void (*bdrv_io_unplug)(BlockDriverState *bs);void (*bdrv_flush_io_queue)(BlockDriverState *bs); + +/* Checkpoint control, called in migration/checkpoint thread */ +int (*bdrv_start_replication)(BlockDriverState *bs,int mode); +/* +* Drop Disk buffer when doing checkpoint. +*/ +int (*bdrv_do_checkpoint)(BlockDriverState *bs); +/* After failover, we should flush Disk buffer into secondary disk +* and stop block replication. +*/ +int (*bdrv_stop_replication)(BlockDriverState *bs); +QLIST_ENTRY (BlockDriver) list; };
Re: [Qemu-devel] [RFC PATCH 04/14] Add new block driver interfaces to control disk replication
Quoted 11 lines · Max Reitz
Quoted 9 lines · Wen Congyang
Signed-off-by Wen Congyang <[email protected]>Signed-off-by zhanghailiang <[email protected]>Signed-off-by Gonglei <[email protected]>--- block.c | 36 ++++++++++++++++++++++++++++++++++++ include/block/block.h | 10 ++++++++++ include/block/block_int.h | 12 ++++++++++++ 3 files changed, 58 insertions(+)
Quoted 11 lines
include/block/block.h void bdrv_flush_io_queue(BlockDriverState *bs); · line 563
Quoted 9 lines
+++
b/include/block/block.hinclude/block/block.h +5
-0@@ -557,4 +557,14 @@ void bdrv_flush_io_queue(BlockDriverState *bs);BlockAcctStats *bdrv_get_stats (BlockDriverState *bs); +/* Checkpoint control, called in migration/checkpoint thread */ +enum { +COLO_UNPROTECTED_MODE =0 , +COLO_PRIMARY_MODE , + COLO_SECONDARY_MODE, +};I have a feeling that you may want to define these values through QAPI...
especially if you intend for a QMP command to output which mode a colo disk is in.
Quoted 11 lines
include/block/block_int.h struct BlockDriver { · line 281
Quoted 11 lines
include/block/block_int.h +7
-0+++ b/include/block/block_int.h@@ -273,6 +273,18 @@ struct BlockDriver {void (*bdrv_io_unplug)(BlockDriverState *bs);void (*bdrv_flush_io_queue)(BlockDriverState *bs); + +/* Checkpoint control, called in migration/checkpoint thread */ + int (*bdrv_start_replication)(BlockDriverState *bs, int mode); +/* +* Drop Disk buffer when doing checkpoint. +*/ +int (*bdrv_do_checkpoint)(BlockDriverState *bs);
Inconsistent comment style between one-line and multi-line.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
RFC PATCH 5/14 quorom: implement block driver interfaces for block replication
In reply to Wen Congyang--- block/quorum.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+)
block/quorum.c +69 -0
@@ -1070,6 +1070,71 @@ static void quorum_refresh_filename(BlockDriverState *bs) bs->full_open_options = opts; } +static int quorum_stop_replication (BlockDriverState *bs); +static int quorum_start_replication (BlockDriverState *bs,int mode) +{ +BDRVQuorumState *s = bs->opaque; +int ret =-1 , i; + +/* +* TODO: support COLO_SECONDARY_MODE if we allow secondary +* QEMU becoming primary QEMU. +*/ +if (mode !=COLO_PRIMARY_MODE ) { +return -1 ; + } + +if (s->read_pattern !=QUORUM_READ_PATTERN_FIRST ) { +return -1 ; + } + +/* NBD client should not be the first child */ +if (bdrv_start_replication (s->bs[0 ], mode) ==0 ) { +bdrv_stop_replication (s->bs[0 ]); +return -1 ; + } + +for (i =1 ; i < s->num_children; i++) { +if (bdrv_start_replication (s->bs[i], mode) ==0 ) { + ret++; + } + } + +if (ret >0 ) { +quorum_stop_replication (bs); + } + +return ret ?-1 :0 ; +} + +static int quorum_do_checkpoint (BlockDriverState *bs) +{ +BDRVQuorumState *s = bs->opaque; +int i; + +for (i =1 ; i < s->num_children; i++) { +if (bdrv_do_checkpoint (s->bs[i]) ==0 ) { +return 0 ; + } + } + +return -1 ; +} + +static int quorum_stop_replication (BlockDriverState *bs) +{ +BDRVQuorumState *s = bs->opaque; +int ret =-1 , i; + +for (i =0 ; i < s->num_children; i++) { +if (bdrv_stop_replication (s->bs[i]) ==0 ) { + ret++; + } + } + +return ret ?-1 :0 ; +} +static BlockDriver bdrv_quorum = { .format_name ="quorum" , .protocol_name ="quorum" ,
@@ -1093,6 +1158,10 @@ static BlockDriver bdrv_quorum = { .is_filter = true, .bdrv_recurse_is_first_non_filter = quorum_recurse_is_first_non_filter, + + .bdrv_start_replication = quorum_start_replication, + .bdrv_do_checkpoint = quorum_do_checkpoint, + .bdrv_stop_replication = quorum_stop_replication, };static void bdrv_quorum_init (void )
Signature · 1 line
2.1.0
Re: [Qemu-devel] [RFC PATCH 05/14] quorom: implement block driver interfaces for block replication
Quoted 12 lines · Wen Congyang
Signed-off-by Wen Congyang <[email protected]>Signed-off-by zhanghailiang <[email protected]>Signed-off-by Gonglei <[email protected]>--- block/quorum.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+)block/quorum.c +0
-0
block/quorum.c static void quorum_refresh_filename(BlockDriverState *bs) · line 1077
Quoted 8 lines
block/quorum.c +5
-0@@ -1070,6 +1070,71 @@ static void quorum_refresh_filename(BlockDriverState *bs) bs->full_open_options = opts; } +static int quorum_stop_replication (BlockDriverState *bs); +static int quorum_start_replication (BlockDriverState *bs,int mode) +{ +BDRVQuorumState *s = bs->opaque; +int ret =-1 , i;
Again, I'd prefer it if you used -errno (or the Error API).
Quoted 5 lines
block/quorum.c +5
-0+ +/* +* TODO: support COLO_SECONDARY_MODE if we allow secondary +* QEMU becoming primary QEMU. +*/
block/quorum.c static void quorum_refresh_filename(BlockDriverState *bs) · line 1092
Quoted 10 lines
block/quorum.c +10
-0+if (mode !=COLO_PRIMARY_MODE ) { +return -1 ; + } + +if (s->read_pattern !=QUORUM_READ_PATTERN_FIRST ) { +return -1 ; + } + +/* NBD client should not be the first child */ +if (bdrv_start_replication (s->bs[0 ], mode) ==0 ) {
If you allow the NBD client to be the first child you can probably drop this block (and start from "i = 0" in the for loop).
block/quorum.c static void quorum_refresh_filename(BlockDriverState *bs) · line 1105
Quoted 13 lines
block/quorum.c +13
-0+bdrv_stop_replication (s->bs[0 ]); +return -1 ; + } + +for (i =1 ; i < s->num_children; i++) { +if (bdrv_start_replication (s->bs[i], mode) ==0 ) { + ret++; + } + } + +if (ret >0 ) { +quorum_stop_replication (bs); + }
I think it would be easier to read if you had an additional "count" variable which is set to 0 before the for loop and then incremented (instead of ret). This would then be "if (count > 1)".
block/quorum.c static void quorum_refresh_filename(BlockDriverState *bs) · line 1107
Quoted 2 lines
block/quorum.c +2
-0+ +return ret ?-1 :0 ;
And this would be "return count == 0 ? 0 : -ENOTSUP" or something.
But apart from that, what's so bad about having multiple children which support bdrv_start_replication()? I mean, other than "It's not what we intended".
Max
Quoted 44 lines
block/quorum.c +34
-0+} + +static int quorum_do_checkpoint (BlockDriverState *bs) +{ +BDRVQuorumState *s = bs->opaque; +int i; + +for (i =1 ; i < s->num_children; i++) { +if (bdrv_do_checkpoint (s->bs[i]) ==0 ) { +return 0 ; + } + } + +return -1 ; +} + +static int quorum_stop_replication (BlockDriverState *bs) +{ +BDRVQuorumState *s = bs->opaque; +int ret =-1 , i; + +for (i =0 ; i < s->num_children; i++) { +if (bdrv_stop_replication (s->bs[i]) ==0 ) { + ret++; + } + } + +return ret ?-1 :0 ; +} +static BlockDriver bdrv_quorum = { .format_name ="quorum" , .protocol_name ="quorum" ,@@ -1093,6 +1158,10 @@ static BlockDriver bdrv_quorum = { .is_filter = true, .bdrv_recurse_is_first_non_filter = quorum_recurse_is_first_non_filter, + + .bdrv_start_replication = quorum_start_replication, + .bdrv_do_checkpoint = quorum_do_checkpoint, + .bdrv_stop_replication = quorum_stop_replication, };static void bdrv_quorum_init (void )
RFC PATCH 6/14 NBD client: connect to nbd server later
In reply to Wen CongyangThe secondary qemu starts later than the primary qemu, so we cannot connect to nbd server in bdrv_open().
--- block/nbd.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 87 insertions(+), 13 deletions(-)
block/nbd.c +87 -13
@@ -44,6 +44,8 @@typedef struct BDRVNBDState {NbdClientSession client;QemuOpts *socket_opts; +char *export; +bool connected; }BDRVNBDState ;static int nbd_parse_uri (const char *filename,QDict *options)
@@ -247,20 +249,10 @@ static int nbd_establish_connection(BlockDriverState *bs, Error **errp)return sock; } -static int nbd_open (BlockDriverState *bs,QDict *options,int flags, -Error **errp) +static int nbd_connect_server (BlockDriverState *bs,Error **errp) {BDRVNBDState *s = bs->opaque; -char *export =NULL ;int result, sock; -Error *local_err =NULL ; - -/* Pop the config into our state object. Exit if invalid. */ -nbd_config (s, options, &export, &local_err); -if (local_err) { -error_propagate (errp, local_err); -return -EINVAL ; - }/* establish TCP connection, return error if it fails * TODO: Configurable retry-until-timeout behaviour.
@@ -271,16 +263,57 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags, }/* NBD handshake */ - result =nbd_client_session_init (&s->client, bs, sock, export, errp); -g_free (export); + result =nbd_client_session_init (&s->client, bs, sock, s->export, errp); +g_free (s->export); + s->export =NULL ; +if (!result) { + s->connected = true; + } +return result; } +static int nbd_open (BlockDriverState *bs,QDict *options,int flags, +Error **errp) +{ +BDRVNBDState *s = bs->opaque; +Error *local_err =NULL ; + +/* Pop the config into our state object. Exit if invalid. */ +nbd_config (s, options, &s->export, &local_err); +if (local_err) { +error_propagate (errp, local_err); +return -EINVAL ; + } + +return nbd_connect_server (bs, errp); +} + +static int nbd_open_colo (BlockDriverState *bs,QDict *options,int flags, +Error **errp) +{ +BDRVNBDState *s = bs->opaque; +Error *local_err =NULL ; + +/* Pop the config into our state object. Exit if invalid. */ +nbd_config (s, options, &s->export, &local_err); +if (local_err) { +error_propagate (errp, local_err); +return -EINVAL ; + } + +return 0 ; +} +static int nbd_co_readv (BlockDriverState *bs,int64_t sector_num,int nb_sectors,QEMUIOVector *qiov) {BDRVNBDState *s = bs->opaque; +if (!s->connected) { +return -EIO ; + } +return nbd_client_session_co_readv (&s->client, sector_num, nb_sectors, qiov); }
@@ -290,6 +323,10 @@ static int nbd_co_writev(BlockDriverState *bs, int64_t sector_num, {BDRVNBDState *s = bs->opaque; +if (!s->connected) { +return 0 ; + } +return nbd_client_session_co_writev (&s->client, sector_num, nb_sectors, qiov); }
@@ -298,6 +335,10 @@ static int nbd_co_flush(BlockDriverState *bs) {BDRVNBDState *s = bs->opaque; +if (!s->connected) { +return 0 ; + } +return nbd_client_session_co_flush (&s->client); }
@@ -312,6 +353,10 @@ static int nbd_co_discard(BlockDriverState *bs, int64_t sector_num, {BDRVNBDState *s = bs->opaque; +if (!s->connected) { +return 0 ; + } +return nbd_client_session_co_discard (&s->client, sector_num, nb_sectors); }
@@ -322,6 +367,7 @@ static void nbd_close(BlockDriverState *bs)qemu_opts_del (s->socket_opts);nbd_client_session_close (&s->client); + s->connected = false; }static int64_t nbd_getlength (BlockDriverState *bs)
@@ -335,6 +381,10 @@ static void nbd_detach_aio_context(BlockDriverState *bs) {BDRVNBDState *s = bs->opaque; +if (!s->connected) { +return ; + } +nbd_client_session_detach_aio_context (&s->client); }
@@ -343,6 +393,10 @@ static void nbd_attach_aio_context(BlockDriverState *bs, {BDRVNBDState *s = bs->opaque; +if (!s->connected) { +return ; + } +nbd_client_session_attach_aio_context (&s->client, new_context); }
@@ -445,11 +499,31 @@ static BlockDriver bdrv_nbd_unix = { .bdrv_refresh_filename = nbd_refresh_filename, }; +static BlockDriver bdrv_nbd_colo = { + .format_name ="nbd+colo" , + .protocol_name ="nbd+colo" , + .instance_size =sizeof (BDRVNBDState), + .bdrv_parse_filename = nbd_parse_filename, + .bdrv_file_open = nbd_open_colo, + .bdrv_co_readv = nbd_co_readv, + .bdrv_co_writev = nbd_co_writev, + .bdrv_close = nbd_close, + .bdrv_co_flush_to_os = nbd_co_flush, + .bdrv_co_discard = nbd_co_discard, + .bdrv_getlength = nbd_getlength, + .bdrv_detach_aio_context = nbd_detach_aio_context, + .bdrv_attach_aio_context = nbd_attach_aio_context, + .bdrv_refresh_filename = nbd_refresh_filename, + + .has_variable_length = true, +}; +static void bdrv_nbd_init (void ) {bdrv_register (&bdrv_nbd);bdrv_register (&bdrv_nbd_tcp);bdrv_register (&bdrv_nbd_unix); +bdrv_register (&bdrv_nbd_colo); }block_init (bdrv_nbd_init);
Signature · 1 line
2.1.0
Re: [Qemu-devel] [RFC PATCH 06/14] NBD client: connect to nbd server later
Quoted 106 lines · Wen Congyang
The secondary qemu starts later than the primary qemu, so we cannot connect to nbd server in
bdrv_open().Signed-off-by Wen Congyang <[email protected]>Signed-off-by zhanghailiang <[email protected]>Signed-off-by Gonglei <[email protected]>--- block/nbd.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 87 insertions(+), 13 deletions(-)block/nbd.c +46
-13@@ -44,6 +44,8 @@typedef struct BDRVNBDState {NbdClientSession client;QemuOpts *socket_opts; +char *export; +bool connected; }BDRVNBDState ;static int nbd_parse_uri (const char *filename,QDict *options)@@ -247,20 +249,10 @@ static int nbd_establish_connection(BlockDriverState *bs, Error **errp)return sock; } -static int nbd_open (BlockDriverState *bs,QDict *options,int flags, -Error **errp) +static int nbd_connect_server (BlockDriverState *bs,Error **errp) {BDRVNBDState *s = bs->opaque; -char *export =NULL ;int result, sock; -Error *local_err =NULL ; - -/* Pop the config into our state object. Exit if invalid. */ -nbd_config (s, options, &export, &local_err); -if (local_err) { -error_propagate (errp, local_err); -return -EINVAL ; - }/* establish TCP connection, return error if it fails * TODO: Configurable retry-until-timeout behaviour. @@ -271,16 +263,57 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags, }/* NBD handshake */ - result =nbd_client_session_init (&s->client, bs, sock, export, errp); -g_free (export); + result =nbd_client_session_init (&s->client, bs, sock, s->export, errp); +g_free (s->export); + s->export =NULL ; +if (!result) { + s->connected = true; + } +return result; } +static int nbd_open (BlockDriverState *bs,QDict *options,int flags, +Error **errp) +{ +BDRVNBDState *s = bs->opaque; +Error *local_err =NULL ; + +/* Pop the config into our state object. Exit if invalid. */ +nbd_config (s, options, &s->export, &local_err); +if (local_err) { +error_propagate (errp, local_err); +return -EINVAL ; + } + +return nbd_connect_server (bs, errp); +} + +static int nbd_open_colo (BlockDriverState *bs,QDict *options,int flags, +Error **errp) +{ +BDRVNBDState *s = bs->opaque; +Error *local_err =NULL ; + +/* Pop the config into our state object. Exit if invalid. */ +nbd_config (s, options, &s->export, &local_err); +if (local_err) { +error_propagate (errp, local_err); +return -EINVAL ; + } + +return 0 ; +} +static int nbd_co_readv (BlockDriverState *bs,int64_t sector_num,int nb_sectors,QEMUIOVector *qiov) {BDRVNBDState *s = bs->opaque; +if (!s->connected) { +return -EIO ; + } +return nbd_client_session_co_readv (&s->client, sector_num, nb_sectors, qiov); }
block/nbd.c static int nbd_co_writev(BlockDriverState *bs, int64_t sector_num, · line 328
Quoted 6 lines
block/nbd.c +3
-0@@ -290,6 +323,10 @@ static int nbd_co_writev(BlockDriverState *bs, int64_t sector_num, {BDRVNBDState *s = bs->opaque; +if (!s->connected) { +return 0 ; + }
Would it break anything to return -EIO here as well? (And in all the following functions)
Quoted 27 lines
block/nbd.c +9
-0+return nbd_client_session_co_writev (&s->client, sector_num, nb_sectors, qiov); }@@ -298,6 +335,10 @@ static int nbd_co_flush(BlockDriverState *bs) {BDRVNBDState *s = bs->opaque; +if (!s->connected) { +return 0 ; + } +return nbd_client_session_co_flush (&s->client); }@@ -312,6 +353,10 @@ static int nbd_co_discard(BlockDriverState *bs, int64_t sector_num, {BDRVNBDState *s = bs->opaque; +if (!s->connected) { +return 0 ; + } +return nbd_client_session_co_discard (&s->client, sector_num, nb_sectors); }
block/nbd.c static void nbd_close(BlockDriverState *bs) · line 372
Quoted 6 lines
block/nbd.c +1
-0@@ -322,6 +367,7 @@ static void nbd_close(BlockDriverState *bs)qemu_opts_del (s->socket_opts);nbd_client_session_close (&s->client); + s->connected = false; }
As I proposed before, can you make nbd_getlength() return -ENOTCONN or something unique in case s->connected is false? I think that'd be better than returning 0 (which is a valid value).
Max
Quoted 55 lines
block/nbd.c +28
-0static int64_t nbd_getlength (BlockDriverState *bs)@@ -335,6 +381,10 @@ static void nbd_detach_aio_context(BlockDriverState *bs) {BDRVNBDState *s = bs->opaque; +if (!s->connected) { +return ; + } +nbd_client_session_detach_aio_context (&s->client); }@@ -343,6 +393,10 @@ static void nbd_attach_aio_context(BlockDriverState *bs, {BDRVNBDState *s = bs->opaque; +if (!s->connected) { +return ; + } +nbd_client_session_attach_aio_context (&s->client, new_context); }@@ -445,11 +499,31 @@ static BlockDriver bdrv_nbd_unix = { .bdrv_refresh_filename = nbd_refresh_filename, }; +static BlockDriver bdrv_nbd_colo = { + .format_name ="nbd+colo" , + .protocol_name ="nbd+colo" , + .instance_size =sizeof (BDRVNBDState), + .bdrv_parse_filename = nbd_parse_filename, + .bdrv_file_open = nbd_open_colo, + .bdrv_co_readv = nbd_co_readv, + .bdrv_co_writev = nbd_co_writev, + .bdrv_close = nbd_close, + .bdrv_co_flush_to_os = nbd_co_flush, + .bdrv_co_discard = nbd_co_discard, + .bdrv_getlength = nbd_getlength, + .bdrv_detach_aio_context = nbd_detach_aio_context, + .bdrv_attach_aio_context = nbd_attach_aio_context, + .bdrv_refresh_filename = nbd_refresh_filename, + + .has_variable_length = true, +}; +static void bdrv_nbd_init (void ) {bdrv_register (&bdrv_nbd);bdrv_register (&bdrv_nbd_tcp);bdrv_register (&bdrv_nbd_unix); +bdrv_register (&bdrv_nbd_colo); }block_init (bdrv_nbd_init);
Re: [Qemu-devel] [RFC PATCH 06/14] NBD client: connect to nbd server later
Quoted 100 lines · Max Reitz
Quoted 99 lines · Wen Congyang
The secondary qemu starts later than the primary qemu, so we cannot connect to nbd server in
bdrv_open().Signed-off-by Wen Congyang <[email protected]>Signed-off-by zhanghailiang <[email protected]>Signed-off-by Gonglei <[email protected]>--- block/nbd.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 87 insertions(+), 13 deletions(-)block/nbd.c +44
-12@@ -44,6 +44,8 @@typedef struct BDRVNBDState {NbdClientSession client;QemuOpts *socket_opts; +char *export; +bool connected; }BDRVNBDState ;static int nbd_parse_uri (const char *filename,QDict *options)@@ -247,20 +249,10 @@ static int nbd_establish_connection(BlockDriverState *bs, Error **errp)return sock; } -static int nbd_open(BlockDriverState *bs, QDict *options, int flags, -Error **errp) +static int nbd_connect_server(BlockDriverState *bs, Error **errp) {BDRVNBDState *s = bs->opaque; -char *export =NULL ;int result, sock; -Error *local_err =NULL ; - -/* Pop the config into our state object. Exit if invalid. */ -nbd_config (s, options, &export, &local_err); -if (local_err) { -error_propagate (errp, local_err); -return -EINVAL ; - }/* establish TCP connection, return error if it fails * TODO: Configurable retry-until-timeout behaviour. @@ -271,16 +263,57 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags, }/* NBD handshake */ - result =nbd_client_session_init (&s->client, bs, sock, export, errp); -g_free (export); + result =nbd_client_session_init (&s->client, bs, sock, s->export, errp); +g_free (s->export); + s->export =NULL ; +if (!result) { + s->connected = true; + } +return result; } +static int nbd_open(BlockDriverState *bs, QDict *options, int flags, +Error **errp) +{ +BDRVNBDState *s = bs->opaque; +Error *local_err =NULL ; + +/* Pop the config into our state object. Exit if invalid. */ +nbd_config (s, options, &s->export, &local_err); +if (local_err) { +error_propagate (errp, local_err); +return -EINVAL ; + } + +return nbd_connect_server (bs, errp); +} + +static int nbd_open_colo (BlockDriverState *bs,QDict *options,int flags, +Error **errp) +{ +BDRVNBDState *s = bs->opaque; +Error *local_err =NULL ; + +/* Pop the config into our state object. Exit if invalid. */ +nbd_config (s, options, &s->export, &local_err); +if (local_err) { +error_propagate (errp, local_err); +return -EINVAL ; + } + +return 0 ; +} +static int nbd_co_readv (BlockDriverState *bs,int64_t sector_num,int nb_sectors,QEMUIOVector *qiov) {BDRVNBDState *s = bs->opaque; + if (!s->connected) { +return -EIO ; + } +return nbd_client_session_co_readv (&s->client, sector_num, nb_sectors, qiov); }
Quoted 8 lines
block/nbd.c static int nbd_co_writev(BlockDriverState *bs, int64_t sector_num, · line 327
Quoted 6 lines
block/nbd.c +2
-0@@ -290,6 +323,10 @@ static int nbd_co_writev(BlockDriverState *bs, int64_t sector_num, {BDRVNBDState *s = bs->opaque; + if (!s->connected) { +return 0 ; + }Would it break anything to return
-EIOhere as well? (And in all the following functions)
1. nbd_co_writev()
If one child returns error, quorum will report it. There may be many write requests before we connect to nbd server, so there are too many qapi events...
2. nbd_co_flush()
If quorum only have two children, and nbd client is the last one, quorum_co_flush() will return -EIO.
3. nbd_co_discard()
quorum doens't call bdrv_co_discard(), so it is OK to return -EIO here.
So only nbd_co_discard() can return -EIO.
Thanks
Wen Congyang
Quoted 31 lines
Quoted 30 lines
block/nbd.c +8
-0+return nbd_client_session_co_writev (&s->client, sector_num, nb_sectors, qiov); }@@ -298,6 +335,10 @@ static int nbd_co_flush(BlockDriverState *bs) {BDRVNBDState *s = bs->opaque; + if (!s->connected) { +return 0 ; + } +return nbd_client_session_co_flush (&s->client); } @@ -312,6 +353,10 @@ static int nbd_co_discard(BlockDriverState *bs, int64_t sector_num, { BDRVNBDState *s = bs->opaque; + if (!s->connected) { +return 0 ; + } +return nbd_client_session_co_discard (&s->client, sector_num, nb_sectors); }@@ -322,6 +367,7 @@ static void nbd_close(BlockDriverState *bs)qemu_opts_del (s->socket_opts);nbd_client_session_close (&s->client); + s->connected = false; }
Re: [Qemu-devel] [RFC PATCH 06/14] NBD client: connect to nbd server later
Quoted 117 lines · Wen Congyang
Quoted 99 lines · Max Reitz
Quoted 98 lines · Wen Congyang
The secondary qemu starts later than the primary qemu, so we cannot connect to nbd server in
bdrv_open().Signed-off-by Wen Congyang <[email protected]>Signed-off-by zhanghailiang <[email protected]>Signed-off-by Gonglei <[email protected]>--- block/nbd.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 87 insertions(+), 13 deletions(-)block/nbd.c +44
-12@@ -44,6 +44,8 @@typedef struct BDRVNBDState {NbdClientSession client;QemuOpts *socket_opts; +char *export; +bool connected; }BDRVNBDState ;static int nbd_parse_uri (const char *filename,QDict *options)@@ -247,20 +249,10 @@ static int nbd_establish_connection(BlockDriverState *bs, Error **errp)return sock; } -static int nbd_open(BlockDriverState *bs, QDict *options, int flags, -Error **errp) +static int nbd_connect_server(BlockDriverState *bs, Error **errp) {BDRVNBDState *s = bs->opaque; -char *export =NULL ;int result, sock; -Error *local_err =NULL ; - -/* Pop the config into our state object. Exit if invalid. */ -nbd_config (s, options, &export, &local_err); -if (local_err) { -error_propagate (errp, local_err); -return -EINVAL ; - }/* establish TCP connection, return error if it fails * TODO: Configurable retry-until-timeout behaviour. @@ -271,16 +263,57 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags, }/* NBD handshake */ - result =nbd_client_session_init (&s->client, bs, sock, export, errp); -g_free (export); + result =nbd_client_session_init (&s->client, bs, sock, s->export, errp); +g_free (s->export); + s->export =NULL ; +if (!result) { + s->connected = true; + } +return result; } +static int nbd_open(BlockDriverState *bs, QDict *options, int flags, +Error **errp) +{ +BDRVNBDState *s = bs->opaque; +Error *local_err =NULL ; + +/* Pop the config into our state object. Exit if invalid. */ +nbd_config (s, options, &s->export, &local_err); +if (local_err) { +error_propagate (errp, local_err); +return -EINVAL ; + } + +return nbd_connect_server (bs, errp); +} + +static int nbd_open_colo (BlockDriverState *bs,QDict *options,int flags, +Error **errp) +{ +BDRVNBDState *s = bs->opaque; +Error *local_err =NULL ; + +/* Pop the config into our state object. Exit if invalid. */ +nbd_config (s, options, &s->export, &local_err); +if (local_err) { +error_propagate (errp, local_err); +return -EINVAL ; + } + +return 0 ; +} +static int nbd_co_readv (BlockDriverState *bs,int64_t sector_num,int nb_sectors,QEMUIOVector *qiov) {BDRVNBDState *s = bs->opaque; + if (!s->connected) { +return -EIO ; + } +return nbd_client_session_co_readv (&s->client, sector_num, nb_sectors, qiov);Quoted 8 lines
block/nbd.c static int nbd_co_writev(BlockDriverState *bs, int64_t sector_num, · line 327
Quoted 7 lines
block/nbd.c +2
-0}@@ -290,6 +323,10 @@ static int nbd_co_writev(BlockDriverState *bs, int64_t sector_num, {BDRVNBDState *s = bs->opaque; + if (!s->connected) { +return 0 ; + }Would it break anything to return
-EIOhere as well? (And in all the following functions)1.
nbd_co_writev()
If one child returns error, quorum will report it. There may be many write requests before we connect to nbd server, so there are too many qapi events...
2.nbd_co_flush()
If quorum only have two children, and nbd client is the last one,quorum_co_flush()will return-EIO.
3.nbd_co_discard()
quorum doens't callbdrv_co_discard(), so it is OK to return-EIOhere.
Quoted 1 line
So only
nbd_co_discard()can return-EIO.
Hm, okay. How about adding an option to quorum for ignoring errors from a specific child? It's probably not possible to do something like "children.1.ignore-errors=true", but maybe you can just ignore errors in quorum from any but the first child if the read pattern is set to "first", that would make sense to me.
But if you don't want to do that, I guess just making NBD some kind of /dev/null before it's connected should be fine.
Max
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
block/nbd.c +8
-0+return nbd_client_session_co_writev (&s->client, sector_num, nb_sectors, qiov); }@@ -298,6 +335,10 @@ static int nbd_co_flush(BlockDriverState *bs) {BDRVNBDState *s = bs->opaque; + if (!s->connected) { +return 0 ; + } +return nbd_client_session_co_flush (&s->client); } @@ -312,6 +353,10 @@ static int nbd_co_discard(BlockDriverState *bs, int64_t sector_num, { BDRVNBDState *s = bs->opaque; + if (!s->connected) { +return 0 ; + } +return nbd_client_session_co_discard (&s->client, sector_num, nb_sectors); }@@ -322,6 +367,7 @@ static void nbd_close(BlockDriverState *bs)qemu_opts_del (s->socket_opts);nbd_client_session_close (&s->client); + s->connected = false; }
Re: [Qemu-devel] [RFC PATCH 06/14] NBD client: connect to nbd server later
Quoted 2 lines · Max Reitz
3.
nbd_co_discard()
quorum doens't callbdrv_co_discard(), so it is OK to return-EIOhere.
That can change, so I think you should return -EIO either everywhere or nowhere. Which probably means nowhere.
Quoted 8 lines
Hm, okay. How about adding an option to quorum for ignoring errors from a specific child? It's probably not possible to do something like "children.1.ignore-errors=true", but maybe you can just ignore errors in quorum from any but the first child if the read pattern is set to "first", that would make sense to me.
But if you don't want to do that, I guess just making NBD some kind of
/dev/nullbefore it's connected should be fine.
I think what Wen is doing is okay, especially since it's only the special nbd+colo:// URIs that are acting as /dev/null.
Paolo
RFC PATCH 7/14 NBD client: implement block driver interfaces for block replication
In reply to Wen Congyang--- block/nbd.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+)
block/nbd.c +55 -0
@@ -445,6 +445,58 @@ static void nbd_refresh_filename(BlockDriverState *bs) bs->full_open_options = opts; } +static int nbd_start_replication (BlockDriverState *bs,int mode) +{ +BDRVNBDState *s = bs->opaque; +Error *local_err =NULL ; +int ret; + +/* +* TODO: support COLO_SECONDARY_MODE if we allow secondary +* QEMU becoming primary QEMU. +*/ +if (mode !=COLO_PRIMARY_MODE ) { +return -1 ; + } + +if (s->connected) { +return -1 ; + } + +/* TODO: NBD client should be one child of quorum, how to verify it? */ + ret =nbd_connect_server (bs, &local_err); +if (local_err) { +error_free (local_err); + } + +return ret; +} + +static int nbd_do_checkpoint (BlockDriverState *bs) +{ +BDRVNBDState *s = bs->opaque; + +if (!s->connected) { +return -1 ; + } + +return 0 ; +} + +static int nbd_stop_replication (BlockDriverState *bs) +{ +BDRVNBDState *s = bs->opaque; + +if (!s->connected) { +return -1 ; + } + +nbd_client_session_close (&s->client); + s->connected = false; + +return 0 ; +} +static BlockDriver bdrv_nbd = { .format_name ="nbd" , .protocol_name ="nbd" ,
@@ -514,6 +566,9 @@ static BlockDriver bdrv_nbd_colo = { .bdrv_detach_aio_context = nbd_detach_aio_context, .bdrv_attach_aio_context = nbd_attach_aio_context, .bdrv_refresh_filename = nbd_refresh_filename, + .bdrv_start_replication = nbd_start_replication, + .bdrv_do_checkpoint = nbd_do_checkpoint, + .bdrv_stop_replication = nbd_stop_replication, .has_variable_length = true, };
Signature · 1 line
2.1.0
Re: [Qemu-devel] [RFC PATCH 07/14] NBD client: implement block driver interfaces for block replication
Quoted 6 lines · Wen Congyang
Signed-off-by Wen Congyang <[email protected]>Signed-off-by zhanghailiang <[email protected]>Signed-off-by Gonglei <[email protected]>--- block/nbd.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+)
So by now to me it looks like you're using bdrv_start_replication() on the primary VM to start transferring data through the NBD connection to the secondary VM.
I guess this is what you were discussing with Fam and John, whether there'd be a better way to do it by using functionality that is already (or is about to become) part of qemu, right?
Quoted 10 lines
block/nbd.c +2
-0@@ -445,6 +445,58 @@ static void nbd_refresh_filename(BlockDriverState *bs) bs->full_open_options = opts; } +static int nbd_start_replication (BlockDriverState *bs,int mode) +{
block/nbd.c static void nbd_refresh_filename(BlockDriverState *bs) · line 459
Quoted 10 lines
block/nbd.c +10
-0+BDRVNBDState *s = bs->opaque; +Error *local_err =NULL ; +int ret; + +/* +* TODO: support COLO_SECONDARY_MODE if we allow secondary +* QEMU becoming primary QEMU. +*/ +if (mode !=COLO_PRIMARY_MODE ) { +return -1 ;
Once again, I'd like -ENOTSUP more (or -EINVAL or whatever you prefer).
block/nbd.c static void nbd_refresh_filename(BlockDriverState *bs) · line 466
Quoted 7 lines
block/nbd.c +7
-0+ } + +if (s->connected) { +return -1 ; + } + +/* TODO: NBD client should be one child of quorum, how to verify it? */
Again, why would you care about that? Other than "It's how it's intended to be used".
block/nbd.c static void nbd_refresh_filename(BlockDriverState *bs) · line 470
Quoted 4 lines
block/nbd.c +4
-0+ ret =nbd_connect_server (bs, &local_err); +if (local_err) { +error_free (local_err); + }
If you'd use the Error API you'd be able to propagate the error.
Max
Quoted 42 lines
block/nbd.c +32
-0+ +return ret; +} + +static int nbd_do_checkpoint (BlockDriverState *bs) +{ +BDRVNBDState *s = bs->opaque; + +if (!s->connected) { +return -1 ; + } + +return 0 ; +} + +static int nbd_stop_replication (BlockDriverState *bs) +{ +BDRVNBDState *s = bs->opaque; + +if (!s->connected) { +return -1 ; + } + +nbd_client_session_close (&s->client); + s->connected = false; + +return 0 ; +} +static BlockDriver bdrv_nbd = { .format_name ="nbd" , .protocol_name ="nbd" ,@@ -514,6 +566,9 @@ static BlockDriver bdrv_nbd_colo = { .bdrv_detach_aio_context = nbd_detach_aio_context, .bdrv_attach_aio_context = nbd_attach_aio_context, .bdrv_refresh_filename = nbd_refresh_filename, + .bdrv_start_replication = nbd_start_replication, + .bdrv_do_checkpoint = nbd_do_checkpoint, + .bdrv_stop_replication = nbd_stop_replication, .has_variable_length = true, };
Re: [Qemu-devel] [RFC PATCH 07/14] NBD client: implement block driver interfaces for block replication
Quoted 16 lines · Max Reitz
Quoted 4 lines
} +static int nbd_start_replication(BlockDriverState *bs, int mode)block/nbd.c +1
-0+{block/nbd.c static void nbd_refresh_filename(BlockDriverState *bs) · line 459
Quoted 10 lines
block/nbd.c +10
-0+BDRVNBDState *s = bs->opaque; +Error *local_err =NULL ; +int ret; + +/* +* TODO: support COLO_SECONDARY_MODE if we allow secondary +* QEMU becoming primary QEMU. +*/ +if (mode !=COLO_PRIMARY_MODE ) { +return -1 ;Once again, I'd like
-ENOTSUPmore (or-EINVALor whatever you prefer).
Using the Error API is the right thing to do here.
Paolo
RFC PATCH 8/14 block: add a new API to create a hidden BlockBackend
In reply to Wen Congyang--- block/block-backend.c | 29 ++++++++++++++++++++++++++++- include/sysemu/block-backend.h | 2 ++ 2 files changed, 30 insertions(+), 1 deletion(-)
block/block-backend.c +28 -1
@@ -72,6 +72,19 @@ BlockBackend *blk_new(const char *name, Error **errp) }/* +* Create a new hidden BlockBackend, with a reference count of one. +* Return the new BlockBackend on success, null on failure. +*/ +BlockBackend *blk_hide_new (void ) +{ +BlockBackend *blk; + + blk =g_new0 (BlockBackend,1 ); + blk->refcnt =1 ; +return blk; +} + +/* * Create a new BlockBackend with a new BlockDriverState attached. * Otherwise just like blk_new(), which see. */
@@ -91,6 +104,20 @@ BlockBackend *blk_new_with_bs(const char *name, Error **errp)return blk; } +/* +* Create a new hidden BlockBackend with a new BlockDriverState attached. +* Otherwise just like blk_hide_new(), which see. +*/ +BlockBackend *blk_hide_new_with_bs (void ) +{ +BlockBackend *blk =blk_hide_new (); +BlockDriverState *bs =bdrv_new (); + + blk->bs = bs; + bs->blk = blk; +return blk; +} +static void blk_delete (BlockBackend *blk) {assert (!blk->refcnt);
@@ -102,7 +129,7 @@ static void blk_delete(BlockBackend *blk) blk->bs =NULL ; }/* Avoid double-remove after blk_hide_on_behalf_of_do_drive_del() */ -if (blk->name[0 ]) { +if (blk->name && blk->name[0 ]) {QTAILQ_REMOVE (&blk_backends, blk, link); }g_free (blk->name);
include/sysemu/block-backend.h +2 -0
@@ -61,7 +61,9 @@ typedef struct BlockDevOps { } BlockDevOps;BlockBackend *blk_new (const char *name,Error **errp); +BlockBackend *blk_hide_new (void );BlockBackend *blk_new_with_bs (const char *name,Error **errp); +BlockBackend *blk_hide_new_with_bs (void );void blk_ref (BlockBackend *blk);void blk_unref (BlockBackend *blk);const char *blk_name (BlockBackend *blk);
Signature · 1 line
2.1.0
Re: [Qemu-devel] [RFC PATCH 08/14] block: add a new API to create a hidden BlockBackend
Quoted 7 lines · Wen Congyang
Signed-off-by Wen Congyang <[email protected]>Signed-off-by zhanghailiang <[email protected]>Signed-off-by Gonglei <[email protected]>--- block/block-backend.c | 29 ++++++++++++++++++++++++++++- include/sysemu/block-backend.h | 2 ++ 2 files changed, 30 insertions(+), 1 deletion(-)
Hm, I'm currently working on a series that (among other things) separate the list of monitor-owned BlockBackends and the list of all BBs. That should be helpful here; but Paolo said it might not be necessary to create a BB at all, so... Maybe he's right. I'll have to look into the remaining patches first.
Max
RFC PATCH 9/14 block: give backing image its own BlockBackend
In reply to Wen Congyang--- block.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
block.c +7 -4
@@ -1218,6 +1218,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp) {char *backing_filename =g_malloc0 (PATH_MAX );int ret =0 ; +BlockBackend *backing_blk;BlockDriverState *backing_hd;Error *local_err =NULL ;
@@ -1255,7 +1256,8 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp) goto free_exit; } - backing_hd =bdrv_new (); + backing_blk =blk_hide_new_with_bs (); + backing_hd =blk_bs (backing_blk);if (bs->backing_format[0 ] !='\0' && !qdict_haskey (options,"driver" )) {qdict_put (options,"driver" ,qstring_from_str (bs->backing_format));
@@ -1266,7 +1268,8 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp) *backing_filename ? backing_filename :NULL ,NULL , options, bdrv_backing_flags(bs->open_flags), NULL, &local_err);if (ret <0 ) { -bdrv_unref (backing_hd); +blk_unref (backing_blk); + backing_blk =NULL ; backing_hd =NULL ; bs->open_flags |=BDRV_O_NO_BACKING ; error_setg(errp, "Could not open backing file: %s",
@@ -1870,9 +1873,9 @@ void bdrv_close(BlockDriverState *bs)if (bs->drv) {if (bs->backing_hd) { -BlockDriverState *backing_hd = bs->backing_hd; +BlockBackend *backing_blk = bs->backing_hd->blk;bdrv_set_backing_hd (bs,NULL ); -bdrv_unref (backing_hd); +blk_unref (backing_blk); } bs->drv->bdrv_close (bs);g_free (bs->opaque);
Signature · 1 line
2.1.0
Re: [Qemu-devel] [RFC PATCH 09/14] block: give backing image its own BlockBackend
Quoted 6 lines · Wen Congyang
Signed-off-by Wen Congyang <[email protected]>Signed-off-by zhanghailiang <[email protected]>Signed-off-by Gonglei <[email protected]>--- block.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
Our current stance on BlockBackends is (as far as I know, anyway) that a BlockBackend always comes with a user. In case you're creating a BlockBackend through -drive or blockdev-add, the user is the monitor (which can use it to attach it to a device, for instance). In this case, there is no user and nobody holds a reference to the BB (other than the BDS, but that doesn't count).
Therefore, this patch doesn't look quite right.
Max
RFC PATCH 10/14 allow the backing image access the origin BlockDriverState
In reply to Wen CongyangBlock replication needs this feature.
--- block.c | 2 ++ include/block/block_int.h | 2 ++ 2 files changed, 4 insertions(+)
block.c +2 -0
@@ -1181,6 +1181,7 @@ void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd)if (bs->backing_hd) {assert (bs->backing_blocker);bdrv_op_unblock_all (bs->backing_hd, bs->backing_blocker); + bs->backing_hd->origin_file =NULL ; }else if (backing_hd) { error_setg(&bs->backing_blocker, "device is used as backing hd of '%s'",
@@ -1193,6 +1194,7 @@ void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd) bs->backing_blocker =NULL ; goto out; } + backing_hd->origin_file = bs; bs->open_flags &= ~BDRV_O_NO_BACKING ;pstrcpy (bs->backing_file,sizeof (bs->backing_file), backing_hd->filename); pstrcpy(bs->backing_format, sizeof(bs->backing_format),
include/block/block_int.h +2 -0
@@ -360,6 +360,8 @@ struct BlockDriverState {char exact_filename[PATH_MAX ];BlockDriverState *backing_hd; +/* used by backing image */ +BlockDriverState *origin_file;BlockDriverState *file;NotifierList close_notifiers;
Signature · 1 line
2.1.0
Re: [Qemu-devel] [RFC PATCH 10/14] allow the backing image access the origin BlockDriverState
Quoted 15 lines · Wen Congyang
Block replication needs this feature.
Signed-off-by Wen Congyang <[email protected]>Signed-off-by zhanghailiang <[email protected]>Signed-off-by Gonglei <[email protected]>--- block.c | 2 ++ include/block/block_int.h | 2 ++ 2 files changed, 4 insertions(+)block.c +0
-0
block.c void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd) · line 1184
Quoted 4 lines
block.c +1
-0@@ -1181,6 +1181,7 @@ void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd)if (bs->backing_hd) {assert (bs->backing_blocker);bdrv_op_unblock_all (bs->backing_hd, bs->backing_blocker); + bs->backing_hd->origin_file =NULL ;
Seems more like "backed_file" to me. Can you explain to me where "origin file" comes from?
Since apparently one BDS can be used as a backing file by only at most one other BDS, the patch seems fine to me (other than the naming issue).
Max
Quoted 24 lines
block.c +1
-0}else if (backing_hd) { error_setg(&bs->backing_blocker, "device is used as backing hd of '%s'",@@ -1193,6 +1194,7 @@ void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd) bs->backing_blocker =NULL ; goto out; } + backing_hd->origin_file = bs; bs->open_flags &= ~BDRV_O_NO_BACKING ;pstrcpy (bs->backing_file,sizeof (bs->backing_file), backing_hd->filename); pstrcpy(bs->backing_format, sizeof(bs->backing_format),include/block/block_int.h +2
-0@@ -360,6 +360,8 @@ struct BlockDriverState {char exact_filename[PATH_MAX ];BlockDriverState *backing_hd; +/* used by backing image */ +BlockDriverState *origin_file;BlockDriverState *file;NotifierList close_notifiers;
RFC PATCH 11/14 allow writing to the backing file
In reply to Wen Congyang--- block.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
block.c +2 -2
@@ -856,8 +856,8 @@ static int bdrv_inherited_flags(int flags)*/ static int bdrv_backing_flags (int flags) { -/* backing files always opened read-only */ - flags &= ~(BDRV_O_RDWR |BDRV_O_COPY_ON_READ ); +/* backing files are opened read-write for block replication */ + flags &= ~BDRV_O_COPY_ON_READ ;/* snapshot=on is handled on the top layer */ flags &= ~(BDRV_O_SNAPSHOT |BDRV_O_TEMPORARY );
Signature · 1 line
2.1.0
Re: [Qemu-devel] [RFC PATCH 11/14] allow writing to the backing file
Quoted 6 lines · Wen Congyang
Signed-off-by Wen Congyang <[email protected]>Signed-off-by zhanghailiang <[email protected]>Signed-off-by Gonglei <[email protected]>--- block.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
I don't think this is a good idea. With this patch, every time you open a COW file (with a backing file) R/W, the backing file will be writable. I'd rather like a way to explicitly overwrite the R/W mode of the backing file; but by default, in my opinion, it should stay read-only.
Max
Quoted 15 lines
block.c +2
-2@@ -856,8 +856,8 @@ static int bdrv_inherited_flags(int flags)*/ static int bdrv_backing_flags (int flags) { -/* backing files always opened read-only */ - flags &= ~(BDRV_O_RDWR |BDRV_O_COPY_ON_READ ); +/* backing files are opened read-write for block replication */ + flags &= ~BDRV_O_COPY_ON_READ ;/* snapshot=on is handled on the top layer */ flags &= ~(BDRV_O_SNAPSHOT |BDRV_O_TEMPORARY );
Re: [Qemu-devel] [RFC PATCH 11/14] allow writing to the backing file
Quoted 8 lines · Max Reitz
Quoted 6 lines · Wen Congyang
Signed-off-by Wen Congyang <[email protected]>Signed-off-by zhanghailiang <[email protected]>Signed-off-by Gonglei <[email protected]>--- block.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 4 lines
I don't think this is a good idea. With this patch, every time you open a COW file (with a backing file) R/W, the backing file will be writable. I'd rather like a way to explicitly overwrite the R/W mode of the backing file; but by default, in my opinion, it should stay read-only.
I agree.
Perhaps blkcolo_open or colo_svm_init can take care of setting BDRV_O_RDWR on the backing file? They could also use bdrv_reopen.
Paolo
Quoted 17 lines
Max
Quoted 14 lines
block.c +2
-2@@ -856,8 +856,8 @@ static int bdrv_inherited_flags(int flags)*/ static int bdrv_backing_flags (int flags) { -/* backing files always opened read-only */ - flags &= ~(BDRV_O_RDWR |BDRV_O_COPY_ON_READ ); +/* backing files are opened read-write for block replication */ + flags &= ~BDRV_O_COPY_ON_READ ;/* snapshot=on is handled on the top layer */ flags &= ~(BDRV_O_SNAPSHOT |BDRV_O_TEMPORARY );
RFC PATCH 12/14 Add disk buffer for block replication
In reply to Wen Congyang--- block/Makefile.objs | 1 + block/blkcolo-buffer.c | 324 +++++++++++++++++++++++++++++++++++++++++++++++++ block/blkcolo.h | 35 ++++++ 3 files changed, 360 insertions(+) create mode 100644 block/blkcolo-buffer.c create mode 100644 block/blkcolo.h
block/Makefile.objs +1 -0
@@ -21,6 +21,7 @@ block-obj-$(CONFIG_ARCHIPELAGO) += archipelago.o block-obj-$(CONFIG_LIBSSH2) += ssh.o block-obj-y += accounting.o block-obj-y += write-threshold.o +block-obj-y += blkcolo-buffer.o common-obj-y += stream.o common-obj-y += commit.o
block/blkcolo-buffer.c new file +324 -0
324 lines not on this page · raw message
block/blkcolo.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* Block driver for COLO +* +* Copyright Fujitsu, Corp. 2015 +* Copyright (c) 2015 Intel Corporation +* Copyright (c) 2015 HUAWEI TECHNOLOGIES CO.,LTD. +* +* Authors: +* Wen Congyang <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* +*/ + +#ifndef BLOCK_BLKCOLO_H +#define BLOCK_BLKCOLO_H + +typedef struct disk_buffer { + QSIMPLEQ_HEAD(, buffered_request_state) head; +}disk_buffer ; + +bool buffer_has_empty_range (disk_buffer *disk_buffer, +uint64_t sector,int nb_sectors); +void qiov_read_from_buffer (disk_buffer *disk_buffer,QEMUIOVector *qiov, +uint64_t sector,int nb_sectors); +void qiov_write_to_buffer (disk_buffer *disk_buffer,QEMUIOVector *qiov, +uint64_t sector,int nb_sectors,bool overwrite); +void flush_buffered_data_to_disk (disk_buffer *disk_buffer, +BlockDriverState *bs); + +void init_disk_buffer (disk_buffer *disk_buffer); +void clear_all_buffered_data (disk_buffer *disk_buffer); + +#endif
Signature · 1 line
2.1.0
Re: [Qemu-devel] [RFC PATCH 12/14] Add disk buffer for block replication
Quoted 10 lines · Wen Congyang
Signed-off-by Wen Congyang <[email protected]>Signed-off-by zhanghailiang <[email protected]>Signed-off-by Gonglei <[email protected]>--- block/Makefile.objs | 1 + block/blkcolo-buffer.c | 324 +++++++++++++++++++++++++++++++++++++++++++++++++ block/blkcolo.h | 35 ++++++ 3 files changed, 360 insertions(+)create mode 100644
block/blkcolo-buffer.c
create mode 100644block/blkcolo.h
In general: Can you please add some prefix to the non-static functions, like colo_*?
As for the design questions regarding this block driver, I should probably leave that to Fam and John (because they seemed to have an idea how to approach the issue at hand using a different implementation, based on functionality that's already (or close to become) part of qemu).
Therefore, I'm hesitating to review this patch (and the following ones) until you've reached a conclusion on how to proceed.
Max
RFC PATCH 13/14 COW: move cow interfaces to a seperate file
In reply to Wen Congyang--- Makefile.objs | 2 +- block/backup.c | 52 ++++----------------------------------------------- blockcow.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/block/block.h | 17 +++++++++++++++++ 4 files changed, 74 insertions(+), 49 deletions(-) create mode 100644 blockcow.c
Makefile.objs +1 -1
@@ -7,7 +7,7 @@ util-obj-y = util/ qobject/ qapi/ qapi-types.o qapi-visit.o qapi-event.o # block-obj-y is code used by both qemu system emulation and qemu-img block-obj-y = async.o thread-pool.o -block-obj-y += nbd.o block.o blockjob.o +block-obj-y += nbd.o block.o blockjob.o blockcow.o block-obj-y += main-loop.o iohandler.o qemu-timer.o block-obj-$(CONFIG_POSIX) += aio-posix.o block-obj-$(CONFIG_WIN32) += aio-win32.o
block/backup.c +4 -48
78 lines not on this page · raw message
blockcow.c new file +52 -0
52 lines not on this page · raw message
include/block/block.h +17 -0
@@ -567,4 +567,21 @@ int bdrv_start_replication(BlockDriverState *bs, int mode);int bdrv_do_checkpoint (BlockDriverState *bs);int bdrv_stop_replication (BlockDriverState *bs); +typedef struct CowRequest { +int64_t start; +int64_t end; +QLIST_ENTRY (CowRequest) list; +CoQueue wait_queue;/* coroutines blocked on this request */ +}CowRequest ; + +typedef struct CowJob { + QLIST_HEAD(, CowRequest) inflight_reqs; +}CowJob ; + +void coroutine_fn +wait_for_overlapping_requests (CowJob *job,int64_t start,int64_t end); +void cow_request_begin (CowRequest *req,CowJob *job, +int64_t start,int64_t end); +void cow_request_end (CowRequest *req); +#endif
Signature · 1 line
2.1.0
RFC PATCH 14/14 COLO: implement a new block driver
In reply to Wen Congyang--- block/Makefile.objs | 2 +- block/blkcolo.c | 409 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 410 insertions(+), 1 deletion(-) create mode 100644 block/blkcolo.c
block/Makefile.objs +1 -1
@@ -21,7 +21,7 @@ block-obj-$(CONFIG_ARCHIPELAGO) += archipelago.o block-obj-$(CONFIG_LIBSSH2) += ssh.o block-obj-y += accounting.o block-obj-y += write-threshold.o -block-obj-y += blkcolo-buffer.o +block-obj-y += blkcolo-buffer.o blkcolo.o common-obj-y += stream.o common-obj-y += commit.o
block/blkcolo.c new file +409 -0
409 lines not on this page · raw message
Signature · 1 line
2.1.0
Re: [Qemu-devel] [RFC PATCH 14/14] COLO: implement a new block driver
Quoted 8 lines · Wen Congyang
Signed-off-by Wen Congyang <[email protected]>Signed-off-by zhanghailiang <[email protected]>Signed-off-by Gonglei <[email protected]>--- block/Makefile.objs | 2 +- block/blkcolo.c | 409 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 410 insertions(+), 1 deletion(-)create mode 100644
block/blkcolo.c
Seeing what you want to use the BlockBackend for (which is, set up an NBD server): I think it's best to create the BlockBackend the moment the NBD server is created, and destroy it the moment the NBD server is stopped (that is, create it in colo_svm_init() and destroy it in colo_svm_fini()).
Max
Quoted 7 lines · Wen Congyang
Wen Congyang (14):
docs: block replication's description
quorom: add a new read pattern
quorum: ignore 0-length child
Add new block driver interfaces to control disk replication
quorom: implement block driver interfaces for block replication NBD client: connect to nbd server later
Quoted 8 lines
NBD client: implement block driver interfaces for block replication
block: add a new API to create a hidden BlockBackend
block: give backing image its own BlockBackend
allow the backing image access the origin BlockDriverState allow writing to the backing file
Add disk buffer for block replication
COW: move cow interfaces to a seperate file
COLO: implement a new block driver
Hi Wen, sorry for the delay.
Kevin and Max need to review this series, as they are the most comfortable with BlockDriverState vs. BlockBackend.
I suspect you cannot unconditionally give a separate BlockBackend to each backing image, but they can hopefully suggest how to proceed.
Paolo