|
|
218e99 |
From 145376957366516a0b47f4a83d93b6c0c026e469 Mon Sep 17 00:00:00 2001
|
|
|
218e99 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
218e99 |
Date: Fri, 18 Oct 2013 08:14:44 +0200
|
|
|
218e99 |
Subject: [PATCH 19/81] raw-posix: return get_block_status data and flags
|
|
|
218e99 |
|
|
|
218e99 |
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
218e99 |
Message-id: <1382084091-16636-20-git-send-email-pbonzini@redhat.com>
|
|
|
218e99 |
Patchwork-id: 55002
|
|
|
218e99 |
O-Subject: [RHEL 7.0 qemu-kvm PATCH 19/26] raw-posix: return get_block_status data and flags
|
|
|
218e99 |
Bugzilla: 989646
|
|
|
218e99 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
218e99 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
218e99 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
218e99 |
|
|
|
218e99 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
218e99 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
218e99 |
(cherry picked from commit 63390a8d14c9006f42bdaab22291c9c97676322d)
|
|
|
218e99 |
---
|
|
|
218e99 |
block/raw-posix.c | 17 ++++++++++-------
|
|
|
218e99 |
1 file changed, 10 insertions(+), 7 deletions(-)
|
|
|
218e99 |
|
|
|
218e99 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
218e99 |
---
|
|
|
218e99 |
block/raw-posix.c | 17 ++++++++++-------
|
|
|
218e99 |
1 files changed, 10 insertions(+), 7 deletions(-)
|
|
|
218e99 |
|
|
|
218e99 |
diff --git a/block/raw-posix.c b/block/raw-posix.c
|
|
|
218e99 |
index 9a7c5a8..a829ce0 100644
|
|
|
218e99 |
--- a/block/raw-posix.c
|
|
|
218e99 |
+++ b/block/raw-posix.c
|
|
|
218e99 |
@@ -1089,7 +1089,7 @@ static int64_t coroutine_fn raw_co_get_block_status(BlockDriverState *bs,
|
|
|
218e99 |
int nb_sectors, int *pnum)
|
|
|
218e99 |
{
|
|
|
218e99 |
off_t start, data, hole;
|
|
|
218e99 |
- int ret;
|
|
|
218e99 |
+ int64_t ret;
|
|
|
218e99 |
|
|
|
218e99 |
ret = fd_open(bs);
|
|
|
218e99 |
if (ret < 0) {
|
|
|
218e99 |
@@ -1097,6 +1097,7 @@ static int64_t coroutine_fn raw_co_get_block_status(BlockDriverState *bs,
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
start = sector_num * BDRV_SECTOR_SIZE;
|
|
|
218e99 |
+ ret = BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | start;
|
|
|
218e99 |
|
|
|
218e99 |
#ifdef CONFIG_FIEMAP
|
|
|
218e99 |
|
|
|
218e99 |
@@ -1114,7 +1115,7 @@ static int64_t coroutine_fn raw_co_get_block_status(BlockDriverState *bs,
|
|
|
218e99 |
if (ioctl(s->fd, FS_IOC_FIEMAP, &f) == -1) {
|
|
|
218e99 |
/* Assume everything is allocated. */
|
|
|
218e99 |
*pnum = nb_sectors;
|
|
|
218e99 |
- return 1;
|
|
|
218e99 |
+ return ret;
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
if (f.fm.fm_mapped_extents == 0) {
|
|
|
218e99 |
@@ -1141,7 +1142,7 @@ static int64_t coroutine_fn raw_co_get_block_status(BlockDriverState *bs,
|
|
|
218e99 |
|
|
|
218e99 |
/* Most likely EINVAL. Assume everything is allocated. */
|
|
|
218e99 |
*pnum = nb_sectors;
|
|
|
218e99 |
- return 1;
|
|
|
218e99 |
+ return ret;
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
if (hole > start) {
|
|
|
218e99 |
@@ -1154,19 +1155,21 @@ static int64_t coroutine_fn raw_co_get_block_status(BlockDriverState *bs,
|
|
|
218e99 |
}
|
|
|
218e99 |
}
|
|
|
218e99 |
#else
|
|
|
218e99 |
- *pnum = nb_sectors;
|
|
|
218e99 |
- return 1;
|
|
|
218e99 |
+ data = 0;
|
|
|
218e99 |
+ hole = start + nb_sectors * BDRV_SECTOR_SIZE;
|
|
|
218e99 |
#endif
|
|
|
218e99 |
|
|
|
218e99 |
if (data <= start) {
|
|
|
218e99 |
/* On a data extent, compute sectors to the end of the extent. */
|
|
|
218e99 |
*pnum = MIN(nb_sectors, (hole - start) / BDRV_SECTOR_SIZE);
|
|
|
218e99 |
- return 1;
|
|
|
218e99 |
} else {
|
|
|
218e99 |
/* On a hole, compute sectors to the beginning of the next extent. */
|
|
|
218e99 |
*pnum = MIN(nb_sectors, (data - start) / BDRV_SECTOR_SIZE);
|
|
|
218e99 |
- return 0;
|
|
|
218e99 |
+ ret &= ~BDRV_BLOCK_DATA;
|
|
|
218e99 |
+ ret |= BDRV_BLOCK_ZERO;
|
|
|
218e99 |
}
|
|
|
218e99 |
+
|
|
|
218e99 |
+ return ret;
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
static coroutine_fn BlockDriverAIOCB *raw_aio_discard(BlockDriverState *bs,
|
|
|
218e99 |
--
|
|
|
218e99 |
1.7.1
|
|
|
218e99 |
|