[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 47/54] quorum: Add quorum_getlength().
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 47/54] quorum: Add quorum_getlength(). |
Date: |
Fri, 21 Feb 2014 23:12:44 +0100 |
From: BenoƮt Canet <address@hidden>
Check that every bs file returns the same length.
Otherwise, return -EIO to disable the quorum and
avoid length discrepancy.
Signed-off-by: Benoit Canet <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/quorum.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/block/quorum.c b/block/quorum.c
index 4beee96..c6ea862 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -595,12 +595,38 @@ 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 all file have the same length */
+ result = bdrv_getlength(s->bs[0]);
+ if (result < 0) {
+ return result;
+ }
+ for (i = 1; i < s->num_children; i++) {
+ int64_t value = bdrv_getlength(s->bs[i]);
+ if (value < 0) {
+ return value;
+ }
+ 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_aio_readv = quorum_aio_readv,
.bdrv_aio_writev = quorum_aio_writev,
};
--
1.8.1.4
- [Qemu-devel] [PULL 38/54] qdict: Extract non-QDicts in qdict_array_split(), (continued)
- [Qemu-devel] [PULL 38/54] qdict: Extract non-QDicts in qdict_array_split(), Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 41/54] quorum: Create quorum.c, add QuorumChildRequest and QuorumAIOCB., Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 42/54] quorum: Create BDRVQuorumState and BlkDriver and do init., Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 43/54] quorum: Add quorum_aio_writev and its dependencies., Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 40/54] check-qdict: Test termination of qdict_array_split(), Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 39/54] check-qdict: Adjust test for qdict_array_split(), Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 44/54] blkverify: Extract qemu_iovec_clone() and qemu_iovec_compare() from blkverify., Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 45/54] quorum: Add quorum_aio_readv., Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 46/54] quorum: Add quorum mechanism., Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 48/54] quorum: Add quorum_invalidate_cache()., Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 47/54] quorum: Add quorum_getlength().,
Kevin Wolf <=
- [Qemu-devel] [PULL 49/54] quorum: Add quorum_co_flush()., Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 50/54] quorum: Implement recursive .bdrv_recurse_is_first_non_filter in quorum., Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 51/54] quorum: Add quorum_open() and quorum_close()., Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 52/54] quorum: Add unit test., Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 53/54] quorum: Simplify quorum_open(), Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 54/54] iotests: Mixed quorum child device specifications, Kevin Wolf, 2014/02/21
- Re: [Qemu-devel] [PULL 00/54] Block patches, Peter Maydell, 2014/02/25