Skip to contentSkip to conversation

replication: interrupt failover if the main device is closed

PATCH Applied Paolo Bonzini 4 participants 4 messages Oct 7, 2016 – Oct 14, 2016 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 replication: interrupt failover if the main device is closed

Without this change, there is a race condition in tests/test-replication. Depending on how fast the failover job (active commit) runs, there is a chance of two bad things happening:

1) replication_done can be called after the secondary has been closed and hence when the BDRVReplicationState is not valid anymore.

2) two copies of the active disk are present during the /replication/secondary/stop test (that test runs immediately after /replication/secondary/start, which tests failover). This causes the corruption detector to fire.

---
 block/replication.c | 3 +++
 1 file changed, 3 insertions(+)
block/replication.c +3 -0
index 3bd1cf1..5231a00 100644
@@ -133,6 +133,9 @@ static void replication_close(BlockDriverState *bs)
     if (s->replication_state == BLOCK_REPLICATION_RUNNING) {
         replication_stop(s->rs, false, NULL);
     }
+    if (s->replication_state == BLOCK_REPLICATION_FAILOVER) {
+        block_job_cancel_sync(s->active_disk->bs->job);
+    }
 
     if (s->mode == REPLICATION_MODE_SECONDARY) {
         g_free(s->top_id);
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Paolo Bonzini

Without this change, there is a race condition in tests/test-replication. Depending on how fast the failover job (active commit) runs, there is a chance of two bad things happening:

1) replication_done can be called after the secondary has been closed and hence when the BDRVReplicationState is not valid anymore.

Quoted 6 lines

2) two copies of the active disk are present during the /replication/secondary/stop test (that test runs immediately after /replication/secondary/start, which tests failover). This causes the corruption detector to fire.

This patch looks fine to me.

Quoted 19 lines
---
  block/replication.c | 3 +++
  1 file changed, 3 insertions(+)
block/replication.c +3 -0
index 3bd1cf1..5231a00 100644
@@ -133,6 +133,9 @@ static void replication_close(BlockDriverState *bs)
      if (s->replication_state == BLOCK_REPLICATION_RUNNING) {
          replication_stop(s->rs, false, NULL);
      }
+    if (s->replication_state == BLOCK_REPLICATION_FAILOVER) {
+        block_job_cancel_sync(s->active_disk->bs->job);
+    }
 
      if (s->mode == REPLICATION_MODE_SECONDARY) {
          g_free(s->top_id);
Reviewed-by on v1 1/1
#2 lore raw
In reply to Paolo Bonzini
Quoted 7 lines · Paolo Bonzini

Without this change, there is a race condition in tests/test-replication. Depending on how fast the failover job (active commit) runs, there is a chance of two bad things happening:

1) replication_done can be called after the secondary has been closed and hence when the BDRVReplicationState is not valid anymore.

Quoted 6 lines

2) two copies of the active disk are present during the /replication/secondary/stop test (that test runs immediately after /replication/secondary/start, which tests failover). This causes the corruption detector to fire.

Quoted 19 lines
---
  block/replication.c | 3 +++
  1 file changed, 3 insertions(+)
block/replication.c +3 -0
index 3bd1cf1..5231a00 100644
@@ -133,6 +133,9 @@ static void replication_close(BlockDriverState *bs)
      if (s->replication_state == BLOCK_REPLICATION_RUNNING) {
          replication_stop(s->rs, false, NULL);
      }
+    if (s->replication_state == BLOCK_REPLICATION_FAILOVER) {
+        block_job_cancel_sync(s->active_disk->bs->job);
+    }
 
      if (s->mode == REPLICATION_MODE_SECONDARY) {
          g_free(s->top_id);
#3 lore raw
In reply to Paolo Bonzini
Quoted 12 lines · Paolo Bonzini

Without this change, there is a race condition in tests/test-replication. Depending on how fast the failover job (active commit) runs, there is a chance of two bad things happening:

1) replication_done can be called after the secondary has been closed and hence when the BDRVReplicationState is not valid anymore.

2) two copies of the active disk are present during the /replication/secondary/stop test (that test runs immediately after /replication/secondary/start, which tests failover). This causes the corruption detector to fire.

Quoted 4 lines
---
 block/replication.c | 3 +++
 1 file changed, 3 insertions(+)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan