Skip to content

Commit 142e690

Browse files
esposemkevmw
authored andcommitted
block: remove bdrv_try_set_aio_context and replace it with bdrv_try_change_aio_context
No functional change intended. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]> Reviewed-by: Kevin Wolf <[email protected]> Message-Id: <[email protected]> Signed-off-by: Kevin Wolf <[email protected]>
1 parent a41cfda commit 142e690

File tree

8 files changed

+27
-35
lines changed

8 files changed

+27
-35
lines changed

block.c

+4-10
Original file line numberDiff line numberDiff line change
@@ -2904,7 +2904,7 @@ static void bdrv_attach_child_common_abort(void *opaque)
29042904
bdrv_replace_child_noperm(s->child, NULL);
29052905

29062906
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);
29082908
}
29092909

29102910
if (bdrv_child_get_parent_aio_context(s->child) != s->old_parent_ctx) {
@@ -2975,7 +2975,8 @@ static BdrvChild *bdrv_attach_child_common(BlockDriverState *child_bs,
29752975
parent_ctx = bdrv_child_get_parent_aio_context(new_child);
29762976
if (child_ctx != parent_ctx) {
29772977
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);
29792980

29802981
if (ret < 0 && child_class->change_aio_ctx) {
29812982
Transaction *tran = tran_new();
@@ -3065,7 +3066,7 @@ static void bdrv_detach_child(BdrvChild *child)
30653066
* When the parent requiring a non-default AioContext is removed, the
30663067
* node moves back to the main AioContext
30673068
*/
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);
30693070
}
30703071
}
30713072

@@ -7407,13 +7408,6 @@ int bdrv_try_change_aio_context(BlockDriverState *bs, AioContext *ctx,
74077408
return 0;
74087409
}
74097410

7410-
int 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-
74177411
void bdrv_add_aio_context_notifier(BlockDriverState *bs,
74187412
void (*attached_aio_context)(AioContext *new_context, void *opaque),
74197413
void (*detach_aio_context)(void *opaque), void *opaque)

block/export/export.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ BlockExport *blk_exp_add(BlockExportOptions *export, Error **errp)
129129

130130
/* Ignore errors with fixed-iothread=false */
131131
set_context_errp = fixed_iothread ? errp : NULL;
132-
ret = bdrv_try_set_aio_context(bs, new_ctx, set_context_errp);
132+
ret = bdrv_try_change_aio_context(bs, new_ctx, NULL, set_context_errp);
133133
if (ret == 0) {
134134
aio_context_release(ctx);
135135
aio_context_acquire(new_ctx);

blockdev.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -1630,8 +1630,8 @@ static void external_snapshot_abort(BlkActionState *common)
16301630
aio_context_release(aio_context);
16311631
aio_context_acquire(tmp_context);
16321632

1633-
ret = bdrv_try_set_aio_context(state->old_bs,
1634-
aio_context, NULL);
1633+
ret = bdrv_try_change_aio_context(state->old_bs,
1634+
aio_context, NULL, NULL);
16351635
assert(ret == 0);
16361636

16371637
aio_context_release(tmp_context);
@@ -1792,12 +1792,12 @@ static void drive_backup_prepare(BlkActionState *common, Error **errp)
17921792
goto out;
17931793
}
17941794

1795-
/* Honor bdrv_try_set_aio_context() context acquisition requirements. */
1795+
/* Honor bdrv_try_change_aio_context() context acquisition requirements. */
17961796
old_context = bdrv_get_aio_context(target_bs);
17971797
aio_context_release(aio_context);
17981798
aio_context_acquire(old_context);
17991799

1800-
ret = bdrv_try_set_aio_context(target_bs, aio_context, errp);
1800+
ret = bdrv_try_change_aio_context(target_bs, aio_context, NULL, errp);
18011801
if (ret < 0) {
18021802
bdrv_unref(target_bs);
18031803
aio_context_release(old_context);
@@ -1892,12 +1892,12 @@ static void blockdev_backup_prepare(BlkActionState *common, Error **errp)
18921892
return;
18931893
}
18941894

