copy-on-read: skip non-guest reads if no copy needed
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> Message-Id: <20201216061703.70908-9-vsementsov@virtuozzo.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
897dd0ec4f
commit
e275458b29
@ -50,6 +50,8 @@ static int cor_open(BlockDriverState *bs, QDict *options, int flags,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bs->supported_read_flags = BDRV_REQ_PREFETCH;
|
||||||
|
|
||||||
bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED |
|
bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED |
|
||||||
(BDRV_REQ_FUA & bs->file->bs->supported_write_flags);
|
(BDRV_REQ_FUA & bs->file->bs->supported_write_flags);
|
||||||
|
|
||||||
@ -172,11 +174,15 @@ static int coroutine_fn cor_co_preadv_part(BlockDriverState *bs,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 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,
|
ret = bdrv_co_preadv_part(bs->file, offset, n, qiov, qiov_offset,
|
||||||
local_flags);
|
local_flags);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
offset += n;
|
offset += n;
|
||||||
qiov_offset += n;
|
qiov_offset += n;
|
||||||
|
@ -72,9 +72,11 @@ typedef enum {
|
|||||||
BDRV_REQ_NO_FALLBACK = 0x100,
|
BDRV_REQ_NO_FALLBACK = 0x100,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* BDRV_REQ_PREFETCH may be used only together with BDRV_REQ_COPY_ON_READ
|
* BDRV_REQ_PREFETCH makes sense only in the context of copy-on-read
|
||||||
* on read request and means that caller doesn't really need data to be
|
* (i.e., together with the BDRV_REQ_COPY_ON_READ flag or when a COR
|
||||||
* written to qiov parameter which may be NULL.
|
* 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,
|
BDRV_REQ_PREFETCH = 0x200,
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user