Skip to contentSkip to conversation

modify vote rules for flush operation

PATCH Superseded Changlong Xie 3 participants 11 messages Feb 23, 2016 – Feb 24, 2016 Block layer

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v4 cover modify vote rules for flush operation

ChangLog:
v4:
1. Introduce QUORUM_FLUSH_ERROR event to notify flush failure. v3:
1. *Note* that, the codes logic is different from what we talked in v2. I just keep flush interface the same logic as quorum read/write, and think it's reasoned.

[Ref] http://lists.nongnu.org/archive/html/qemu-devel/2016-01/msg05342.htm

Changlong Xie (2):
qmp event: Add QUORUM_FLUSH_ERROR
quorum: modify vote rules for flush operation

 block/quorum.c      | 24 +++++++++++++++++++-----
 docs/qmp-events.txt | 18 ++++++++++++++++++
 qapi/event.json     | 16 ++++++++++++++++
 3 files changed, 53 insertions(+), 5 deletions(-)
Signature · 1 line
1.9.3
#1 lore raw

PATCH v4 1/2 qmp event: Add QUORUM_FLUSH_ERROR

---
 block/quorum.c      |  5 +++++
 docs/qmp-events.txt | 18 ++++++++++++++++++
 qapi/event.json     | 16 ++++++++++++++++
 3 files changed, 39 insertions(+)
block/quorum.c +5 -0
index f78d4cb..d3c3958 100644
@@ -235,6 +235,11 @@ static void quorum_report_failure(QuorumAIOCB *acb)
                                    acb->nb_sectors, &error_abort);
 }
 
+static void quorum_flush_error(char *node_name, const char *msg)
+{
+    qapi_event_send_quorum_flush_error(node_name, msg, &error_abort);
+}
+
 static int quorum_vote_error(QuorumAIOCB *acb);
 
 static bool quorum_has_too_much_io_failed(QuorumAIOCB *acb)
docs/qmp-events.txt +18 -0
index b6e8937..d777873 100644
@@ -340,6 +340,24 @@ Example:
 
 Note: this event is rate-limited.
 
+QUORUM_FLUSH_ERROR
+-----------------
+
+Emitted to report flush error message of the Quorum block driver
+
+Data:
+
+- "node-name":     The graph node name of the block driver state.
+- "error":         This field contains a human-readable error message.  There are
+                   no semantics other than that the block layer reported an error
+                   and clients should not try to interpret the error string.
+
+Example:
+
+{ "event": "QUORUM_FLUSH_ERROR",
+     "data": { "node-name": "1.raw", "error": "xxxxxx" },
+     "timestamp": { "seconds": 1344522075, "microseconds": 745528 } }
+
 RESET
 -----
 
qapi/event.json +16 -0
index cfcc887..5b16706 100644
@@ -358,6 +358,22 @@
             'sector-num': 'int', 'sectors-count': 'int' } }
 
 ##
+# @QUORUM_FLUSH_ERROR
+#
+# Emitted to report flush error message of the Quorum block driver
+#
+# @node-name: the graph node name of the block driver state
+#
+# @error: This field contains a human-readable error message. There are no semantics
+#         other than that the block layer reported an error and clients should not
+#         try to interpret the error string.
+#
+# Since: 2.5
+##
+{ 'event': 'QUORUM_FLUSH_ERROR',
+  'data': { 'node-name': 'str', 'error': 'str'} }
+
+##
 # @VSERPORT_CHANGE
 #
 # Emitted when the guest opens or closes a virtio-serial port.
Signature · 1 line
1.9.3
#2 lore raw

Re: [Qemu-devel] [PATCH v4 1/2] qmp event: Add QUORUM_FLUSH_ERROR

cc Markus Armbruster <[email protected]>
Quoted 81 lines · Changlong Xie
---
  block/quorum.c      |  5 +++++
  docs/qmp-events.txt | 18 ++++++++++++++++++
  qapi/event.json     | 16 ++++++++++++++++
  3 files changed, 39 insertions(+)
