]> git.proxmox.com Git - mirror_qemu.git/blob - block/quorum.c
quorum: Create quorum.c, add QuorumChildRequest and QuorumAIOCB.
[mirror_qemu.git] / block / quorum.c
1 /*
2 * Quorum Block filter
3 *
4 * Copyright (C) 2012-2014 Nodalink, EURL.
5 *
6 * Author:
7 * BenoƮt Canet <benoit.canet@irqsave.net>
8 *
9 * Based on the design and code of blkverify.c (Copyright (C) 2010 IBM, Corp)
10 * and blkmirror.c (Copyright (C) 2011 Red Hat, Inc).
11 *
12 * This work is licensed under the terms of the GNU GPL, version 2 or later.
13 * See the COPYING file in the top-level directory.
14 */
15
16 #include "block/block_int.h"
17
18 typedef struct QuorumAIOCB QuorumAIOCB;
19
20 /* Quorum will create one instance of the following structure per operation it
21 * performs on its children.
22 * So for each read/write operation coming from the upper layer there will be
23 * $children_count QuorumChildRequest.
24 */
25 typedef struct QuorumChildRequest {
26 BlockDriverAIOCB *aiocb;
27 QEMUIOVector qiov;
28 uint8_t *buf;
29 int ret;
30 QuorumAIOCB *parent;
31 } QuorumChildRequest;
32
33 /* Quorum will use the following structure to track progress of each read/write
34 * operation received by the upper layer.
35 * This structure hold pointers to the QuorumChildRequest structures instances
36 * used to do operations on each children and track overall progress.
37 */
38 struct QuorumAIOCB {
39 BlockDriverAIOCB common;
40
41 /* Request metadata */
42 uint64_t sector_num;
43 int nb_sectors;
44
45 QEMUIOVector *qiov; /* calling IOV */
46
47 QuorumChildRequest *qcrs; /* individual child requests */
48 int count; /* number of completed AIOCB */
49 int success_count; /* number of successfully completed AIOCB */
50
51 bool is_read;
52 int vote_ret;
53 };