block.c (5263724b78f89cdea2354c8e92c53bac1b4641a3) block.c (1bffe1ae7a7b707c3a14ea2ccd00d3609d3ce4d8)
1/*
2 * QEMU System Emulator block driver
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

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

5667 g_free(ban);
5668}
5669
5670void bdrv_detach_aio_context(BlockDriverState *bs)
5671{
5672 BdrvAioNotifier *baf, *baf_tmp;
5673 BdrvChild *child;
5674
1/*
2 * QEMU System Emulator block driver
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

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

5667 g_free(ban);
5668}
5669
5670void bdrv_detach_aio_context(BlockDriverState *bs)
5671{
5672 BdrvAioNotifier *baf, *baf_tmp;
5673 BdrvChild *child;
5674
5675 if (!bs->drv) {
5676 return;
5677 }
5678
5679 assert(!bs->walking_aio_notifiers);
5680 bs->walking_aio_notifiers = true;
5681 QLIST_FOREACH_SAFE(baf, &bs->aio_notifiers, list, baf_tmp) {
5682 if (baf->deleted) {
5683 bdrv_do_remove_aio_context_notifier(baf);
5684 } else {
5685 baf->detach_aio_context(baf->opaque);
5686 }
5687 }
5688 /* Never mind iterating again to check for ->deleted. bdrv_close() will
5689 * remove remaining aio notifiers if we aren't called again.
5690 */
5691 bs->walking_aio_notifiers = false;
5692
5675 assert(!bs->walking_aio_notifiers);
5676 bs->walking_aio_notifiers = true;
5677 QLIST_FOREACH_SAFE(baf, &bs->aio_notifiers, list, baf_tmp) {
5678 if (baf->deleted) {
5679 bdrv_do_remove_aio_context_notifier(baf);
5680 } else {
5681 baf->detach_aio_context(baf->opaque);
5682 }
5683 }
5684 /* Never mind iterating again to check for ->deleted. bdrv_close() will
5685 * remove remaining aio notifiers if we aren't called again.
5686 */
5687 bs->walking_aio_notifiers = false;
5688
5693 if (bs->drv->bdrv_detach_aio_context) {
5689 if (bs->drv && bs->drv->bdrv_detach_aio_context) {
5694 bs->drv->bdrv_detach_aio_context(bs);
5695 }
5696 QLIST_FOREACH(child, &bs->children, next) {
5697 bdrv_detach_aio_context(child->bs);
5698 }
5699
5700 if (bs->quiesce_counter) {
5701 aio_enable_external(bs->aio_context);
5702 }
5703 bs->aio_context = NULL;
5704}
5705
5706void bdrv_attach_aio_context(BlockDriverState *bs,
5707 AioContext *new_context)
5708{
5709 BdrvAioNotifier *ban, *ban_tmp;
5710 BdrvChild *child;
5711
5690 bs->drv->bdrv_detach_aio_context(bs);
5691 }
5692 QLIST_FOREACH(child, &bs->children, next) {
5693 bdrv_detach_aio_context(child->bs);
5694 }
5695
5696 if (bs->quiesce_counter) {
5697 aio_enable_external(bs->aio_context);
5698 }
5699 bs->aio_context = NULL;
5700}
5701
5702void bdrv_attach_aio_context(BlockDriverState *bs,
5703 AioContext *new_context)
5704{
5705 BdrvAioNotifier *ban, *ban_tmp;
5706 BdrvChild *child;
5707
5712 if (!bs->drv) {
5713 return;
5714 }
5715
5716 if (bs->quiesce_counter) {
5717 aio_disable_external(new_context);
5718 }
5719
5720 bs->aio_context = new_context;
5721
5722 QLIST_FOREACH(child, &bs->children, next) {
5723 bdrv_attach_aio_context(child->bs, new_context);
5724 }
5708 if (bs->quiesce_counter) {
5709 aio_disable_external(new_context);
5710 }
5711
5712 bs->aio_context = new_context;
5713
5714 QLIST_FOREACH(child, &bs->children, next) {
5715 bdrv_attach_aio_context(child->bs, new_context);
5716 }
5725 if (bs->drv->bdrv_attach_aio_context) {
5717 if (bs->drv && bs->drv->bdrv_attach_aio_context) {
5726 bs->drv->bdrv_attach_aio_context(bs, new_context);
5727 }
5728
5729 assert(!bs->walking_aio_notifiers);
5730 bs->walking_aio_notifiers = true;
5731 QLIST_FOREACH_SAFE(ban, &bs->aio_notifiers, list, ban_tmp) {
5732 if (ban->deleted) {
5733 bdrv_do_remove_aio_context_notifier(ban);

--- 506 unchanged lines hidden ---
5718 bs->drv->bdrv_attach_aio_context(bs, new_context);
5719 }
5720
5721 assert(!bs->walking_aio_notifiers);
5722 bs->walking_aio_notifiers = true;
5723 QLIST_FOREACH_SAFE(ban, &bs->aio_notifiers, list, ban_tmp) {
5724 if (ban->deleted) {
5725 bdrv_do_remove_aio_context_notifier(ban);

--- 506 unchanged lines hidden ---