block/quorum.c +5 -0
index f78d4cb..d3c3958 100644
@@ -235,6 +235,11 @@ static void quorum_report_failure(QuorumAIOCB *acb)
                                     acb->nb_sectors, &error_abort);
  }
 
+static void quorum_flush_error(char *node_name, const char *msg)
+{
+    qapi_event_send_quorum_flush_error(node_name, msg, &error_abort);
+}
+
  static int quorum_vote_error(QuorumAIOCB *acb);
 
  static bool quorum_has_too_much_io_failed(QuorumAIOCB *acb)
docs/qmp-events.txt +18 -0
index b6e8937..d777873 100644
@@ -340,6 +340,24 @@ Example:
 
  Note: this event is rate-limited.
 
+QUORUM_FLUSH_ERROR
+-----------------
+
+Emitted to report flush error message of the Quorum block driver
+
+Data:
+
+- "node-name":     The graph node name of the block driver state.
+- "error":         This field contains a human-readable error message.  There are
+                   no semantics other than that the block layer reported an error
+                   and clients should not try to interpret the error string.
+
+Example:
+
+{ "event": "QUORUM_FLUSH_ERROR",
+     "data": { "node-name": "1.raw", "error": "xxxxxx" },
+     "timestamp": { "seconds": 1344522075, "microseconds": 745528 } }
+
  RESET
  -----
 
qapi/event.json +16 -0
index cfcc887..5b16706 100644
@@ -358,6 +358,22 @@
              'sector-num': 'int', 'sectors-count': 'int' } }
 
  ##
+# @QUORUM_FLUSH_ERROR
+#
+# Emitted to report flush error message of the Quorum block driver
+#
+# @node-name: the graph node name of the block driver state
+#
+# @error: This field contains a human-readable error message. There are no semantics
+#         other than that the block layer reported an error and clients should not
+#         try to interpret the error string.
+#
+# Since: 2.5
+##
+{ 'event': 'QUORUM_FLUSH_ERROR',
+  'data': { 'node-name': 'str', 'error': 'str'} }
+
+##
  # @VSERPORT_CHANGE
  #
  # Emitted when the guest opens or closes a virtio-serial port.
#3 lore raw

Re: [Qemu-devel] [PATCH v4 1/2] qmp event: Add QUORUM_FLUSH_ERROR

In reply to Changlong Xie

block/quorum.c static void quorum_report_failure(QuorumAIOCB *acb) · line 242

Quoted 9 lines · Changlong Xie
block/quorum.c +5 -0
@@ -235,6 +235,11 @@ static void quorum_report_failure(QuorumAIOCB *acb)
                                    acb->nb_sectors, &error_abort);
 }
 
+static void quorum_flush_error(char *node_name, const char *msg)
+{
+    qapi_event_send_quorum_flush_error(node_name, msg, &error_abort);
+}
+

Instead of 'msg' I think you can receive an error code here and convert it to a message using strerror(). Take a look at quorum_report_bad() to see what I mean.

docs/qmp-events.txt Example: · line 346

Quoted 4 lines
docs/qmp-events.txt +4 -0
+QUORUM_FLUSH_ERROR
+-----------------
+
+Emitted to report flush error message of the Quorum block driver

Emitted to report a flush error in a Quorum file

docs/qmp-events.txt Example: · line 353

Quoted 7 lines
docs/qmp-events.txt +7 -0
+
+Data:
+
+- "node-name":     The graph node name of the block driver state.
+- "error":         This field contains a human-readable error message.  There are
+                   no semantics other than that the block layer reported an error
+                   and clients should not try to interpret the error string.

Can you reformat this paragraph so it takes less than 80 columns?

docs/qmp-events.txt Example: · line 359

