[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 18/21] raw-posix: return get_block_status data an
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH v4 18/21] raw-posix: return get_block_status data and flags |
Date: |
Thu, 29 Aug 2013 16:00:18 +0200 |
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
block/raw-posix.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/block/raw-posix.c b/block/raw-posix.c
index dbc65b0..d011cfd 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -1089,7 +1089,7 @@ static int64_t coroutine_fn
raw_co_get_block_status(BlockDriverState *bs,
int nb_sectors, int *pnum)
{
off_t start, data, hole;
- int ret;
+ int64_t ret;
ret = fd_open(bs);
if (ret < 0) {
@@ -1097,6 +1097,7 @@ static int64_t coroutine_fn
raw_co_get_block_status(BlockDriverState *bs,
}
start = sector_num * BDRV_SECTOR_SIZE;
+ ret = BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | start;
#ifdef CONFIG_FIEMAP
@@ -1114,7 +1115,7 @@ static int64_t coroutine_fn
raw_co_get_block_status(BlockDriverState *bs,
if (ioctl(s->fd, FS_IOC_FIEMAP, &f) == -1) {
/* Assume everything is allocated. */
*pnum = nb_sectors;
- return 1;
+ return ret;
}
if (f.fm.fm_mapped_extents == 0) {
@@ -1141,7 +1142,7 @@ static int64_t coroutine_fn
raw_co_get_block_status(BlockDriverState *bs,
/* Most likely EINVAL. Assume everything is allocated. */
*pnum = nb_sectors;
- return 1;
+ return ret;
}
if (hole > start) {
@@ -1154,19 +1155,21 @@ static int64_t coroutine_fn
raw_co_get_block_status(BlockDriverState *bs,
}
}
#else
- *pnum = nb_sectors;
- return 1;
+ data = 0;
+ hole = start + nb_sectors * BDRV_SECTOR_SIZE;
#endif
if (data <= start) {
/* On a data extent, compute sectors to the end of the extent. */
*pnum = MIN(nb_sectors, (hole - start) / BDRV_SECTOR_SIZE);
- return 1;
} else {
/* On a hole, compute sectors to the beginning of the next extent. */
*pnum = MIN(nb_sectors, (data - start) / BDRV_SECTOR_SIZE);
- return 0;
+ ret &= ~BDRV_BLOCK_DATA;
+ ret |= BDRV_BLOCK_ZERO;
}
+
+ return ret;
}
static coroutine_fn BlockDriverAIOCB *raw_aio_discard(BlockDriverState *bs,
--
1.8.3.1
- [Qemu-devel] [PATCH v4 09/21] qemu-img: always probe the input image for allocated sectors, (continued)
- [Qemu-devel] [PATCH v4 09/21] qemu-img: always probe the input image for allocated sectors, Paolo Bonzini, 2013/08/29
- [Qemu-devel] [PATCH v4 10/21] block: make bdrv_has_zero_init return false for copy-on-write-images, Paolo Bonzini, 2013/08/29
- [Qemu-devel] [PATCH v4 13/21] block: return get_block_status data and flags for formats, Paolo Bonzini, 2013/08/29
- [Qemu-devel] [PATCH v4 11/21] block: introduce bdrv_get_block_status API, Paolo Bonzini, 2013/08/29
- [Qemu-devel] [PATCH v4 12/21] block: define get_block_status return value, Paolo Bonzini, 2013/08/29
- [Qemu-devel] [PATCH v4 14/21] block: use bdrv_has_zero_init to return BDRV_BLOCK_ZERO, Paolo Bonzini, 2013/08/29
- [Qemu-devel] [PATCH v4 15/21] block: return BDRV_BLOCK_ZERO past end of backing file, Paolo Bonzini, 2013/08/29
- [Qemu-devel] [PATCH v4 16/21] qemu-img: add a "map" subcommand, Paolo Bonzini, 2013/08/29
- [Qemu-devel] [PATCH v4 17/21] docs, qapi: document qemu-img map, Paolo Bonzini, 2013/08/29
- [Qemu-devel] [PATCH v4 18/21] raw-posix: return get_block_status data and flags,
Paolo Bonzini <=
- [Qemu-devel] [PATCH v4 19/21] raw-posix: report unwritten extents as zero, Paolo Bonzini, 2013/08/29
- [Qemu-devel] [PATCH v4 20/21] block: add default get_block_status implementation for protocols, Paolo Bonzini, 2013/08/29
- [Qemu-devel] [PATCH v4 21/21] block: look for zero blocks in bs->file, Paolo Bonzini, 2013/08/29