diff mbox

[RFC,V8,02/13] quorum: Create BDRVQuorumState and BlkDriver and do init.

Message ID 1359392845-15905-3-git-send-email-benoit@irqsave.net
State New
Headers show

Commit Message

Benoît Canet Jan. 28, 2013, 5:07 p.m. UTC
Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 block/quorum.c |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

Comments

Kevin Wolf Feb. 8, 2013, 10:22 a.m. UTC | #1
Am 28.01.2013 18:07, schrieb Benoît Canet:
> Signed-off-by: Benoit Canet <benoit@irqsave.net>
> ---
>  block/quorum.c |   22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/block/quorum.c b/block/quorum.c
> index 8dc6e4c..d8fffbe 100644
> --- a/block/quorum.c
> +++ b/block/quorum.c
> @@ -15,6 +15,13 @@
>  
>  #include "block/block_int.h"

This needs more documentation as well:

> +typedef struct {
> +    BlockDriverState **bs;
> +    unsigned long long threshold;

What kind of threshold is this?

> +    unsigned long long total;

Is this the array length for .bs and .filenames? Looking at the type,
probably not, so what is it - and where is the array size stored?

Why are both long long? It's not a type that appears a lot in the qemu
code. Should it be replaced by uint64_t?

> +    char **filenames;

What do you need the filenames for? If at all possible we should avoid
dealing with file names outside of the initialisation. Once we got all
the -blockdev infrastructure we're dreaming of, you wouldn't even be
able to get file names any more, just BlockDriverStates.

> +} BDRVQuorumState;
> +
>  typedef struct QuorumAIOCB QuorumAIOCB;
>  
>  typedef struct QuorumSingleAIOCB {

Kevin
diff mbox

Patch

diff --git a/block/quorum.c b/block/quorum.c
index 8dc6e4c..d8fffbe 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -15,6 +15,13 @@ 
 
 #include "block/block_int.h"
 
+typedef struct {
+    BlockDriverState **bs;
+    unsigned long long threshold;
+    unsigned long long total;
+    char **filenames;
+} BDRVQuorumState;
+
 typedef struct QuorumAIOCB QuorumAIOCB;
 
 typedef struct QuorumSingleAIOCB {
@@ -27,6 +34,7 @@  typedef struct QuorumSingleAIOCB {
 
 struct QuorumAIOCB {
     BlockDriverAIOCB common;
+    BDRVQuorumState *bqs;
     QEMUBH *bh;
 
     /* Request metadata */
@@ -43,3 +51,17 @@  struct QuorumAIOCB {
     void (*vote)(QuorumAIOCB *acb);
     int vote_ret;
 };
+
+static BlockDriver bdrv_quorum = {
+    .format_name        = "quorum",
+    .protocol_name      = "quorum",
+
+    .instance_size      = sizeof(BDRVQuorumState),
+};
+
+static void bdrv_quorum_init(void)
+{
+    bdrv_register(&bdrv_quorum);
+}
+
+block_init(bdrv_quorum_init);