1895-
/* Honor bdrv_try_set_aio_context() context acquisition requirements. */
1895+
/* Honor bdrv_try_change_aio_context() context acquisition requirements. */
18961896
aio_context = bdrv_get_aio_context(bs);
18971897
old_context = bdrv_get_aio_context(target_bs);
18981898
aio_context_acquire(old_context);
18991899

1900-
ret = bdrv_try_set_aio_context(target_bs, aio_context, errp);
1900+
ret = bdrv_try_change_aio_context(target_bs, aio_context, NULL, errp);
19011901
if (ret < 0) {
19021902
aio_context_release(old_context);
19031903
return;
@@ -3194,12 +3194,12 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)
31943194
!bdrv_has_zero_init(target_bs)));
31953195

31963196

3197-
/* Honor bdrv_try_set_aio_context() context acquisition requirements. */
3197+
/* Honor bdrv_try_change_aio_context() context acquisition requirements. */
31983198
old_context = bdrv_get_aio_context(target_bs);
31993199
aio_context_release(aio_context);
32003200
aio_context_acquire(old_context);
32013201

3202-
ret = bdrv_try_set_aio_context(target_bs, aio_context, errp);
3202+
ret = bdrv_try_change_aio_context(target_bs, aio_context, NULL, errp);
32033203
if (ret < 0) {
32043204
bdrv_unref(target_bs);
32053205
aio_context_release(old_context);
@@ -3266,12 +3266,12 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id,
32663266

32673267
zero_target = (sync == MIRROR_SYNC_MODE_FULL);
32683268

3269-
/* Honor bdrv_try_set_aio_context() context acquisition requirements. */
3269+
/* Honor bdrv_try_change_aio_context() context acquisition requirements. */
32703270
old_context = bdrv_get_aio_context(target_bs);
32713271
aio_context = bdrv_get_aio_context(bs);
32723272
aio_context_acquire(old_context);
32733273

3274-
ret = bdrv_try_set_aio_context(target_bs, aio_context, errp);
3274+
ret = bdrv_try_change_aio_context(target_bs, aio_context, NULL, errp);
32753275

32763276
aio_context_release(old_context);
32773277
aio_context_acquire(aio_context);
@@ -3767,7 +3767,7 @@ void qmp_x_blockdev_set_iothread(const char *node_name, StrOrNull *iothread,
37673767
old_context = bdrv_get_aio_context(bs);
37683768
aio_context_acquire(old_context);
37693769

3770-
bdrv_try_set_aio_context(bs, new_context, errp);
3770+
bdrv_try_change_aio_context(bs, new_context, NULL, errp);
37713771

37723772
aio_context_release(old_context);
37733773
}

docs/devel/multiple-iothreads.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ The AioContext originates from the QEMU block layer, even though nowadays
109109
AioContext is a generic event loop that can be used by any QEMU subsystem.
110110

111111
The block layer has support for AioContext integrated. Each BlockDriverState
112-
is associated with an AioContext using bdrv_try_set_aio_context() and
112+
is associated with an AioContext using bdrv_try_change_aio_context() and
113113
bdrv_get_aio_context(). This allows block layer code to process I/O inside the
114114
right AioContext. Other subsystems may wish to follow a similar approach.
115115

@@ -134,5 +134,5 @@ Long-running jobs (usually in the form of coroutines) are best scheduled in
134134
the BlockDriverState's AioContext to avoid the need to acquire/release around
135135
each bdrv_*() call. The functions bdrv_add/remove_aio_context_notifier,
136136
or alternatively blk_add/remove_aio_context_notifier if you use BlockBackends,
137-
can be used to get a notification whenever bdrv_try_set_aio_context() moves a
137+
can be used to get a notification whenever bdrv_try_change_aio_context() moves a
138138
BlockDriverState to a different AioContext.

include/block/block-global-state.h

-2
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,6 @@ void coroutine_fn bdrv_co_lock(BlockDriverState *bs);
220220
*/
221221
void coroutine_fn bdrv_co_unlock(BlockDriverState *bs);
222222

223-
int bdrv_try_set_aio_context(BlockDriverState *bs, AioContext *ctx,
224-
Error **errp);
225223
AioContext *bdrv_child_get_parent_aio_context(BdrvChild *c);
226224
bool bdrv_child_change_aio_context(BdrvChild *c, AioContext *ctx,
227225
GHashTable *visited, Transaction *tran,

job.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ static void coroutine_fn job_do_yield_locked(Job *job, uint64_t ns)
588588
next_aio_context = job->aio_context;
589589
/*
590590
* Coroutine has resumed, but in the meanwhile the job AioContext
591-
* might have changed via bdrv_try_set_aio_context(), so we need to move
591+
* might have changed via bdrv_try_change_aio_context(), so we need to move
592592
* the coroutine too in the new aiocontext.
593593
*/
594594
while (qemu_get_current_aio_context() != next_aio_context) {

tests/unit/test-bdrv-drain.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1538,16 +1538,16 @@ static void test_set_aio_context(void)
15381538
&error_abort);
15391539

15401540
bdrv_drained_begin(bs);
1541-
bdrv_try_set_aio_context(bs, ctx_a, &error_abort);
1541+
bdrv_try_change_aio_context(bs, ctx_a, NULL, &error_abort);
15421542

15431543
aio_context_acquire(ctx_a);
15441544
bdrv_drained_end(bs);
15451545

15461546
bdrv_drained_begin(bs);
1547-
bdrv_try_set_aio_context(bs, ctx_b, &error_abort);
1547+
bdrv_try_change_aio_context(bs, ctx_b, NULL, &error_abort);
15481548
aio_context_release(ctx_a);
15491549
aio_context_acquire(ctx_b);
1550-
bdrv_try_set_aio_context(bs, qemu_get_aio_context(), &error_abort);
1550+
bdrv_try_change_aio_context(bs, qemu_get_aio_context(), NULL, &error_abort);
15511551
aio_context_release(ctx_b);
15521552
bdrv_drained_end(bs);
15531553

tests/unit/test-block-iothread.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -765,15 +765,15 @@ static void test_propagate_mirror(void)
765765
filter = bdrv_find_node("filter_node");
766766

767767
/* Change the AioContext of src */
768-
bdrv_try_set_aio_context(src, ctx, &error_abort);
768+
bdrv_try_change_aio_context(src, ctx, NULL, &error_abort);
769769
g_assert(bdrv_get_aio_context(src) == ctx);
770770
g_assert(bdrv_get_aio_context(target) == ctx);
771771
g_assert(bdrv_get_aio_context(filter) == ctx);
772772
g_assert(job->aio_context == ctx);
773773

774774
/* Change the AioContext of target */
775775
aio_context_acquire(ctx);
776-
bdrv_try_set_aio_context(target, main_ctx, &error_abort);
776+
bdrv_try_change_aio_context(target, main_ctx, NULL, &error_abort);
777777
aio_context_release(ctx);
778778
g_assert(bdrv_get_aio_context(src) == main_ctx);
779779
g_assert(bdrv_get_aio_context(target) == main_ctx);
@@ -783,7 +783,7 @@ static void test_propagate_mirror(void)
783783
blk = blk_new(qemu_get_aio_context(), 0, BLK_PERM_ALL);
784784
blk_insert_bs(blk, src, &error_abort);
785785

786-
bdrv_try_set_aio_context(target, ctx, &local_err);
786+
bdrv_try_change_aio_context(target, ctx, NULL, &local_err);
787787
error_free_or_abort(&local_err);
788788

789789
g_assert(blk_get_aio_context(blk) == main_ctx);
@@ -794,7 +794,7 @@ static void test_propagate_mirror(void)
794794
/* ...unless we explicitly allow it */
795795
aio_context_acquire(ctx);
796796
blk_set_allow_aio_context_change(blk, true);
797-
bdrv_try_set_aio_context(target, ctx, &error_abort);
797+
bdrv_try_change_aio_context(target, ctx, NULL, &error_abort);
798798
aio_context_release(ctx);
799799

800800
g_assert(blk_get_aio_context(blk) == ctx);
@@ -806,7 +806,7 @@ static void test_propagate_mirror(void)
806806

807807
aio_context_acquire(ctx);
808808
blk_set_aio_context(blk, main_ctx, &error_abort);
809-
bdrv_try_set_aio_context(target, main_ctx, &error_abort);
809+
bdrv_try_change_aio_context(target, main_ctx, NULL, &error_abort);
810810
aio_context_release(ctx);
811811

812812
blk_unref(blk);

0 commit comments

Comments
 (0)