block.c (a41cfda12674a296579bc5459646ded9547b1220) | block.c (142e6907120d12de1e7ac402e556597ebbab86e8) |
---|---|
1/* 2 * QEMU System Emulator block driver 3 * 4 * Copyright (c) 2003 Fabrice Bellard 5 * Copyright (c) 2020 Virtuozzo International GmbH. 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a copy 8 * of this software and associated documentation files (the "Software"), to deal --- 2890 unchanged lines hidden (view full) --- 2899{ 2900 BdrvAttachChildCommonState *s = opaque; 2901 BlockDriverState *bs = s->child->bs; 2902 2903 GLOBAL_STATE_CODE(); 2904 bdrv_replace_child_noperm(s->child, NULL); 2905 2906 if (bdrv_get_aio_context(bs) != s->old_child_ctx) { | 1/* 2 * QEMU System Emulator block driver 3 * 4 * Copyright (c) 2003 Fabrice Bellard 5 * Copyright (c) 2020 Virtuozzo International GmbH. 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a copy 8 * of this software and associated documentation files (the "Software"), to deal --- 2890 unchanged lines hidden (view full) --- 2899{ 2900 BdrvAttachChildCommonState *s = opaque; 2901 BlockDriverState *bs = s->child->bs; 2902 2903 GLOBAL_STATE_CODE(); 2904 bdrv_replace_child_noperm(s->child, NULL); 2905 2906 if (bdrv_get_aio_context(bs) != s->old_child_ctx) { |
2907 bdrv_try_set_aio_context(bs, s->old_child_ctx, &error_abort); | 2907 bdrv_try_change_aio_context(bs, s->old_child_ctx, NULL, &error_abort); |
2908 } 2909 2910 if (bdrv_child_get_parent_aio_context(s->child) != s->old_parent_ctx) { 2911 Transaction *tran; 2912 GHashTable *visited; 2913 bool ret; 2914 2915 tran = tran_new(); --- 54 unchanged lines hidden (view full) --- 2970 /* 2971 * If the AioContexts don't match, first try to move the subtree of 2972 * child_bs into the AioContext of the new parent. If this doesn't work, 2973 * try moving the parent into the AioContext of child_bs instead. 2974 */ 2975 parent_ctx = bdrv_child_get_parent_aio_context(new_child); 2976 if (child_ctx != parent_ctx) { 2977 Error *local_err = NULL; | 2908 } 2909 2910 if (bdrv_child_get_parent_aio_context(s->child) != s->old_parent_ctx) { 2911 Transaction *tran; 2912 GHashTable *visited; 2913 bool ret; 2914 2915 tran = tran_new(); --- 54 unchanged lines hidden (view full) --- 2970 /* 2971 * If the AioContexts don't match, first try to move the subtree of 2972 * child_bs into the AioContext of the new parent. If this doesn't work, 2973 * try moving the parent into the AioContext of child_bs instead. 2974 */ 2975 parent_ctx = bdrv_child_get_parent_aio_context(new_child); 2976 if (child_ctx != parent_ctx) { 2977 Error *local_err = NULL; |
2978 int ret = bdrv_try_set_aio_context(child_bs, parent_ctx, &local_err); | 2978 int ret = bdrv_try_change_aio_context(child_bs, parent_ctx, NULL, 2979 &local_err); |
2979 2980 if (ret < 0 && child_class->change_aio_ctx) { 2981 Transaction *tran = tran_new(); 2982 GHashTable *visited = g_hash_table_new(NULL, NULL); 2983 bool ret_child; 2984 2985 g_hash_table_add(visited, new_child); 2986 ret_child = child_class->change_aio_ctx(new_child, child_ctx, --- 73 unchanged lines hidden (view full) --- 3060 * fatal in this case, ignore them. 3061 */ 3062 bdrv_refresh_perms(old_bs, NULL); 3063 3064 /* 3065 * When the parent requiring a non-default AioContext is removed, the 3066 * node moves back to the main AioContext 3067 */ | 2980 2981 if (ret < 0 && child_class->change_aio_ctx) { 2982 Transaction *tran = tran_new(); 2983 GHashTable *visited = g_hash_table_new(NULL, NULL); 2984 bool ret_child; 2985 2986 g_hash_table_add(visited, new_child); 2987 ret_child = child_class->change_aio_ctx(new_child, child_ctx, --- 73 unchanged lines hidden (view full) --- 3061 * fatal in this case, ignore them. 3062 */ 3063 bdrv_refresh_perms(old_bs, NULL); 3064 3065 /* 3066 * When the parent requiring a non-default AioContext is removed, the 3067 * node moves back to the main AioContext 3068 */ |
3068 bdrv_try_set_aio_context(old_bs, qemu_get_aio_context(), NULL); | 3069 bdrv_try_change_aio_context(old_bs, qemu_get_aio_context(), NULL, NULL); |
3069 } 3070} 3071 3072/* 3073 * This function steals the reference to child_bs from the caller. 3074 * That reference is later dropped by bdrv_root_unref_child(). 3075 * 3076 * On failure NULL is returned, errp is set and the reference to --- 4325 unchanged lines hidden (view full) --- 7402 /* Re-acquire the old AioContext, since the caller takes and releases it. */ 7403 if (qemu_get_aio_context() != old_context) { 7404 aio_context_acquire(old_context); 7405 } 7406 7407 return 0; 7408} 7409 | 3070 } 3071} 3072 3073/* 3074 * This function steals the reference to child_bs from the caller. 3075 * That reference is later dropped by bdrv_root_unref_child(). 3076 * 3077 * On failure NULL is returned, errp is set and the reference to --- 4325 unchanged lines hidden (view full) --- 7403 /* Re-acquire the old AioContext, since the caller takes and releases it. */ 7404 if (qemu_get_aio_context() != old_context) { 7405 aio_context_acquire(old_context); 7406 } 7407 7408 return 0; 7409} 7410 |
7410int bdrv_try_set_aio_context(BlockDriverState *bs, AioContext *ctx, 7411 Error **errp) 7412{ 7413 GLOBAL_STATE_CODE(); 7414 return bdrv_try_change_aio_context(bs, ctx, NULL, errp); 7415} 7416 | |
7417void bdrv_add_aio_context_notifier(BlockDriverState *bs, 7418 void (*attached_aio_context)(AioContext *new_context, void *opaque), 7419 void (*detach_aio_context)(void *opaque), void *opaque) 7420{ 7421 BdrvAioNotifier *ban = g_new(BdrvAioNotifier, 1); 7422 *ban = (BdrvAioNotifier){ 7423 .attached_aio_context = attached_aio_context, 7424 .detach_aio_context = detach_aio_context, --- 735 unchanged lines hidden --- | 7411void bdrv_add_aio_context_notifier(BlockDriverState *bs, 7412 void (*attached_aio_context)(AioContext *new_context, void *opaque), 7413 void (*detach_aio_context)(void *opaque), void *opaque) 7414{ 7415 BdrvAioNotifier *ban = g_new(BdrvAioNotifier, 1); 7416 *ban = (BdrvAioNotifier){ 7417 .attached_aio_context = attached_aio_context, 7418 .detach_aio_context = detach_aio_context, --- 735 unchanged lines hidden --- |