Skip to contentSkip to conversation

quorum: validate vote threshold against num_children even if read-pattern is fifo

Qemu-devel Applied Wen Congyang 4 participants 7 messages Jul 3, 2015 – Aug 26, 2015 Block layer

lore
Share & tools
lore
#0 lore raw

We need to use threshold to check if too many write operation fails. If threshold is larger than num children, we always get write error event even if all write operations success.

---
 block/quorum.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
block/quorum.c +6 -6
index a7df17c..b0eead0 100644
@@ -894,6 +894,12 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
     }
 
     s->threshold = qemu_opt_get_number(opts, QUORUM_OPT_VOTE_THRESHOLD, 0);
+    /* and validate it against s->num_children */
+    ret = quorum_valid_threshold(s->threshold, s->num_children, &local_err);
+    if (ret < 0) {
+        goto exit;
+    }
+
     ret = parse_read_pattern(qemu_opt_get(opts, QUORUM_OPT_READ_PATTERN));
     if (ret < 0) {
         error_setg(&local_err, "Please set read-pattern as fifo or quorum");
@@ -902,12 +908,6 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
     s->read_pattern = ret;
 
     if (s->read_pattern == QUORUM_READ_PATTERN_QUORUM) {
-        /* and validate it against s->num_children */
-        ret = quorum_valid_threshold(s->threshold, s->num_children, &local_err);
-        if (ret < 0) {
-            goto exit;
-        }
-
         /* is the driver in blkverify mode */
         if (qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false) &&
             s->num_children == 2 && s->threshold == 2) {
Signature · 1 line
2.4.3
Reviewed-by
#1 lore raw
Quoted 14 lines · Wen Congyang

We need to use threshold to check if too many write operation fails. If threshold is larger than num children, we always get write error event even if all write operations success.

---
 block/quorum.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
block/quorum.c +0 -0
index a7df17c..b0eead0 100644

block/quorum.c static int quorum_open(BlockDriverState *bs, QDict *options, int flags, · line 902

Quoted 9 lines
block/quorum.c +6 -0
@@ -894,6 +894,12 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
     }
 
     s->threshold = qemu_opt_get_number(opts, QUORUM_OPT_VOTE_THRESHOLD, 0);
+    /* and validate it against s->num_children */
+    ret = quorum_valid_threshold(s->threshold, s->num_children, &local_err);
+    if (ret < 0) {
+        goto exit;
+    }
+

I wonder why this check was moved inside the (s->read_pattern == QUORUM_READ_PATTERN_QUORUM) block when the fifo mode was introduced (adding Liu Yuan to Cc).

I assume that you are not going to allow removing children under the vote_threshold limit as we discussed, right?

Berto

#2 lore raw
Quoted 30 lines · Alberto Garcia
Quoted 14 lines · Wen Congyang

We need to use threshold to check if too many write operation fails. If threshold is larger than num children, we always get write error event even if all write operations success.

---
 block/quorum.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
block/quorum.c +0 -0
index a7df17c..b0eead0 100644

block/quorum.c static int quorum_open(BlockDriverState *bs, QDict *options, int flags, · line 902

Quoted 9 lines
block/quorum.c +6 -0
@@ -894,6 +894,12 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
     }
 
     s->threshold = qemu_opt_get_number(opts, QUORUM_OPT_VOTE_THRESHOLD, 0);
+    /* and validate it against s->num_children */
+    ret = quorum_valid_threshold(s->threshold, s->num_children, &local_err);
+    if (ret < 0) {
+        goto exit;
+    }
+

I wonder why this check was moved inside the (s->read_pattern == QUORUM_READ_PATTERN_QUORUM) block when the fifo mode was introduced (adding Liu Yuan to Cc).

Quoted 2 lines

I assume that you are not going to allow removing children under the vote_threshold limit as we discussed, right?

Yes.

Thanks
Wen Congyang

Quoted 6 lines

Berto
.

#3 lore raw
In reply to Wen Congyang

Ping...

Quoted 40 lines · Wen Congyang

We need to use threshold to check if too many write operation fails. If threshold is larger than num children, we always get write error event even if all write operations success.

---
 block/quorum.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
block/quorum.c +6 -6
index a7df17c..b0eead0 100644
@@ -894,6 +894,12 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
     }
 
     s->threshold = qemu_opt_get_number(opts, QUORUM_OPT_VOTE_THRESHOLD, 0);
+    /* and validate it against s->num_children */
+    ret = quorum_valid_threshold(s->threshold, s->num_children, &local_err);
+    if (ret < 0) {
+        goto exit;
+    }
+
     ret = parse_read_pattern(qemu_opt_get(opts, QUORUM_OPT_READ_PATTERN));
     if (ret < 0) {
         error_setg(&local_err, "Please set read-pattern as fifo or quorum");
@@ -902,12 +908,6 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
     s->read_pattern = ret;
 
     if (s->read_pattern == QUORUM_READ_PATTERN_QUORUM) {
-        /* and validate it against s->num_children */
-        ret = quorum_valid_threshold(s->threshold, s->num_children, &local_err);
-        if (ret < 0) {
-            goto exit;
-        }
-
         /* is the driver in blkverify mode */
         if (qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false) &&
             s->num_children == 2 && s->threshold == 2) {
#4 lore raw

Am 19.08.2015 um 04:53 hat Wen Congyang geschrieben:

Quoted 1 line

Ping...

It might have helped to...

a) CC the qemu-block mailing list
b) CC the subsystem maintainer that should apply the patch (according to scripts/get_maintainer.pl that's me with Berto's Acked-by)
c) include the "PATCH" keyword in the subject line.

I'm copying qemu-block now and will consider the patch once I'm back from KVM Forum.

Kevin

Quoted 43 lines · Wen Congyang
Quoted 40 lines

We need to use threshold to check if too many write operation fails. If threshold is larger than num children, we always get write error event even if all write operations success.

---
 block/quorum.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
block/quorum.c +6 -6
index a7df17c..b0eead0 100644
@@ -894,6 +894,12 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
     }
 
     s->threshold = qemu_opt_get_number(opts, QUORUM_OPT_VOTE_THRESHOLD, 0);
+    /* and validate it against s->num_children */
+    ret = quorum_valid_threshold(s->threshold, s->num_children, &local_err);
+    if (ret < 0) {
+        goto exit;
+    }
+
     ret = parse_read_pattern(qemu_opt_get(opts, QUORUM_OPT_READ_PATTERN));
     if (ret < 0) {
         error_setg(&local_err, "Please set read-pattern as fifo or quorum");
@@ -902,12 +908,6 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
     s->read_pattern = ret;
 
     if (s->read_pattern == QUORUM_READ_PATTERN_QUORUM) {
-        /* and validate it against s->num_children */
-        ret = quorum_valid_threshold(s->threshold, s->num_children, &local_err);
-        if (ret < 0) {
-            goto exit;
-        }
-
         /* is the driver in blkverify mode */
         if (qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false) &&
             s->num_children == 2 && s->threshold == 2) {