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