|
|
9ae3a8 |
From 971e56af33f89b4e11a2e6b07b389d729756b9ed Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Date: Tue, 3 Dec 2013 14:55:55 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 17/37] block: Allow waiting for overlapping requests between begin/end
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Message-id: <1392117622-28812-18-git-send-email-kwolf@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 57182
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 17/37] block: Allow waiting for overlapping requests between begin/end
|
|
|
9ae3a8 |
Bugzilla: 748906
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Previously, it was not possible to use wait_for_overlapping_requests()
|
|
|
9ae3a8 |
between tracked_request_begin()/end() because it would wait for itself.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Ignore the current request in the overlap check and run more of the
|
|
|
9ae3a8 |
bdrv_co_do_preadv/pwritev code with a BdrvTrackedRequest present.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Benoit Canet <benoit@irqsave.net>
|
|
|
9ae3a8 |
(cherry picked from commit 65afd211c71fc91750d8a18f9604c1e57a5202fb)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Conflicts:
|
|
|
9ae3a8 |
block.c
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Conflicts because in RHEL 7 write notifiers don't exist.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block.c | 36 +++++++++++++++++++-----------------
|
|
|
9ae3a8 |
1 file changed, 19 insertions(+), 17 deletions(-)
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block.c | 36 +++++++++++++++++++-----------------
|
|
|
9ae3a8 |
1 files changed, 19 insertions(+), 17 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block.c b/block.c
|
|
|
9ae3a8 |
index 09bb127..645bcd0 100644
|
|
|
9ae3a8 |
--- a/block.c
|
|
|
9ae3a8 |
+++ b/block.c
|
|
|
9ae3a8 |
@@ -2129,7 +2129,7 @@ static bool tracked_request_overlaps(BdrvTrackedRequest *req,
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static void coroutine_fn wait_for_overlapping_requests(BlockDriverState *bs,
|
|
|
9ae3a8 |
- int64_t offset, unsigned int bytes)
|
|
|
9ae3a8 |
+ BdrvTrackedRequest *self, int64_t offset, unsigned int bytes)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
BdrvTrackedRequest *req;
|
|
|
9ae3a8 |
int64_t cluster_offset;
|
|
|
9ae3a8 |
@@ -2147,6 +2147,9 @@ static void coroutine_fn wait_for_overlapping_requests(BlockDriverState *bs,
|
|
|
9ae3a8 |
do {
|
|
|
9ae3a8 |
retry = false;
|
|
|
9ae3a8 |
QLIST_FOREACH(req, &bs->tracked_requests, list) {
|
|
|
9ae3a8 |
+ if (req == self) {
|
|
|
9ae3a8 |
+ continue;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
if (tracked_request_overlaps(req, cluster_offset, cluster_bytes)) {
|
|
|
9ae3a8 |
/* Hitting this means there was a reentrant request, for
|
|
|
9ae3a8 |
* example, a block driver issuing nested requests. This must
|
|
|
9ae3a8 |
@@ -2744,10 +2747,10 @@ err:
|
|
|
9ae3a8 |
* implemented by the caller.
|
|
|
9ae3a8 |
*/
|
|
|
9ae3a8 |
static int coroutine_fn bdrv_aligned_preadv(BlockDriverState *bs,
|
|
|
9ae3a8 |
- int64_t offset, unsigned int bytes, QEMUIOVector *qiov, int flags)
|
|
|
9ae3a8 |
+ BdrvTrackedRequest *req, int64_t offset, unsigned int bytes,
|
|
|
9ae3a8 |
+ QEMUIOVector *qiov, int flags)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
BlockDriver *drv = bs->drv;
|
|
|
9ae3a8 |
- BdrvTrackedRequest req;
|
|
|
9ae3a8 |
int ret;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
int64_t sector_num = offset >> BDRV_SECTOR_BITS;
|
|
|
9ae3a8 |
@@ -2762,11 +2765,9 @@ static int coroutine_fn bdrv_aligned_preadv(BlockDriverState *bs,
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (bs->copy_on_read_in_flight) {
|
|
|
9ae3a8 |
- wait_for_overlapping_requests(bs, offset, bytes);
|
|
|
9ae3a8 |
+ wait_for_overlapping_requests(bs, req, offset, bytes);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- tracked_request_begin(&req, bs, offset, bytes, false);
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
if (flags & BDRV_REQ_COPY_ON_READ) {
|
|
|
9ae3a8 |
int pnum;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -2813,8 +2814,6 @@ static int coroutine_fn bdrv_aligned_preadv(BlockDriverState *bs,
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
out:
|
|
|
9ae3a8 |
- tracked_request_end(&req;;
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
if (flags & BDRV_REQ_COPY_ON_READ) {
|
|
|
9ae3a8 |
bs->copy_on_read_in_flight--;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -2830,6 +2829,8 @@ static int coroutine_fn bdrv_co_do_preadv(BlockDriverState *bs,
|
|
|
9ae3a8 |
BdrvRequestFlags flags)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
BlockDriver *drv = bs->drv;
|
|
|
9ae3a8 |
+ BdrvTrackedRequest req;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
/* TODO Lift BDRV_SECTOR_SIZE restriction in BlockDriver interface */
|
|
|
9ae3a8 |
uint64_t align = MAX(BDRV_SECTOR_SIZE, bs->request_alignment);
|
|
|
9ae3a8 |
uint8_t *head_buf = NULL;
|
|
|
9ae3a8 |
@@ -2880,9 +2881,11 @@ static int coroutine_fn bdrv_co_do_preadv(BlockDriverState *bs,
|
|
|
9ae3a8 |
bytes = ROUND_UP(bytes, align);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- ret = bdrv_aligned_preadv(bs, offset, bytes,
|
|
|
9ae3a8 |
+ tracked_request_begin(&req, bs, offset, bytes, false);
|
|
|
9ae3a8 |
+ ret = bdrv_aligned_preadv(bs, &req, offset, bytes,
|
|
|
9ae3a8 |
use_local_qiov ? &local_qiov : qiov,
|
|
|
9ae3a8 |
flags);
|
|
|
9ae3a8 |
+ tracked_request_end(&req;;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (use_local_qiov) {
|
|
|
9ae3a8 |
qemu_iovec_destroy(&local_qiov);
|
|
|
9ae3a8 |
@@ -3001,10 +3004,10 @@ static int coroutine_fn bdrv_co_do_write_zeroes(BlockDriverState *bs,
|
|
|
9ae3a8 |
* Forwards an already correctly aligned write request to the BlockDriver.
|
|
|
9ae3a8 |
*/
|
|
|
9ae3a8 |
static int coroutine_fn bdrv_aligned_pwritev(BlockDriverState *bs,
|
|
|
9ae3a8 |
- int64_t offset, unsigned int bytes, QEMUIOVector *qiov, int flags)
|
|
|
9ae3a8 |
+ BdrvTrackedRequest *req, int64_t offset, unsigned int bytes,
|
|
|
9ae3a8 |
+ QEMUIOVector *qiov, int flags)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
BlockDriver *drv = bs->drv;
|
|
|
9ae3a8 |
- BdrvTrackedRequest req;
|
|
|
9ae3a8 |
int ret;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
int64_t sector_num = offset >> BDRV_SECTOR_BITS;
|
|
|
9ae3a8 |
@@ -3014,11 +3017,9 @@ static int coroutine_fn bdrv_aligned_pwritev(BlockDriverState *bs,
|
|
|
9ae3a8 |
assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (bs->copy_on_read_in_flight) {
|
|
|
9ae3a8 |
- wait_for_overlapping_requests(bs, offset, bytes);
|
|
|
9ae3a8 |
+ wait_for_overlapping_requests(bs, req, offset, bytes);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- tracked_request_begin(&req, bs, offset, bytes, true);
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
if (flags & BDRV_REQ_ZERO_WRITE) {
|
|
|
9ae3a8 |
ret = bdrv_co_do_write_zeroes(bs, sector_num, nb_sectors, flags);
|
|
|
9ae3a8 |
} else {
|
|
|
9ae3a8 |
@@ -3040,8 +3041,6 @@ static int coroutine_fn bdrv_aligned_pwritev(BlockDriverState *bs,
|
|
|
9ae3a8 |
bs->total_sectors = MAX(bs->total_sectors, sector_num + nb_sectors);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- tracked_request_end(&req;;
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
return ret;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -3052,6 +3051,7 @@ static int coroutine_fn bdrv_co_do_pwritev(BlockDriverState *bs,
|
|
|
9ae3a8 |
int64_t offset, unsigned int bytes, QEMUIOVector *qiov,
|
|
|
9ae3a8 |
BdrvRequestFlags flags)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
+ BdrvTrackedRequest req;
|
|
|
9ae3a8 |
int ret;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (!bs->drv) {
|
|
|
9ae3a8 |
@@ -3070,7 +3070,9 @@ static int coroutine_fn bdrv_co_do_pwritev(BlockDriverState *bs,
|
|
|
9ae3a8 |
bdrv_io_limits_intercept(bs, true, bytes >> BDRV_SECTOR_BITS);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- ret = bdrv_aligned_pwritev(bs, offset, bytes, qiov, flags);
|
|
|
9ae3a8 |
+ tracked_request_begin(&req, bs, offset, bytes, true);
|
|
|
9ae3a8 |
+ ret = bdrv_aligned_pwritev(bs, &req, offset, bytes, qiov, flags);
|
|
|
9ae3a8 |
+ tracked_request_end(&req;;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
return ret;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|