block/quorum: add simple read pattern support
PATCH v2 1/1 block/quorum: add simple read pattern support
This patch adds single read pattern to quorum driver and quorum vote is default pattern.
For now we do a quorum vote on all the reads, it is designed for unreliable underlying storage such as non-redundant NFS to make sure data integrity at the cost of the read performance.
For some use cases as following:
VM
--------------
| | v v A B
Both A and B has hardware raid storage to justify the data integrity on its own. So it would help performance if we do a single read instead of on all the nodes. Further, if we run VM on either of the storage node, we can make a local read request for better performance.
This patch generalize the above 2 nodes case in the N nodes. That is,
vm -> write to all the N nodes, read just one of them. If single read fails, we try to read next node in FIFO order specified by the startup command.
The 2 nodes case is very similar to DRBD[1] though lack of auto-sync functionality in the single device/node failure for now. But compared with DRBD we still have some advantages over it:
- Suppose we have 20 VMs running on one(assume A) of 2 nodes' DRBD backed storage. And if A crashes, we need to restart all the VMs on node B. But for practice case, we can't because B might not have enough resources to setup 20 VMs at once. So if we run our 20 VMs with quorum driver, and scatter the replicated images over the data center, we can very likely restart 20 VMs without any resource problem.
After all, I think we can build a more powerful replicated image functionality on quorum and block jobs(block mirror) to meet various High Availibility needs.
E.g, Enable single read pattern on 2 children,
-drive driver=quorum,children.0.file.filename=0.qcow2,\
children.1.file.filename=1.qcow2,read-pattern=single,vote-threshold=1
[1] http://en.wikipedia.org/wiki/Distributed_Replicated_Block_Device
---
v2:
- rename single as 'fifo'
- rename read_all_children as read_quorum_children
- fix quorum_aio_finalize() for fifo pattern
block.c | 2 +- block/quorum.c | 181 +++++++++++++++++++++++++++++++++++++-------------- qapi/block-core.json | 7 +- 3 files changed, 138 insertions(+), 52 deletions(-)
block.c +1 -1
@@ -2212,7 +2212,7 @@ int bdrv_commit(BlockDriverState *bs)if (!drv)return -ENOMEDIUM ; - +if (!bs->backing_hd) {return -ENOTSUP ; }
block/quorum.c +131 -50
262 lines not on this page · raw message
qapi/block-core.json +6 -1
@@ -1398,12 +1398,17 @@ # @rewrite-corrupted: #optional rewrite corrupted data when quorum is reached # (Since 2.1) # +# @read-pattern: #optional choose quorum or fifo pattern for read +# set to quorum by default (Since 2.2) +# # Since: 2.0 ## { 'type': 'BlockdevOptionsQuorum', 'data': { '*blkverify': 'bool', 'children': [ 'BlockdevRef' ], - 'vote-threshold': 'int', '*rewrite-corrupted': 'bool' } } + 'vote-threshold': 'int', + '*rewrite-corrupted': 'bool', + '*read-pattern': 'str' } } ## # @BlockdevOptions
Signature · 1 line
1.9.1
Quoted 16 lines · Liu Yuan
This patch adds single read pattern to quorum driver and quorum vote is default pattern.
This patch generalize the above 2 nodes case in the N nodes. That is,
vm -> write to all the N nodes, read just one of them. If single read fails, we try to read next node in FIFO order specified by the startup command.
The 2 nodes case is very similar to DRBD[1] though lack of auto-sync functionality in the single device/node failure for now. But compared with DRBD we still have some advantages over it:
+++
b/block.c
block.c int bdrv_commit(BlockDriverState *bs) · line 2218
Quoted 8 lines
block.c +1
-1@@ -2212,7 +2212,7 @@ int bdrv_commit(BlockDriverState *bs)if (!drv)return -ENOMEDIUM ; - +if (!bs->backing_hd) {return -ENOTSUP ; }
While this whitespace cleanup is nice, it doesn't belong in this patch, when there is no other change to this unrelated file.
Quoted 7 lines
+++
b/qapi/block-core.jsonqapi/block-core.json +2
-0@@ -1398,12 +1398,17 @@ # @rewrite-corrupted: #optional rewrite corrupted data when quorum is reached # (Since 2.1) # +# @read-pattern: #optional choose quorum or fifo pattern for read +# set to quorum by default (Since 2.2)
qapi/block-core.json line 1411
Quoted 10 lines
qapi/block-core.json +4
-1+# # Since: 2.0 ## { 'type': 'BlockdevOptionsQuorum', 'data': { '*blkverify': 'bool', 'children': [ 'BlockdevRef' ], - 'vote-threshold': 'int', '*rewrite-corrupted': 'bool' } } + 'vote-threshold': 'int', + '*rewrite-corrupted': 'bool', + '*read-pattern': 'str' } }
Raw strings that encode a finite set of values are bad for type-safety.
Please add an enum:
{ 'enum': 'QuorumReadPattern', 'data': [ 'quorum', 'fifo' ] }
then use '*read-pattern': 'QuorumReadPattern'
Should we offer multiple modes in addition to 'quorum'? For example, I could see a difference between 'fifo' (favor read from the first quorum member always, unless it fails, good when the first member is local and other member is remote) and 'round-robin' (evenly distribute reads; each read goes to the next available quorum member, good when all members are equally distant).
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 51 lines · Eric Blake
Quoted 16 lines · Liu Yuan
This patch adds single read pattern to quorum driver and quorum vote is default pattern.
This patch generalize the above 2 nodes case in the N nodes. That is,
vm -> write to all the N nodes, read just one of them. If single read fails, we try to read next node in FIFO order specified by the startup command.
The 2 nodes case is very similar to DRBD[1] though lack of auto-sync functionality in the single device/node failure for now. But compared with DRBD we still have some advantages over it:
+++
b/block.cblock.c int bdrv_commit(BlockDriverState *bs) · line 2218
Quoted 8 lines
block.c +1
-1@@ -2212,7 +2212,7 @@ int bdrv_commit(BlockDriverState *bs)if (!drv)return -ENOMEDIUM ; - +if (!bs->backing_hd) {return -ENOTSUP ; }While this whitespace cleanup is nice, it doesn't belong in this patch, when there is no other change to this unrelated file.
Quoted 7 lines
+++
b/qapi/block-core.jsonqapi/block-core.json +2
-0@@ -1398,12 +1398,17 @@ # @rewrite-corrupted: #optional rewrite corrupted data when quorum is reached # (Since 2.1) # +# @read-pattern: #optional choose quorum or fifo pattern for read +# set to quorum by default (Since 2.2)qapi/block-core.json line 1411
Quoted 10 lines
qapi/block-core.json +4
-1+# # Since: 2.0 ## { 'type': 'BlockdevOptionsQuorum', 'data': { '*blkverify': 'bool', 'children': [ 'BlockdevRef' ], - 'vote-threshold': 'int', '*rewrite-corrupted': 'bool' } } + 'vote-threshold': 'int', + '*rewrite-corrupted': 'bool', + '*read-pattern': 'str' } }Raw strings that encode a finite set of values are bad for type-safety.
Please add an enum:
Quoted 3 lines
{ 'enum': 'QuorumReadPattern', 'data': [ 'quorum', 'fifo' ] }
then use '*read-pattern': 'QuorumReadPattern'
For startup command line, did it imply a change too? Sorry I'm not familiar with block-core.json.
With your suggestion, how we pass read-pattern via qmp?
read-pattern: fifo
or
read-pattern: quorum
Quoted 7 lines
Should we offer multiple modes in addition to 'quorum'? For example, I could see a difference between 'fifo' (favor read from the first quorum member always, unless it fails, good when the first member is local and other member is remote) and 'round-robin' (evenly distribute reads; each read goes to the next available quorum member, good when all members are equally distant).
I guess so. 'round-robin' in your context would benefit use case seeking for better read load balance.
Thanks
Yuan
Quoted 11 lines · Liu Yuan
Quoted 8 lines
Quoted 1 line
+ '*read-pattern': 'str' } }
Raw strings that encode a finite set of values are bad for type-safety.
Please add an enum:{ 'enum': 'QuorumReadPattern', 'data': [ 'quorum', 'fifo' ] }
then use '*read-pattern': 'QuorumReadPattern'
For startup command line, did it imply a change too? Sorry I'm not familiar with block-core.json.
Adding an enum in the .json file will generate an enum that you can reuse in your parsing code (look at commit 82a402e99, parse_enum_option). The command line will be the same, but instead of open-coding things, you can now use the same enum as what the QMP code will use.
Quoted 6 lines
With your suggestion, how we pass read-pattern via qmp?
read-pattern: fifo
or
read-pattern: quorum
The QMP wire format will be identical - the user still passes "read-pattern":"fifo" as part of building up their JSON. It's just that the string "fifo" is now validated for correctness against the enum of valid strings, instead of being open-ended anything goes.
Quoted 10 lines
Quoted 9 lines
Should we offer multiple modes in addition to 'quorum'? For example, I could see a difference between 'fifo' (favor read from the first quorum member always, unless it fails, good when the first member is local and other member is remote) and 'round-robin' (evenly distribute reads; each read goes to the next available quorum member, good when all members are equally distant).
Quoted 2 lines
I guess so. 'round-robin' in your context would benefit use case seeking for better read load balance.
Of course, if you do add 'round-robin', do it in a separate patch; and that's also a case where having the enum list valid modes will make it easier to add in a new mode.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org