diff options
author | BenoƮt Canet <benoit@irqsave.net> | 2014-02-21 22:21:16 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2014-02-21 22:29:50 +0100 |
commit | d55dee2044791a02394a3db7055cedac68dca26b (patch) | |
tree | b79abcebcf1f8d2831f9846e961edcd4e86dabbf /block/quorum.c | |
parent | 95c6bff3561eedaf7c7de287bc4a002720605a8d (diff) |
quorum: Add quorum_getlength().
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 <benoit@irqsave.net>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/quorum.c')
-rw-r--r-- | block/quorum.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/block/quorum.c b/block/quorum.c index 4beee96ffa..c6ea862132 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, }; |