[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 2/8] block: protect write threshold QMP commands from concurre
From: |
Emanuele Giuseppe Esposito |
Subject: |
[PATCH v2 2/8] block: protect write threshold QMP commands from concurrent requests |
Date: |
Mon, 19 Apr 2021 10:55:35 +0200 |
For simplicity, use bdrv_drained_begin/end to avoid concurrent
writes to the write threshold, or reading it while it is being set.
qmp_block_set_write_threshold is protected by the BQL.
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Co-developed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
block/write-threshold.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/block/write-threshold.c b/block/write-threshold.c
index 63040fa4f2..77c74bdaa7 100644
--- a/block/write-threshold.c
+++ b/block/write-threshold.c
@@ -111,7 +111,6 @@ void qmp_block_set_write_threshold(const char *node_name,
Error **errp)
{
BlockDriverState *bs;
- AioContext *aio_context;
bs = bdrv_find_node(node_name);
if (!bs) {
@@ -119,10 +118,8 @@ void qmp_block_set_write_threshold(const char *node_name,
return;
}
- aio_context = bdrv_get_aio_context(bs);
- aio_context_acquire(aio_context);
-
+ /* Avoid a concurrent write_threshold_disable. */
+ bdrv_drained_begin(bs);
bdrv_write_threshold_set(bs, threshold_bytes);
-
- aio_context_release(aio_context);
+ bdrv_drained_end(bs);
}
--
2.30.2
- [PATCH v2 0/8] Block layer thread-safety, continued, Emanuele Giuseppe Esposito, 2021/04/19
- [PATCH v2 1/8] block: prepare write threshold code for thread safety, Emanuele Giuseppe Esposito, 2021/04/19
- [PATCH v2 2/8] block: protect write threshold QMP commands from concurrent requests,
Emanuele Giuseppe Esposito <=
- [PATCH v2 3/8] util: use RCU accessors for notifiers, Emanuele Giuseppe Esposito, 2021/04/19
- [PATCH v2 4/8] block: make before-write notifiers thread-safe, Emanuele Giuseppe Esposito, 2021/04/19
- [PATCH v2 5/8] block: add a few more notes on locking, Emanuele Giuseppe Esposito, 2021/04/19
- [PATCH v2 6/8] block: do not acquire AioContext in check_to_replace_node, Emanuele Giuseppe Esposito, 2021/04/19
- [PATCH v2 7/8] block/replication: do not acquire AioContext, Emanuele Giuseppe Esposito, 2021/04/19
- [PATCH v2 8/8] block: do not take AioContext around reopen, Emanuele Giuseppe Esposito, 2021/04/19
- Re: [PATCH v2 0/8] Block layer thread-safety, continued, Paolo Bonzini, 2021/04/21