a47d6566ab
Include latest upstream disk corruption fix - hopefully that's all of them! OBS-URL: https://build.opensuse.org/request/show/746103 OBS-URL: https://build.opensuse.org/package/show/Virtualization/qemu?expand=0&rev=505
127 lines
5.1 KiB
Diff
127 lines
5.1 KiB
Diff
From: Max Reitz <mreitz@redhat.com>
|
|
Date: Fri, 1 Nov 2019 16:25:08 +0100
|
|
Subject: block: Make wait/mark serialising requests public
|
|
|
|
Git-commit: 304d9d7f034ff7f5e1e66a65b7f720f63a72c57e
|
|
|
|
Make both bdrv_mark_request_serialising() and
|
|
bdrv_wait_serialising_requests() public so they can be used from block
|
|
drivers.
|
|
|
|
Cc: qemu-stable@nongnu.org
|
|
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
Message-id: 20191101152510.11719-2-mreitz@redhat.com
|
|
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
Signed-off-by: Bruce Rogers <brogers@suse.com>
|
|
---
|
|
block/io.c | 24 ++++++++++++------------
|
|
include/block/block_int.h | 3 +++
|
|
2 files changed, 15 insertions(+), 12 deletions(-)
|
|
|
|
diff --git a/block/io.c b/block/io.c
|
|
index bfb2653d8ee853e99bd4d55a1a87..d9f632f450b744515d3f91d2aa26 100644
|
|
--- a/block/io.c
|
|
+++ b/block/io.c
|
|
@@ -694,7 +694,7 @@ static void tracked_request_begin(BdrvTrackedRequest *req,
|
|
qemu_co_mutex_unlock(&bs->reqs_lock);
|
|
}
|
|
|
|
-static void mark_request_serialising(BdrvTrackedRequest *req, uint64_t align)
|
|
+void bdrv_mark_request_serialising(BdrvTrackedRequest *req, uint64_t align)
|
|
{
|
|
int64_t overlap_offset = req->offset & ~(align - 1);
|
|
uint64_t overlap_bytes = ROUND_UP(req->offset + req->bytes, align)
|
|
@@ -784,7 +784,7 @@ void bdrv_dec_in_flight(BlockDriverState *bs)
|
|
bdrv_wakeup(bs);
|
|
}
|
|
|
|
-static bool coroutine_fn wait_serialising_requests(BdrvTrackedRequest *self)
|
|
+bool coroutine_fn bdrv_wait_serialising_requests(BdrvTrackedRequest *self)
|
|
{
|
|
BlockDriverState *bs = self->bs;
|
|
BdrvTrackedRequest *req;
|
|
@@ -1340,14 +1340,14 @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child,
|
|
* with each other for the same cluster. For example, in copy-on-read
|
|
* it ensures that the CoR read and write operations are atomic and
|
|
* guest writes cannot interleave between them. */
|
|
- mark_request_serialising(req, bdrv_get_cluster_size(bs));
|
|
+ bdrv_mark_request_serialising(req, bdrv_get_cluster_size(bs));
|
|
}
|
|
|
|
/* BDRV_REQ_SERIALISING is only for write operation */
|
|
assert(!(flags & BDRV_REQ_SERIALISING));
|
|
|
|
if (!(flags & BDRV_REQ_NO_SERIALISING)) {
|
|
- wait_serialising_requests(req);
|
|
+ bdrv_wait_serialising_requests(req);
|
|
}
|
|
|
|
if (flags & BDRV_REQ_COPY_ON_READ) {
|
|
@@ -1736,10 +1736,10 @@ bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, uint64_t bytes,
|
|
assert(!(flags & ~BDRV_REQ_MASK));
|
|
|
|
if (flags & BDRV_REQ_SERIALISING) {
|
|
- mark_request_serialising(req, bdrv_get_cluster_size(bs));
|
|
+ bdrv_mark_request_serialising(req, bdrv_get_cluster_size(bs));
|
|
}
|
|
|
|
- waited = wait_serialising_requests(req);
|
|
+ waited = bdrv_wait_serialising_requests(req);
|
|
|
|
assert(!waited || !req->serialising ||
|
|
is_request_serialising_and_aligned(req));
|
|
@@ -1905,8 +1905,8 @@ static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvChild *child,
|
|
|
|
padding = bdrv_init_padding(bs, offset, bytes, &pad);
|
|
if (padding) {
|
|
- mark_request_serialising(req, align);
|
|
- wait_serialising_requests(req);
|
|
+ bdrv_mark_request_serialising(req, align);
|
|
+ bdrv_wait_serialising_requests(req);
|
|
|
|
bdrv_padding_rmw_read(child, req, &pad, true);
|
|
|
|
@@ -1993,8 +1993,8 @@ int coroutine_fn bdrv_co_pwritev(BdrvChild *child,
|
|
}
|
|
|
|
if (bdrv_pad_request(bs, &qiov, &offset, &bytes, &pad)) {
|
|
- mark_request_serialising(&req, align);
|
|
- wait_serialising_requests(&req);
|
|
+ bdrv_mark_request_serialising(&req, align);
|
|
+ bdrv_wait_serialising_requests(&req);
|
|
bdrv_padding_rmw_read(child, &req, &pad, false);
|
|
}
|
|
|
|
@@ -3078,7 +3078,7 @@ static int coroutine_fn bdrv_co_copy_range_internal(
|
|
/* BDRV_REQ_SERIALISING is only for write operation */
|
|
assert(!(read_flags & BDRV_REQ_SERIALISING));
|
|
if (!(read_flags & BDRV_REQ_NO_SERIALISING)) {
|
|
- wait_serialising_requests(&req);
|
|
+ bdrv_wait_serialising_requests(&req);
|
|
}
|
|
|
|
ret = src->bs->drv->bdrv_co_copy_range_from(src->bs,
|
|
@@ -3205,7 +3205,7 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset,
|
|
* new area, we need to make sure that no write requests are made to it
|
|
* concurrently or they might be overwritten by preallocation. */
|
|
if (new_bytes) {
|
|
- mark_request_serialising(&req, 1);
|
|
+ bdrv_mark_request_serialising(&req, 1);
|
|
}
|
|
if (bs->read_only) {
|
|
error_setg(errp, "Image is read-only");
|
|
diff --git a/include/block/block_int.h b/include/block/block_int.h
|
|
index 3aa1e832a8fdf32bf3f33d1e1508..4465b022424c23aea82942547cc3 100644
|
|
--- a/include/block/block_int.h
|
|
+++ b/include/block/block_int.h
|
|
@@ -962,6 +962,9 @@ extern unsigned int bdrv_drain_all_count;
|
|
void bdrv_apply_subtree_drain(BdrvChild *child, BlockDriverState *new_parent);
|
|
void bdrv_unapply_subtree_drain(BdrvChild *child, BlockDriverState *old_parent);
|
|
|
|
+bool coroutine_fn bdrv_wait_serialising_requests(BdrvTrackedRequest *self);
|
|
+void bdrv_mark_request_serialising(BdrvTrackedRequest *req, uint64_t align);
|
|
+
|
|
int get_tmp_filename(char *filename, int size);
|
|
BlockDriver *bdrv_probe_all(const uint8_t *buf, int buf_size,
|
|
const char *filename);
|