Skip to content

Commit 6bc30f1

Browse files
stefanhaRHkevmw
authored andcommitted
graph-lock: remove AioContext locking
Stop acquiring/releasing the AioContext lock in bdrv_graph_wrlock()/bdrv_graph_unlock() since the lock no longer has any effect. The distinction between bdrv_graph_wrunlock() and bdrv_graph_wrunlock_ctx() becomes meaningless and they can be collapsed into one function. Signed-off-by: Stefan Hajnoczi <[email protected]> Reviewed-by: Eric Blake <[email protected]> Reviewed-by: Kevin Wolf <[email protected]> Message-ID: <[email protected]> Signed-off-by: Kevin Wolf <[email protected]>
1 parent b5f4fda commit 6bc30f1

20 files changed

+133
-193
lines changed

block.c

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,12 +1708,12 @@ bdrv_open_driver(BlockDriverState *bs, BlockDriver *drv, const char *node_name,
17081708
open_failed:
17091709
bs->drv = NULL;
17101710

1711-
bdrv_graph_wrlock(NULL);
1711+
bdrv_graph_wrlock();
17121712
if (bs->file != NULL) {
17131713
bdrv_unref_child(bs, bs->file);
17141714
assert(!bs->file);
17151715
}
1716-
bdrv_graph_wrunlock(NULL);
1716+
bdrv_graph_wrunlock();
17171717

17181718
g_free(bs->opaque);
17191719
bs->opaque = NULL;
@@ -3575,9 +3575,9 @@ int bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd,
35753575

35763576
bdrv_ref(drain_bs);
35773577
bdrv_drained_begin(drain_bs);
3578-
bdrv_graph_wrlock(backing_hd);
3578+
bdrv_graph_wrlock();
35793579
ret = bdrv_set_backing_hd_drained(bs, backing_hd, errp);
3580-
bdrv_graph_wrunlock(backing_hd);
3580+
bdrv_graph_wrunlock();
35813581
bdrv_drained_end(drain_bs);
35823582
bdrv_unref(drain_bs);
35833583

@@ -3790,13 +3790,13 @@ BdrvChild *bdrv_open_child(const char *filename,
37903790
return NULL;
37913791
}
37923792

3793-
bdrv_graph_wrlock(NULL);
3793+
bdrv_graph_wrlock();
37943794
ctx = bdrv_get_aio_context(bs);
37953795
aio_context_acquire(ctx);
37963796
child = bdrv_attach_child(parent, bs, bdref_key, child_class, child_role,
37973797
errp);
37983798
aio_context_release(ctx);
3799-
bdrv_graph_wrunlock(NULL);
3799+
bdrv_graph_wrunlock();
38003800

38013801
return child;
38023802
}
@@ -4650,9 +4650,9 @@ int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, Error **errp)
46504650
aio_context_release(ctx);
46514651
}
46524652

4653-
bdrv_graph_wrlock(NULL);
4653+
bdrv_graph_wrlock();
46544654
tran_commit(tran);
4655-
bdrv_graph_wrunlock(NULL);
4655+
bdrv_graph_wrunlock();
46564656

46574657
QTAILQ_FOREACH_REVERSE(bs_entry, bs_queue, entry) {
46584658
BlockDriverState *bs = bs_entry->state.bs;
@@ -4669,9 +4669,9 @@ int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, Error **errp)
46694669
goto cleanup;
46704670

46714671
abort:
4672-
bdrv_graph_wrlock(NULL);
4672+
bdrv_graph_wrlock();
46734673
tran_abort(tran);
4674-
bdrv_graph_wrunlock(NULL);
4674+
bdrv_graph_wrunlock();
46754675

