[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC V7 08/11] quorum: Add quorum_getlength().
From: |
Benoît Canet |
Subject: |
[Qemu-devel] [RFC V7 08/11] quorum: Add quorum_getlength(). |
Date: |
Fri, 18 Jan 2013 18:30:41 +0100 |
Check that every bs file return the same length.
If not return -EIO to disable the quorum and
avoid length discrepancy.
Signed-off-by: Benoit Canet <address@hidden>
---
block/quorum.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/block/quorum.c b/block/quorum.c
index e2b5208..a63a84f 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -651,12 +651,32 @@ static BlockDriverAIOCB
*quorum_aio_writev(BlockDriverState *bs,
return &acb->common;
}
+static int64_t quorum_getlength(BlockDriverState *bs)
+{
+ BDRVQuorumState *s = bs->opaque;
+ int64_t result;
+ int i;
+
+ /* check that every file have the same length */
+ result = bdrv_getlength(s->bs[0]);
+ for (i = 1; i < s->total; i++) {
+ int64_t value = bdrv_getlength(s->bs[i]);
+ if (value != result) {
+ return -EIO;
+ }
+ }
+
+ return result;
+}
+
static BlockDriver bdrv_quorum = {
.format_name = "quorum",
.protocol_name = "quorum",
.instance_size = sizeof(BDRVQuorumState),
+ .bdrv_getlength = quorum_getlength,
+
.bdrv_file_open = quorum_open,
.bdrv_close = quorum_close,
--
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 <=
- [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, 2013/01/18
- [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