[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v1.5 06.5/31] fixup! block: Convert bdrv_get_block_s
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PATCH v1.5 06.5/31] fixup! block: Convert bdrv_get_block_status() to bytes |
Date: |
Tue, 18 Apr 2017 16:34:04 -0500 |
[adjust a paragraph of the original commit message]
...
Note that we have an inherent limitation in the BDRV_BLOCK_* return
values: BDRV_BLOCK_OFFSET_VALID can only return the start of a
sector, even if we later relax the interface to query for the status
starting at an intermediate byte; document the obvious interpretation
that valid offsets are always sector-relative. Furthermore, note that
many callers are expecting sector-aligned answers, especially since
bdrv_getlength() is sector-aligned even when it exceeds the actual
file size; so we intentionally lie and state that any partial sector
at the end of a file has the same status for the entire sector,
rather than a literal interpretation of a hole starting at a
mid-sector location due to end-of-file.
...
Signed-off-by: Eric Blake <address@hidden>
---
This was sufficient to avoid failure of qemu-iotests 109 after patch
13/31 adjusts file-posix.c to clamp EOF numbers to mid-sector locations.
block/io.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/block/io.c b/block/io.c
index 361eeb8..bee6c71 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1769,6 +1769,14 @@ static int64_t coroutine_fn
bdrv_co_block_status(BlockDriverState *bs,
bs->bl.request_alignment) - aligned_offset;
ret = bs->drv->bdrv_co_block_status(bs, aligned_offset, aligned_bytes,
&n, file);
+
+ /* total_size is always sector-aligned, by sometimes exceeding actual
+ * file size. Expand n if it lands mid-sector due to end-of-file. */
+ if (ret >= 0 && QEMU_ALIGN_UP(n + aligned_offset,
+ BDRV_SECTOR_SIZE) == total_size) {
+ n = total_size - aligned_offset;
+ }
+
/* Clamp pnum and ret to original request */
if (aligned_offset != offset && ret >= 0) {
int sectors = DIV_ROUND_UP(offset, BDRV_SECTOR_SIZE) -
--
2.9.3
- [Qemu-devel] [PATCH 00/31] make bdrv_get_block_status byte-based, Eric Blake, 2017/04/17
- [Qemu-devel] [PATCH 01/31] block: Drop unused bdrv_round_sectors_to_clusters(), Eric Blake, 2017/04/17
- [Qemu-devel] [PATCH 02/31] block: Make bdrv_round_to_clusters() signature more useful, Eric Blake, 2017/04/17
- [Qemu-devel] [PATCH 03/31] qcow2: Switch is_zero_sectors() to byte-based, Eric Blake, 2017/04/17
- [Qemu-devel] [PATCH 04/31] block: Switch bdrv_make_zero() to byte-based, Eric Blake, 2017/04/17
- [Qemu-devel] [PATCH 05/31] qemu-img: Switch get_block_status() to byte-based, Eric Blake, 2017/04/17
- [Qemu-devel] [PATCH 06/31] block: Convert bdrv_get_block_status() to bytes, Eric Blake, 2017/04/17
- [Qemu-devel] [PATCH v1.5 06.5/31] fixup! block: Convert bdrv_get_block_status() to bytes,
Eric Blake <=
- [Qemu-devel] [PATCH 07/31] block: Switch bdrv_co_get_block_status() to byte-based, Eric Blake, 2017/04/17
- [Qemu-devel] [PATCH 08/31] block: Switch BdrvCoGetBlockStatusData to byte-based, Eric Blake, 2017/04/17
- [Qemu-devel] [PATCH 09/31] block: Switch bdrv_co_get_block_status_above() to byte-based, Eric Blake, 2017/04/17
- [Qemu-devel] [PATCH 10/31] block: Convert bdrv_get_block_status_above() to bytes, Eric Blake, 2017/04/17
- [Qemu-devel] [PATCH 12/31] commit: Switch to .bdrv_co_block_status(), Eric Blake, 2017/04/17
- [Qemu-devel] [PATCH 11/31] block: Add .bdrv_co_block_status() callback, Eric Blake, 2017/04/17
- [Qemu-devel] [PATCH 13/31] file-posix: Switch to .bdrv_co_block_status(), Eric Blake, 2017/04/17
- [Qemu-devel] [PATCH 14/31] gluster: Switch to .bdrv_co_block_status(), Eric Blake, 2017/04/17