|
|
9ae3a8 |
From 69813093427b02a4a0e02264abd1f851f2b49249 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
Date: Thu, 7 Nov 2013 07:23:45 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 26/81] block/get_block_status: avoid redundant callouts on raw devices
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1382084091-16636-27-git-send-email-pbonzini@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 55009
|
|
|
9ae3a8 |
O-Subject: [RHEL 7.0 qemu-kvm PATCH 26/26] block/get_block_status: avoid redundant callouts on raw devices
|
|
|
9ae3a8 |
Bugzilla: 989646
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Peter Lieven <pl@kamp.de>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if a raw device like an iscsi target or host device is used
|
|
|
9ae3a8 |
the current implementation makes a second call out to get
|
|
|
9ae3a8 |
the block status of bs->file.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Peter Lieven <pl@kamp.de>
|
|
|
9ae3a8 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 92bc50a5ad7fbc9a0bd17240eaea5027a100ca79)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Conflicts:
|
|
|
9ae3a8 |
block/raw_bsd.c
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
block.c | 6 ++++++
|
|
|
9ae3a8 |
block/raw.c | 4 +++-
|
|
|
9ae3a8 |
include/block/block.h | 4 ++++
|
|
|
9ae3a8 |
3 files changed, 13 insertions(+), 1 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff
|
|
|
9ae3a8 |
index 5c49461..fdff92f 100644
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -3073,6 +3073,12 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,
|
|
|
9ae3a8 |
return ret;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ if (ret & BDRV_BLOCK_RAW) {
|
|
|
9ae3a8 |
+ assert(ret & BDRV_BLOCK_OFFSET_VALID);
|
|
|
9ae3a8 |
+ return bdrv_get_block_status(bs->file, ret >> BDRV_SECTOR_BITS,
|
|
|
9ae3a8 |
+ *pnum, pnum);
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
if (!(ret & BDRV_BLOCK_DATA)) {
|
|
|
9ae3a8 |
if (bdrv_has_zero_init(bs)) {
|
|
|
9ae3a8 |
ret |= BDRV_BLOCK_ZERO;
|
|
|
9ae3a8 |
diff
|
|
|
9ae3a8 |
index 844a222..7d82cf3 100644
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -39,7 +39,9 @@ static int64_t coroutine_fn raw_co_get_block_status(BlockDriverState *bs,
|
|
|
9ae3a8 |
int64_t sector_num,
|
|
|
9ae3a8 |
int nb_sectors, int *pnum)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
- return bdrv_get_block_status(bs->file, sector_num, nb_sectors, pnum);
|
|
|
9ae3a8 |
+ *pnum = nb_sectors;
|
|
|
9ae3a8 |
+ return BDRV_BLOCK_RAW | BDRV_BLOCK_OFFSET_VALID | BDRV_BLOCK_DATA |
|
|
|
9ae3a8 |
+ (sector_num << BDRV_SECTOR_BITS);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static int coroutine_fn raw_co_write_zeroes(BlockDriverState *bs,
|
|
|
9ae3a8 |
diff
|
|
|
9ae3a8 |
index 01f5c65..bc1f5f6 100644
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+++ b/include/block/block.h
|
|
|
9ae3a8 |
@@ -95,6 +95,9 @@ typedef struct BlockDevOps {
|
|
|
9ae3a8 |
/* BDRV_BLOCK_DATA: data is read from bs->file or another file
|
|
|
9ae3a8 |
* BDRV_BLOCK_ZERO: sectors read as zero
|
|
|
9ae3a8 |
* BDRV_BLOCK_OFFSET_VALID: sector stored in bs->file as raw data
|
|
|
9ae3a8 |
+ * BDRV_BLOCK_RAW: used internally to indicate that the request
|
|
|
9ae3a8 |
+ * was answered by the raw driver and that one
|
|
|
9ae3a8 |
+ * should look in bs->file directly.
|
|
|
9ae3a8 |
*
|
|
|
9ae3a8 |
* If BDRV_BLOCK_OFFSET_VALID is set, bits 9-62 represent the offset in
|
|
|
9ae3a8 |
* bs->file where sector data can be read from as raw data.
|
|
|
9ae3a8 |
@@ -116,6 +119,7 @@ typedef struct BlockDevOps {
|
|
|
9ae3a8 |
#define BDRV_BLOCK_DATA 1
|
|
|
9ae3a8 |
#define BDRV_BLOCK_ZERO 2
|
|
|
9ae3a8 |
#define BDRV_BLOCK_OFFSET_VALID 4
|
|
|
9ae3a8 |
+#define BDRV_BLOCK_RAW 8
|
|
|
9ae3a8 |
#define BDRV_BLOCK_OFFSET_MASK BDRV_SECTOR_MASK
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
typedef enum {
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|