Quoted 6 lines
docs/qmp-events.txt +6 -0
+
+Example:
+
+{ "event": "QUORUM_FLUSH_ERROR",
+     "data": { "node-name": "1.raw", "error": "xxxxxx" },
+     "timestamp": { "seconds": 1344522075, "microseconds": 745528 } }

'1.raw' is an invalid node name.

qapi/event.json line 369

Quoted 10 lines

##

qapi/event.json +9 -0
+# @QUORUM_FLUSH_ERROR
+#
+# Emitted to report flush error message of the Quorum block driver
+#
+# @node-name: the graph node name of the block driver state
+#
+# @error: This field contains a human-readable error message. There are no semantics
+#         other than that the block layer reported an error and clients should not
+#         try to interpret the error string.

Same changes I mentioned earlier.

Review

Quoted 2 lines
(quoted diff) +2 -0
+#
+# Since: 2.5

Since 2.6

Berto

#4 lore raw

Re: [Qemu-devel] [PATCH v4 1/2] qmp event: Add QUORUM_FLUSH_ERROR

In reply to Changlong Xie
Quoted 7 lines · Changlong Xie
---
 block/quorum.c      |  5 +++++
 docs/qmp-events.txt | 18 ++++++++++++++++++
 qapi/event.json     | 16 ++++++++++++++++
 3 files changed, 39 insertions(+)

In addition to Berto's findings:

docs/qmp-events.txt Example: · line 344

Quoted 7 lines

+++ b/docs/qmp-events.txt

docs/qmp-events.txt +2 -0
@@ -340,6 +340,24 @@ Example:
 
 Note: this event is rate-limited.
 
+QUORUM_FLUSH_ERROR
+-----------------

Please keep the file sorted; this would fall between QUORUM_FAILURE and QUORUM_REPORT_BAD. Commit message should say why we need a third event, rather than reusing either of the other two (my guess: because you don't have a location, and don't want to modify the existing two to report a location - but why not just use 'sector-num':0, 'sectors-count':<size of file> to report the entire file as the location?)

Length of ---- separator should match text above it (you were off by one).

Is this event rate-limited? Should it be?

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#5 lore raw

Re: [Qemu-devel] [PATCH v4 1/2] qmp event: Add QUORUM_FLUSH_ERROR

Quoted 5 lines · Eric Blake

Commit message should say why we need a third event, rather than reusing either of the other two (my guess: because you don't have a location, and don't want to modify the existing two to report a location - but why not just use 'sector-num':0, 'sectors-count':<size of file> to report the entire file as the location?)

I would also be fine with that solution.

Berto

#6 lore raw

Re: [Qemu-devel] [PATCH v4 1/2] qmp event: Add QUORUM_FLUSH_ERROR

Quoted 9 lines · Alberto Garcia
Quoted 5 lines · Eric Blake

Commit message should say why we need a third event, rather than reusing either of the other two (my guess: because you don't have a location, and don't want to modify the existing two to report a location - but why not just use 'sector-num':0, 'sectors-count':<size of file> to report the entire file as the location?)

I would also be fine with that solution.

I would also be fine if we added an optional enum member to the existing event that said which operation failed ('read', 'write', 'flush') - adding optional output members is safe, while converting existing mandatory output members to optional may confuse existing clients.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#7 lore raw

Re: [Qemu-devel] [PATCH v4 1/2] qmp event: Add QUORUM_FLUSH_ERROR

Quoted 7 lines · Eric Blake
Quoted 7 lines
Quoted 6 lines

Commit message should say why we need a third event, rather than reusing either of the other two (my guess: because you don't have a location, and don't want to modify the existing two to report a location - but why not just use 'sector-num':0, 'sectors-count':<size of file> to report the entire file as the location?)

Quoted 7 lines
Quoted 1 line

I would also be fine with that solution.

I would also be fine if we added an optional enum member to the existing event that said which operation failed ('read', 'write', 'flush') - adding optional output members is safe, while converting existing mandatory output members to optional may confuse existing clients.

