Received: from eggs.gnu.org ([2001:4830:134:3::10]:34525) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UuO9R-0001VD-C9 for qemu-devel@nongnu.org; Wed, 03 Jul 2013 10:35:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UuO9P-0006Xd-Og for qemu-devel@nongnu.org; Wed, 03 Jul 2013 10:35:21 -0400 Received: from mail-qc0-x230.google.com ([2607:f8b0:400d:c01::230]:62051) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UuO9P-0006XQ-KU for qemu-devel@nongnu.org; Wed, 03 Jul 2013 10:35:19 -0400 Received: by mail-qc0-f176.google.com with SMTP id z10so126849qcx.21 for ; Wed, 03 Jul 2013 07:35:19 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 3 Jul 2013 16:34:28 +0200 Message-Id: <1372862071-28225-15-git-send-email-pbonzini@redhat.com> In-Reply-To: <1372862071-28225-1-git-send-email-pbonzini@redhat.com> References: <1372862071-28225-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 14/17] raw-posix: return get_block_status data and flags List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, pl@kamp.de, stefanha@redhat.com Signed-off-by: Paolo Bonzini --- 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.2.1