[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC V7 11/11] quorum: Add quorum_co_flush().
From: |
Benoît Canet |
Subject: |
[Qemu-devel] [RFC V7 11/11] quorum: Add quorum_co_flush(). |
Date: |
Fri, 18 Jan 2013 18:30:44 +0100 |
Makes a vote to select error if any.
Signed-off-by: Benoit Canet <address@hidden>
---
block/quorum.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/block/quorum.c b/block/quorum.c
index 8cbf66f..0f4f634 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -731,6 +731,38 @@ static int coroutine_fn
quorum_co_is_allocated(BlockDriverState *bs,
return result;
}
+static coroutine_fn int quorum_co_flush(BlockDriverState *bs)
+{
+ BDRVQuorumState *s = bs->opaque;
+ QuorumVoteVersion *winner = NULL;
+ QuorumVotes error_votes;
+ QuorumVoteValue result_value;
+ int i;
+ int result = 0;
+ bool error = false;
+
+ QLIST_INIT(&error_votes.vote_list);
+ error_votes.compare = quorum_long_compare;
+
+ for (i = 0; i < s->total; i++) {
+ result = bdrv_co_flush(s->bs[i]);
+ if (result) {
+ error = true;
+ result_value.l = result;
+ quorum_count_vote(&error_votes, &result_value, i);
+ }
+ }
+
+ if (error) {
+ winner = quorum_get_vote_winner(&error_votes);
+ result = winner->value.l;
+ }
+
+ quorum_free_vote_list(&error_votes);
+
+ return result;
+}
+
static BlockDriver bdrv_quorum = {
.format_name = "quorum",
.protocol_name = "quorum",
@@ -741,6 +773,7 @@ static BlockDriver bdrv_quorum = {
.bdrv_file_open = quorum_open,
.bdrv_close = quorum_close,
+ .bdrv_co_flush_to_disk = quorum_co_flush,
.bdrv_aio_readv = quorum_aio_readv,
.bdrv_aio_writev = quorum_aio_writev,
--
1.7.10.4
- [Qemu-devel] [RFC V7 00/11] Quorum block filter, Benoît Canet, 2013/01/18
- [Qemu-devel] [RFC V7 02/11] quorum: Create BDRVQuorumState and BlkDriver and do init., Benoît Canet, 2013/01/18
- [Qemu-devel] [RFC V7 01/11] quorum: Create quorum .c, add QuorumSingleAIOCB and QuorumAIOCB., Benoît Canet, 2013/01/18
- [Qemu-devel] [RFC V7 04/11] quorum: Add quorum_aio_writev and its dependencies., Benoît Canet, 2013/01/18
- [Qemu-devel] [RFC V7 03/11] quorum: Add quorum_open() and quorum_close()., Benoît Canet, 2013/01/18
- [Qemu-devel] [RFC V7 06/11] quorum: Add quorum_aio_readv., Benoît Canet, 2013/01/18
- [Qemu-devel] [RFC V7 05/11] blkverify: Extract qemu_iovec_clone() and qemu_iovec_compare() from blkverify., Benoît Canet, 2013/01/18
- [Qemu-devel] [RFC V7 08/11] quorum: Add quorum_getlength()., Benoît Canet, 2013/01/18
- [Qemu-devel] [RFC V7 09/11] quorum: Add quorum_invalidate_cache()., Benoît Canet, 2013/01/18
- [Qemu-devel] [RFC V7 10/11] quorum: Add quorum_co_is_allocated., Benoît Canet, 2013/01/18
- [Qemu-devel] [RFC V7 11/11] quorum: Add quorum_co_flush().,
Benoît Canet <=
- [Qemu-devel] [RFC V7 07/11] quorum: Add quorum mechanism., Benoît Canet, 2013/01/18
- Re: [Qemu-devel] [RFC V7 00/11] Quorum block filter, Zhi Yong Wu, 2013/01/21