replication.c (ce2f51697bea03956c2ac1ccc17d81e170d68c3b) replication.c (004915a96a7a40e942ac85e6d22518cbcd283506)
1/*
2 * Replication Block filter
3 *
4 * Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD.
5 * Copyright (c) 2016 Intel Corporation
6 * Copyright (c) 2016 FUJITSU LIMITED
7 *
8 * Author:

--- 349 unchanged lines hidden (view full) ---

358 */
359static void reopen_backing_file(BlockDriverState *bs, bool writable,
360 Error **errp)
361{
362 BDRVReplicationState *s = bs->opaque;
363 BdrvChild *hidden_disk, *secondary_disk;
364 BlockReopenQueue *reopen_queue = NULL;
365
1/*
2 * Replication Block filter
3 *
4 * Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD.
5 * Copyright (c) 2016 Intel Corporation
6 * Copyright (c) 2016 FUJITSU LIMITED
7 *
8 * Author:

--- 349 unchanged lines hidden (view full) ---

358 */
359static void reopen_backing_file(BlockDriverState *bs, bool writable,
360 Error **errp)
361{
362 BDRVReplicationState *s = bs->opaque;
363 BdrvChild *hidden_disk, *secondary_disk;
364 BlockReopenQueue *reopen_queue = NULL;
365
366 GLOBAL_STATE_CODE();
367 GRAPH_RDLOCK_GUARD_MAINLOOP();
368
366 /*
367 * s->hidden_disk and s->secondary_disk may not be set yet, as they will
368 * only be set after the children are writable.
369 */
370 hidden_disk = bs->file->bs->backing;
371 secondary_disk = hidden_disk->bs->backing;
372
373 if (writable) {

--- 117 unchanged lines hidden (view full) ---

491 aio_context_release(aio_context);
492 return;
493 }
494
495 switch (s->mode) {
496 case REPLICATION_MODE_PRIMARY:
497 break;
498 case REPLICATION_MODE_SECONDARY:
369 /*
370 * s->hidden_disk and s->secondary_disk may not be set yet, as they will
371 * only be set after the children are writable.
372 */
373 hidden_disk = bs->file->bs->backing;
374 secondary_disk = hidden_disk->bs->backing;
375
376 if (writable) {

--- 117 unchanged lines hidden (view full) ---

494 aio_context_release(aio_context);
495 return;
496 }
497
498 switch (s->mode) {
499 case REPLICATION_MODE_PRIMARY:
500 break;
501 case REPLICATION_MODE_SECONDARY:
502 bdrv_graph_rdlock_main_loop();
499 active_disk = bs->file;
500 if (!active_disk || !active_disk->bs || !active_disk->bs->backing) {
501 error_setg(errp, "Active disk doesn't have backing file");
503 active_disk = bs->file;
504 if (!active_disk || !active_disk->bs || !active_disk->bs->backing) {
505 error_setg(errp, "Active disk doesn't have backing file");
506 bdrv_graph_rdunlock_main_loop();
502 aio_context_release(aio_context);
503 return;
504 }
505
506 hidden_disk = active_disk->bs->backing;
507 if (!hidden_disk->bs || !hidden_disk->bs->backing) {
508 error_setg(errp, "Hidden disk doesn't have backing file");
507 aio_context_release(aio_context);
508 return;
509 }
510
511 hidden_disk = active_disk->bs->backing;
512 if (!hidden_disk->bs || !hidden_disk->bs->backing) {
513 error_setg(errp, "Hidden disk doesn't have backing file");
514 bdrv_graph_rdunlock_main_loop();
509 aio_context_release(aio_context);
510 return;
511 }
512
515 aio_context_release(aio_context);
516 return;
517 }
518
513 bdrv_graph_rdlock_main_loop();
514 secondary_disk = hidden_disk->bs->backing;
515 if (!secondary_disk->bs || !bdrv_has_blk(secondary_disk->bs)) {
516 error_setg(errp, "The secondary disk doesn't have block backend");
517 bdrv_graph_rdunlock_main_loop();
518 aio_context_release(aio_context);
519 return;
520 }
521 bdrv_graph_rdunlock_main_loop();

--- 274 unchanged lines hidden ---
519 secondary_disk = hidden_disk->bs->backing;
520 if (!secondary_disk->bs || !bdrv_has_blk(secondary_disk->bs)) {
521 error_setg(errp, "The secondary disk doesn't have block backend");
522 bdrv_graph_rdunlock_main_loop();
523 aio_context_release(aio_context);
524 return;
525 }
526 bdrv_graph_rdunlock_main_loop();

--- 274 unchanged lines hidden ---