[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v15 08/13] copy-on-read: skip non-guest reads if no copy needed
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH v15 08/13] copy-on-read: skip non-guest reads if no copy needed |
Date: |
Wed, 16 Dec 2020 09:16:58 +0300 |
From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
If the flag BDRV_REQ_PREFETCH was set, skip idling read/write
operations in COR-driver. It can be taken into account for the
COR-algorithms optimization. That check is being made during the
block stream job by the moment.
Add the BDRV_REQ_PREFETCH flag to the supported_read_flags of the
COR-filter.
block: Modify the comment for the flag BDRV_REQ_PREFETCH as we are
going to use it alone and pass it to the COR-filter driver for further
processing.
Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
include/block/block.h | 8 +++++---
block/copy-on-read.c | 14 ++++++++++----
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/include/block/block.h b/include/block/block.h
index 8ea794959b..f652f31406 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -81,9 +81,11 @@ typedef enum {
BDRV_REQ_NO_FALLBACK = 0x100,
/*
- * BDRV_REQ_PREFETCH may be used only together with BDRV_REQ_COPY_ON_READ
- * on read request and means that caller doesn't really need data to be
- * written to qiov parameter which may be NULL.
+ * BDRV_REQ_PREFETCH makes sense only in the context of copy-on-read
+ * (i.e., together with the BDRV_REQ_COPY_ON_READ flag or when a COR
+ * filter is involved), in which case it signals that the COR operation
+ * need not read the data into memory (qiov) but only ensure they are
+ * copied to the top layer (i.e., that COR operation is done).
*/
BDRV_REQ_PREFETCH = 0x200,
/* Mask of valid flags */
diff --git a/block/copy-on-read.c b/block/copy-on-read.c
index 71560984f6..9cad9e1b8c 100644
--- a/block/copy-on-read.c
+++ b/block/copy-on-read.c
@@ -50,6 +50,8 @@ static int cor_open(BlockDriverState *bs, QDict *options, int
flags,
return -EINVAL;
}
+ bs->supported_read_flags = BDRV_REQ_PREFETCH;
+
bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED |
(BDRV_REQ_FUA & bs->file->bs->supported_write_flags);
@@ -172,10 +174,14 @@ static int coroutine_fn
cor_co_preadv_part(BlockDriverState *bs,
}
}
- ret = bdrv_co_preadv_part(bs->file, offset, n, qiov, qiov_offset,
- local_flags);
- if (ret < 0) {
- return ret;
+ /* Skip if neither read nor write are needed */
+ if ((local_flags & (BDRV_REQ_PREFETCH | BDRV_REQ_COPY_ON_READ)) !=
+ BDRV_REQ_PREFETCH) {
+ ret = bdrv_co_preadv_part(bs->file, offset, n, qiov, qiov_offset,
+ local_flags);
+ if (ret < 0) {
+ return ret;
+ }
}
offset += n;
--
2.25.4
- [PATCH v15 00/13] Apply COR-filter to the block-stream permanently, Vladimir Sementsov-Ogievskiy, 2020/12/16
- [PATCH v15 02/13] block: add API function to insert a node, Vladimir Sementsov-Ogievskiy, 2020/12/16
- [PATCH v15 01/13] copy-on-read: support preadv/pwritev_part functions, Vladimir Sementsov-Ogievskiy, 2020/12/16
- [PATCH v15 04/13] qapi: add filter-node-name to block-stream, Vladimir Sementsov-Ogievskiy, 2020/12/16
- [PATCH v15 05/13] qapi: copy-on-read filter: add 'bottom' option, Vladimir Sementsov-Ogievskiy, 2020/12/16
- [PATCH v15 03/13] copy-on-read: add filter drop function, Vladimir Sementsov-Ogievskiy, 2020/12/16
- [PATCH v15 06/13] iotests: add #310 to test bottom node in COR driver, Vladimir Sementsov-Ogievskiy, 2020/12/16
- [PATCH v15 08/13] copy-on-read: skip non-guest reads if no copy needed,
Vladimir Sementsov-Ogievskiy <=
- [PATCH v15 09/13] stream: rework backing-file changing, Vladimir Sementsov-Ogievskiy, 2020/12/16
- [PATCH v15 10/13] qapi: block-stream: add "bottom" argument, Vladimir Sementsov-Ogievskiy, 2020/12/16
- [PATCH v15 11/13] iotests: 30: prepare to COR filter insertion by stream job, Vladimir Sementsov-Ogievskiy, 2020/12/16
- [PATCH v15 07/13] block: include supported_read_flags into BDS structure, Vladimir Sementsov-Ogievskiy, 2020/12/16
- [PATCH v15 12/13] block/stream: add s->target_bs, Vladimir Sementsov-Ogievskiy, 2020/12/16