|
|
218e99 |
From f6f47020d06eca20a99967b6ac9eef65326dfdde Mon Sep 17 00:00:00 2001
|
|
|
218e99 |
From: Orit Wasserman <owasserm@redhat.com>
|
|
|
218e99 |
Date: Wed, 9 Oct 2013 10:09:06 +0200
|
|
|
218e99 |
Subject: [PATCH 11/25] block: add bdrv_write_zeroes()
|
|
|
218e99 |
|
|
|
218e99 |
RH-Author: Orit Wasserman <owasserm@redhat.com>
|
|
|
218e99 |
Message-id: <1381313355-15641-2-git-send-email-owasserm@redhat.com>
|
|
|
218e99 |
Patchwork-id: 54797
|
|
|
218e99 |
O-Subject: [RHEL7.0 qemu-kvm v2 01/10] block: add bdrv_write_zeroes()
|
|
|
218e99 |
Bugzilla: 921465
|
|
|
218e99 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
218e99 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
218e99 |
RH-Acked-by: Juan Quintela <quintela@redhat.com>
|
|
|
218e99 |
|
|
|
218e99 |
From: Peter Lieven <pl@kamp.de>
|
|
|
218e99 |
|
|
|
218e99 |
Signed-off-by: Peter Lieven <pl@kamp.de>
|
|
|
218e99 |
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
218e99 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
218e99 |
(cherry picked from commit 4105eaaab9376ea959de711b81bba9e1494c971d)
|
|
|
218e99 |
---
|
|
|
218e99 |
block.c | 27 +++++++++++++++++++--------
|
|
|
218e99 |
include/block/block.h | 2 ++
|
|
|
218e99 |
2 files changed, 21 insertions(+), 8 deletions(-)
|
|
|
218e99 |
|
|
|
218e99 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
218e99 |
---
|
|
|
218e99 |
block.c | 27 +++++++++++++++++++--------
|
|
|
218e99 |
include/block/block.h | 2 ++
|
|
|
218e99 |
2 files changed, 21 insertions(+), 8 deletions(-)
|
|
|
218e99 |
|
|
|
218e99 |
diff --git a/block.c b/block.c
|
|
|
218e99 |
index bd52c13..b160f62 100644
|
|
|
218e99 |
--- a/block.c
|
|
|
218e99 |
+++ b/block.c
|
|
|
218e99 |
@@ -2190,6 +2190,7 @@ typedef struct RwCo {
|
|
|
218e99 |
QEMUIOVector *qiov;
|
|
|
218e99 |
bool is_write;
|
|
|
218e99 |
int ret;
|
|
|
218e99 |
+ BdrvRequestFlags flags;
|
|
|
218e99 |
} RwCo;
|
|
|
218e99 |
|
|
|
218e99 |
static void coroutine_fn bdrv_rw_co_entry(void *opaque)
|
|
|
218e99 |
@@ -2198,10 +2199,12 @@ static void coroutine_fn bdrv_rw_co_entry(void *opaque)
|
|
|
218e99 |
|
|
|
218e99 |
if (!rwco->is_write) {
|
|
|
218e99 |
rwco->ret = bdrv_co_do_readv(rwco->bs, rwco->sector_num,
|
|
|
218e99 |
- rwco->nb_sectors, rwco->qiov, 0);
|
|
|
218e99 |
+ rwco->nb_sectors, rwco->qiov,
|
|
|
218e99 |
+ rwco->flags);
|
|
|
218e99 |
} else {
|
|
|
218e99 |
rwco->ret = bdrv_co_do_writev(rwco->bs, rwco->sector_num,
|
|
|
218e99 |
- rwco->nb_sectors, rwco->qiov, 0);
|
|
|
218e99 |
+ rwco->nb_sectors, rwco->qiov,
|
|
|
218e99 |
+ rwco->flags);
|
|
|
218e99 |
}
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
@@ -2209,7 +2212,8 @@ static void coroutine_fn bdrv_rw_co_entry(void *opaque)
|
|
|
218e99 |
* Process a vectored synchronous request using coroutines
|
|
|
218e99 |
*/
|
|
|
218e99 |
static int bdrv_rwv_co(BlockDriverState *bs, int64_t sector_num,
|
|
|
218e99 |
- QEMUIOVector *qiov, bool is_write)
|
|
|
218e99 |
+ QEMUIOVector *qiov, bool is_write,
|
|
|
218e99 |
+ BdrvRequestFlags flags)
|
|
|
218e99 |
{
|
|
|
218e99 |
Coroutine *co;
|
|
|
218e99 |
RwCo rwco = {
|
|
|
218e99 |
@@ -2219,6 +2223,7 @@ static int bdrv_rwv_co(BlockDriverState *bs, int64_t sector_num,
|
|
|
218e99 |
.qiov = qiov,
|
|
|
218e99 |
.is_write = is_write,
|
|
|
218e99 |
.ret = NOT_DONE,
|
|
|
218e99 |
+ .flags = flags,
|
|
|
218e99 |
};
|
|
|
218e99 |
assert((qiov->size & (BDRV_SECTOR_SIZE - 1)) == 0);
|
|
|
218e99 |
|
|
|
218e99 |
@@ -2250,7 +2255,7 @@ static int bdrv_rwv_co(BlockDriverState *bs, int64_t sector_num,
|
|
|
218e99 |
* Process a synchronous request using coroutines
|
|
|
218e99 |
*/
|
|
|
218e99 |
static int bdrv_rw_co(BlockDriverState *bs, int64_t sector_num, uint8_t *buf,
|
|
|
218e99 |
- int nb_sectors, bool is_write)
|
|
|
218e99 |
+ int nb_sectors, bool is_write, BdrvRequestFlags flags)
|
|
|
218e99 |
{
|
|
|
218e99 |
QEMUIOVector qiov;
|
|
|
218e99 |
struct iovec iov = {
|
|
|
218e99 |
@@ -2259,14 +2264,14 @@ static int bdrv_rw_co(BlockDriverState *bs, int64_t sector_num, uint8_t *buf,
|
|
|
218e99 |
};
|
|
|
218e99 |
|
|
|
218e99 |
qemu_iovec_init_external(&qiov, &iov, 1);
|
|
|
218e99 |
- return bdrv_rwv_co(bs, sector_num, &qiov, is_write);
|
|
|
218e99 |
+ return bdrv_rwv_co(bs, sector_num, &qiov, is_write, flags);
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
/* return < 0 if error. See bdrv_write() for the return codes */
|
|
|
218e99 |
int bdrv_read(BlockDriverState *bs, int64_t sector_num,
|
|
|
218e99 |
uint8_t *buf, int nb_sectors)
|
|
|
218e99 |
{
|
|
|
218e99 |
- return bdrv_rw_co(bs, sector_num, buf, nb_sectors, false);
|
|
|
218e99 |
+ return bdrv_rw_co(bs, sector_num, buf, nb_sectors, false, 0);
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
/* Just like bdrv_read(), but with I/O throttling temporarily disabled */
|
|
|
218e99 |
@@ -2292,12 +2297,18 @@ int bdrv_read_unthrottled(BlockDriverState *bs, int64_t sector_num,
|
|
|
218e99 |
int bdrv_write(BlockDriverState *bs, int64_t sector_num,
|
|
|
218e99 |
const uint8_t *buf, int nb_sectors)
|
|
|
218e99 |
{
|
|
|
218e99 |
- return bdrv_rw_co(bs, sector_num, (uint8_t *)buf, nb_sectors, true);
|
|
|
218e99 |
+ return bdrv_rw_co(bs, sector_num, (uint8_t *)buf, nb_sectors, true, 0);
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
int bdrv_writev(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov)
|
|
|
218e99 |
{
|
|
|
218e99 |
- return bdrv_rwv_co(bs, sector_num, qiov, true);
|
|
|
218e99 |
+ return bdrv_rwv_co(bs, sector_num, qiov, true, 0);
|
|
|
218e99 |
+}
|
|
|
218e99 |
+
|
|
|
218e99 |
+int bdrv_write_zeroes(BlockDriverState *bs, int64_t sector_num, int nb_sectors)
|
|
|
218e99 |
+{
|
|
|
218e99 |
+ return bdrv_rw_co(bs, sector_num, NULL, nb_sectors, true,
|
|
|
218e99 |
+ BDRV_REQ_ZERO_WRITE);
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
int bdrv_pread(BlockDriverState *bs, int64_t offset,
|
|
|
218e99 |
diff --git a/include/block/block.h b/include/block/block.h
|
|
|
218e99 |
index 174295b..1a3ed22 100644
|
|
|
218e99 |
--- a/include/block/block.h
|
|
|
218e99 |
+++ b/include/block/block.h
|
|
|
218e99 |
@@ -168,6 +168,8 @@ int bdrv_read_unthrottled(BlockDriverState *bs, int64_t sector_num,
|
|
|
218e99 |
uint8_t *buf, int nb_sectors);
|
|
|
218e99 |
int bdrv_write(BlockDriverState *bs, int64_t sector_num,
|
|
|
218e99 |
const uint8_t *buf, int nb_sectors);
|
|
|
218e99 |
+int bdrv_write_zeroes(BlockDriverState *bs, int64_t sector_num,
|
|
|
218e99 |
+ int nb_sectors);
|
|
|
218e99 |
int bdrv_writev(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov);
|
|
|
218e99 |
int bdrv_pread(BlockDriverState *bs, int64_t offset,
|
|
|
218e99 |
void *buf, int count);
|
|
|
218e99 |
--
|
|
|
218e99 |
1.7.1
|
|
|
218e99 |
|