That might actually be the best option :-)

Berto

#8 lore raw

Re: [Qemu-devel] [PATCH v4 1/2] qmp event: Add QUORUM_FLUSH_ERROR

Quoted 9 lines · Alberto Garcia
Quoted 7 lines · Eric Blake
Quoted 7 lines
Quoted 6 lines

Commit message should say why we need a third event, rather than reusing either of the other two (my guess: because you don't have a location, and don't want to modify the existing two to report a location - but why not just use 'sector-num':0, 'sectors-count':<size of file> to report the entire file as the location?)

Quoted 8 lines
Quoted 7 lines
Quoted 1 line

I would also be fine with that solution.

I would also be fine if we added an optional enum member to the existing event that said which operation failed ('read', 'write', 'flush') - adding optional output members is safe, while converting existing mandatory output members to optional may confuse existing clients.

Hi Berto & Eric

Thanks for all your comments. Surely, this is the best option to me too :-), will fix it in next version.

Thanks
-Xie

Quoted 7 lines

That might actually be the best option :-)

Berto

.

#9 lore raw

PATCH v4 2/2 quorum: modify vote rules for flush operation

In reply to Changlong Xie

Keep flush interface the same logic as quorum read/write, Otherwise in following scenario, we'll encounter unexpected errors.

Quorum has two children(A, B). A do flush sucessfully, but B flush failed. This cause the filesystem of guest become read-only with following errors:

end_request: I/O error, dev vda, sector 11159960
Aborting journal on device vda3-8
EXT4-fs error (device vda3): ext4_journal_start_sb:327: Detected abort journal EXT4-fs (vda3): Remounting filesystem read-only

---
 block/quorum.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
block/quorum.c +14 -5
index d3c3958..6048208 100644
@@ -768,19 +768,28 @@ static coroutine_fn int quorum_co_flush(BlockDriverState *bs)
     QuorumVoteValue result_value;
     int i;
     int result = 0;
+    int success_count = 0;
 
     QLIST_INIT(&error_votes.vote_list);
     error_votes.compare = quorum_64bits_compare;
 
     for (i = 0; i < s->num_children; i++) {
         result = bdrv_co_flush(s->children[i]->bs);
-        result_value.l = result;
-        quorum_count_vote(&error_votes, &result_value, i);
+        if (result) {
+            quorum_flush_error(s->children[i]->bs->node_name, "Flush failed");
+            result_value.l = result;
+            quorum_count_vote(&error_votes, &result_value, i);
+        } else {
+            success_count++;
+        }
     }
 
-    winner = quorum_get_vote_winner(&error_votes);
-    result = winner->value.l;
-
+    if (success_count >= s->threshold) {
+        result = 0;
+    } else {
+        winner = quorum_get_vote_winner(&error_votes);
+        result = winner->value.l;
+    }
     quorum_free_vote_list(&error_votes);
 
     return result;
Signature · 1 line
1.9.3
#10 lore raw

Re: [Qemu-devel] [PATCH v4 2/2] quorum: modify vote rules for flush operation

block/quorum.c static coroutine_fn int quorum_co_flush(BlockDriverState *bs) · line 784

Quoted 11 lines · Changlong Xie
     for (i = 0; i < s->num_children; i++) {
         result = bdrv_co_flush(s->children[i]->bs);
block/quorum.c +7 -2
-        result_value.l = result;
-        quorum_count_vote(&error_votes, &result_value, i);
+        if (result) {
+            quorum_flush_error(s->children[i]->bs->node_name, "Flush failed");
+            result_value.l = result;
+            quorum_count_vote(&error_votes, &result_value, i);
+        } else {
+            success_count++;
+        }

As I wrote on the review of patch 1/2, I would pass 'result' directly instead of "Flush failed". Otherwise this patch looks good, thanks!

Berto