replication: interrupt failover if the main device is closed
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
@@ -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
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_donecan 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.
Signed-off-by Paolo Bonzini <[email protected]>
This patch looks fine to me.
Quoted 19 lines
--- block/replication.c | 3 +++ 1 file changed, 3 insertions(+)block/replication.c +3
-0@@ -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);
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_donecan 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.
Signed-off-by Paolo Bonzini <[email protected]>
Quoted 19 lines
--- block/replication.c | 3 +++ 1 file changed, 3 insertions(+)block/replication.c +3
-0@@ -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);
Stefan Hajnoczi
AppliedQuoted 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_donecan 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
Signed-off-by Paolo Bonzini <[email protected]>--- block/replication.c | 3 +++ 1 file changed, 3 insertions(+)
Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block
Stefan