46764676
QTAILQ_FOREACH_SAFE(bs_entry, bs_queue, entry, next) {
46774677
if (bs_entry->prepared) {
@@ -4852,12 +4852,12 @@ bdrv_reopen_parse_file_or_backing(BDRVReopenState *reopen_state,
48524852
}
48534853

48544854
bdrv_graph_rdunlock_main_loop();
4855-
bdrv_graph_wrlock(new_child_bs);
4855+
bdrv_graph_wrlock();
48564856

48574857
ret = bdrv_set_file_or_backing_noperm(bs, new_child_bs, is_backing,
48584858
tran, errp);
48594859

4860-
bdrv_graph_wrunlock_ctx(ctx);
4860+
bdrv_graph_wrunlock();
48614861

48624862
if (old_ctx != ctx) {
48634863
aio_context_release(ctx);
@@ -5209,14 +5209,14 @@ static void bdrv_close(BlockDriverState *bs)
52095209
bs->drv = NULL;
52105210
}
52115211

5212-
bdrv_graph_wrlock(bs);
5212+
bdrv_graph_wrlock();
52135213
QLIST_FOREACH_SAFE(child, &bs->children, next, next) {
52145214
bdrv_unref_child(bs, child);
52155215
}
52165216

52175217
assert(!bs->backing);
52185218
assert(!bs->file);
5219-
bdrv_graph_wrunlock(bs);
5219+
bdrv_graph_wrunlock();
52205220

52215221
g_free(bs->opaque);
52225222
bs->opaque = NULL;
@@ -5509,9 +5509,9 @@ int bdrv_drop_filter(BlockDriverState *bs, Error **errp)
55095509
bdrv_graph_rdunlock_main_loop();
55105510

55115511
bdrv_drained_begin(child_bs);
5512-
bdrv_graph_wrlock(bs);
5512+
bdrv_graph_wrlock();
55135513
ret = bdrv_replace_node_common(bs, child_bs, true, true, errp);
5514-
bdrv_graph_wrunlock(bs);
5514+
bdrv_graph_wrunlock();
55155515
bdrv_drained_end(child_bs);
55165516

55175517
return ret;
@@ -5561,7 +5561,7 @@ int bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top,
55615561
aio_context_acquire(old_context);
55625562
new_context = NULL;
55635563

5564-
bdrv_graph_wrlock(bs_top);
5564+
bdrv_graph_wrlock();
55655565

55665566
child = bdrv_attach_child_noperm(bs_new, bs_top, "backing",
55675567
&child_of_bds, bdrv_backing_role(bs_new),
@@ -5593,7 +5593,7 @@ int bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top,
55935593
tran_finalize(tran, ret);
55945594

55955595
bdrv_refresh_limits(bs_top, NULL, NULL);
5596-
bdrv_graph_wrunlock(bs_top);
5596+
bdrv_graph_wrunlock();
55975597

55985598
bdrv_drained_end(bs_top);
55995599
bdrv_drained_end(bs_new);
@@ -5620,7 +5620,7 @@ int bdrv_replace_child_bs(BdrvChild *child, BlockDriverState *new_bs,
56205620
bdrv_ref(old_bs);
56215621
bdrv_drained_begin(old_bs);
56225622
bdrv_drained_begin(new_bs);
5623-
bdrv_graph_wrlock(new_bs);
5623+
bdrv_graph_wrlock();
56245624

56255625
bdrv_replace_child_tran(child, new_bs, tran);
56265626

@@ -5631,7 +5631,7 @@ int bdrv_replace_child_bs(BdrvChild *child, BlockDriverState *new_bs,
56315631

56325632
tran_finalize(tran, ret);
56335633

5634-
bdrv_graph_wrunlock(new_bs);
5634+
bdrv_graph_wrunlock();
56355635
bdrv_drained_end(old_bs);
56365636
bdrv_drained_end(new_bs);
56375637
bdrv_unref(old_bs);
@@ -5718,9 +5718,9 @@ BlockDriverState *bdrv_insert_node(BlockDriverState *bs, QDict *options,
57185718
bdrv_ref(bs);
57195719
bdrv_drained_begin(bs);
57205720
bdrv_drained_begin(new_node_bs);
5721-
bdrv_graph_wrlock(new_node_bs);
5721+
bdrv_graph_wrlock();
57225722
ret = bdrv_replace_node(bs, new_node_bs, errp);
5723-
bdrv_graph_wrunlock(new_node_bs);
5723+
bdrv_graph_wrunlock();
57245724
bdrv_drained_end(new_node_bs);
57255725
bdrv_drained_end(bs);
57265726
bdrv_unref(bs);
@@ -5975,7 +5975,7 @@ int bdrv_drop_intermediate(BlockDriverState *top, BlockDriverState *base,
59755975

59765976
bdrv_ref(top);
59775977
bdrv_drained_begin(base);
5978-
bdrv_graph_wrlock(base);
5978+
bdrv_graph_wrlock();
59795979

59805980
if (!top->drv || !base->drv) {
59815981
goto exit_wrlock;
@@ -6015,7 +6015,7 @@ int bdrv_drop_intermediate(BlockDriverState *top, BlockDriverState *base,
60156015
* That's a FIXME.
60166016
*/
60176017
bdrv_replace_node_common(top, base, false, false, &local_err);
6018-
bdrv_graph_wrunlock(base);
6018+
bdrv_graph_wrunlock();
60196019

60206020
if (local_err) {
60216021
error_report_err(local_err);
@@ -6052,7 +6052,7 @@ int bdrv_drop_intermediate(BlockDriverState *top, BlockDriverState *base,
60526052
goto exit;
60536053

60546054
exit_wrlock:
6055-
bdrv_graph_wrunlock(base);
6055+
bdrv_graph_wrunlock();
60566056
exit:
60576057
bdrv_drained_end(base);
60586058
bdrv_unref(top);

block/backup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,10 +496,10 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
496496
block_copy_set_speed(bcs, speed);
497497

498498
/* Required permissions are taken by copy-before-write filter target */
499-
bdrv_graph_wrlock(target);
499+
bdrv_graph_wrlock();
500500
block_job_add_bdrv(&job->common, "target", target, 0, BLK_PERM_ALL,
501501
&error_abort);
502-
bdrv_graph_wrunlock(target);
502+
bdrv_graph_wrunlock();
503503

504504
return &job->common;
505505

block/blklogwrites.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,9 @@ static int blk_log_writes_open(BlockDriverState *bs, QDict *options, int flags,
251251
ret = 0;
252252
fail_log:
253253
if (ret < 0) {
254-
bdrv_graph_wrlock(NULL);
254+
bdrv_graph_wrlock();
255255
bdrv_unref_child(bs, s->log_file);
256-
bdrv_graph_wrunlock(NULL);
256+
bdrv_graph_wrunlock();
257257
s->log_file = NULL;
258258
}
259259
fail:
@@ -265,10 +265,10 @@ static void blk_log_writes_close(BlockDriverState *bs)
265265
{
266266
BDRVBlkLogWritesState *s = bs->opaque;
267267

268-
bdrv_graph_wrlock(NULL);
268+
bdrv_graph_wrlock();
269269
bdrv_unref_child(bs, s->log_file);
270270
s->log_file = NULL;
271-
bdrv_graph_wrunlock(NULL);
271+
bdrv_graph_wrunlock();
272272
}
273273

274274
static int64_t coroutine_fn GRAPH_RDLOCK

block/blkverify.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,10 @@ static void blkverify_close(BlockDriverState *bs)
151151
{
152152
BDRVBlkverifyState *s = bs->opaque;
153153

154-
bdrv_graph_wrlock(NULL);
154+
bdrv_graph_wrlock();
155155
bdrv_unref_child(bs, s->test_file);
156156
s->test_file = NULL;
157-
bdrv_graph_wrunlock(NULL);
157+
bdrv_graph_wrunlock();
158158
}
159159

160160
static int64_t coroutine_fn GRAPH_RDLOCK

block/block-backend.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,6 @@ void blk_remove_bs(BlockBackend *blk)
889889
{
890890
ThrottleGroupMember *tgm = &blk->public.throttle_group_member;
891891
BdrvChild *root;
892-
AioContext *ctx;
893892

894893
GLOBAL_STATE_CODE();
895894

@@ -919,10 +918,9 @@ void blk_remove_bs(BlockBackend *blk)
919918
root = blk->root;
920919
blk->root = NULL;
921920

922-
ctx = bdrv_get_aio_context(root->bs);
923-
bdrv_graph_wrlock(root->bs);
921+
bdrv_graph_wrlock();
924922
bdrv_root_unref_child(root);
925-
bdrv_graph_wrunlock_ctx(ctx);
923+
bdrv_graph_wrunlock();
926924
}
927925

928926
/*
@@ -933,16 +931,15 @@ void blk_remove_bs(BlockBackend *blk)
933931
int blk_insert_bs(BlockBackend *blk, BlockDriverState *bs, Error **errp)
934932
{
935933
ThrottleGroupMember *tgm = &blk->public.throttle_group_member;
936-
AioContext *ctx = bdrv_get_aio_context(bs);
937934

938935
GLOBAL_STATE_CODE();
939936
bdrv_ref(bs);
940-
bdrv_graph_wrlock(bs);
937+
bdrv_graph_wrlock();
941938
blk->root = bdrv_root_attach_child(bs, "root", &child_root,
942939
BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY,
943940
blk->perm, blk->shared_perm,
944941
blk, errp);
945-
bdrv_graph_wrunlock_ctx(ctx);
942+
bdrv_graph_wrunlock();
946943
if (blk->root == NULL) {
947944
return -EPERM;
948945
}

block/commit.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ static void commit_abort(Job *job)
100100
bdrv_graph_rdunlock_main_loop();
101101

102102
bdrv_drained_begin(commit_top_backing_bs);
103-
bdrv_graph_wrlock(commit_top_backing_bs);
103+
bdrv_graph_wrlock();
104104
bdrv_replace_node(s->commit_top_bs, commit_top_backing_bs, &error_abort);
105-
bdrv_graph_wrunlock(commit_top_backing_bs);
105+
bdrv_graph_wrunlock();
106106
bdrv_drained_end(commit_top_backing_bs);
107107

108108
bdrv_unref(s->commit_top_bs);
@@ -339,7 +339,7 @@ void commit_start(const char *job_id, BlockDriverState *bs,
339339
* this is the responsibility of the interface (i.e. whoever calls
340340
* commit_start()).
341341
*/
342-
bdrv_graph_wrlock(top);
342+
bdrv_graph_wrlock();
343343
s->base_overlay = bdrv_find_overlay(top, base);
344344
assert(s->base_overlay);
345345

@@ -370,19 +370,19 @@ void commit_start(const char *job_id, BlockDriverState *bs,
370370
ret = block_job_add_bdrv(&s->common, "intermediate node", iter, 0,
371371
iter_shared_perms, errp);
372372
if (ret < 0) {
373-
bdrv_graph_wrunlock(top);
373+
bdrv_graph_wrunlock();
374374
goto fail;
375375
}
376376
}
377377

378378
if (bdrv_freeze_backing_chain(commit_top_bs, base, errp) < 0) {
379-
bdrv_graph_wrunlock(top);
379+
bdrv_graph_wrunlock();
380380
goto fail;
381381
}
382382
s->chain_frozen = true;
383383

384384
ret = block_job_add_bdrv(&s->common, "base", base, 0, BLK_PERM_ALL, errp);
385-
bdrv_graph_wrunlock(top);
385+
bdrv_graph_wrunlock();
386386

387387
if (ret < 0) {
388388
goto fail;
@@ -434,9 +434,9 @@ void commit_start(const char *job_id, BlockDriverState *bs,
434434
* otherwise this would fail because of lack of permissions. */
435435
if (commit_top_bs) {
436436
bdrv_drained_begin(top);
437-
bdrv_graph_wrlock(top);
437+
bdrv_graph_wrlock();
438438
bdrv_replace_node(commit_top_bs, top, &error_abort);
439-
bdrv_graph_wrunlock(top);
439+
bdrv_graph_wrunlock();
440440
bdrv_drained_end(top);
441441
}
442442
}

0 commit comments

Comments
 (0)