[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 8/9] block/io: move bdrv_make_zero under block-status
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH 8/9] block/io: move bdrv_make_zero under block-status |
Date: |
Wed, 8 Apr 2020 12:30:50 +0300 |
We are going to use bdrv_co_block_status in bdrv_make_zero, so move it
now down.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
---
block/io.c | 82 +++++++++++++++++++++++++++---------------------------
1 file changed, 41 insertions(+), 41 deletions(-)
diff --git a/block/io.c b/block/io.c
index b1fc8b2367..d2ac9ac7b5 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2177,47 +2177,6 @@ int bdrv_pwrite_sync(BdrvChild *child, int64_t offset,
return 0;
}
-/*
- * Completely zero out a block device with the help of bdrv_pwrite_zeroes.
- * The operation is sped up by checking the block status and only writing
- * zeroes to the device if they currently do not return zeroes. Optional
- * flags are passed through to bdrv_pwrite_zeroes (e.g. BDRV_REQ_MAY_UNMAP,
- * BDRV_REQ_FUA).
- *
- * Returns < 0 on error, 0 on success. For error codes see bdrv_write().
- */
-int bdrv_make_zero(BdrvChild *child, BdrvRequestFlags flags)
-{
- int ret;
- int64_t target_size, bytes, offset = 0;
- BlockDriverState *bs = child->bs;
-
- target_size = bdrv_getlength(bs);
- if (target_size < 0) {
- return target_size;
- }
-
- for (;;) {
- bytes = MIN(target_size - offset, BDRV_REQUEST_MAX_BYTES);
- if (bytes <= 0) {
- return 0;
- }
- ret = bdrv_block_status(bs, offset, bytes, &bytes, NULL, NULL);
- if (ret < 0) {
- return ret;
- }
- if (ret & BDRV_BLOCK_ZERO) {
- offset += bytes;
- continue;
- }
- ret = bdrv_pwrite_zeroes(child, offset, bytes, flags);
- if (ret < 0) {
- return ret;
- }
- offset += bytes;
- }
-}
-
int bdrv_preadv(BdrvChild *child, int64_t offset, QEMUIOVector *qiov)
{
int ret;
@@ -2768,6 +2727,47 @@ bdrv_is_allocated_above(BlockDriverState *top,
BlockDriverState *base,
return data.ret;
}
+/*
+ * Completely zero out a block device with the help of bdrv_pwrite_zeroes.
+ * The operation is sped up by checking the block status and only writing
+ * zeroes to the device if they currently do not return zeroes. Optional
+ * flags are passed through to bdrv_pwrite_zeroes (e.g. BDRV_REQ_MAY_UNMAP,
+ * BDRV_REQ_FUA).
+ *
+ * Returns < 0 on error, 0 on success. For error codes see bdrv_write().
+ */
+int bdrv_make_zero(BdrvChild *child, BdrvRequestFlags flags)
+{
+ int ret;
+ int64_t target_size, bytes, offset = 0;
+ BlockDriverState *bs = child->bs;
+
+ target_size = bdrv_getlength(bs);
+ if (target_size < 0) {
+ return target_size;
+ }
+
+ for (;;) {
+ bytes = MIN(target_size - offset, BDRV_REQUEST_MAX_BYTES);
+ if (bytes <= 0) {
+ return 0;
+ }
+ ret = bdrv_block_status(bs, offset, bytes, &bytes, NULL, NULL);
+ if (ret < 0) {
+ return ret;
+ }
+ if (ret & BDRV_BLOCK_ZERO) {
+ offset += bytes;
+ continue;
+ }
+ ret = bdrv_pwrite_zeroes(child, offset, bytes, flags);
+ if (ret < 0) {
+ return ret;
+ }
+ offset += bytes;
+ }
+}
+
typedef struct BdrvVmstateCo {
BlockDriverState *bs;
QEMUIOVector *qiov;
--
2.21.0
- [PATCH for-5.0? 0/9] block/io: safer inc/dec in_flight sections, Vladimir Sementsov-Ogievskiy, 2020/04/08
- [PATCH 2/9] block/io: refactor bdrv_co_ioctl: move aio stuff to corresponding block, Vladimir Sementsov-Ogievskiy, 2020/04/08
- [PATCH 1/9] block/io: refactor bdrv_is_allocated_above to run only one coroutine, Vladimir Sementsov-Ogievskiy, 2020/04/08
- [PATCH 7/9] block/io: add bdrv_do_pwrite_zeroes, Vladimir Sementsov-Ogievskiy, 2020/04/08
- [PATCH 6/9] block/io: expand in_flight inc/dec section: block-status, Vladimir Sementsov-Ogievskiy, 2020/04/08
- [PATCH 8/9] block/io: move bdrv_make_zero under block-status,
Vladimir Sementsov-Ogievskiy <=
- [PATCH 3/9] block/io: move flush and pdiscard stuff down, Vladimir Sementsov-Ogievskiy, 2020/04/08
- [PATCH 4/9] block/io: move bdrv_rw_co_entry and friends down, Vladimir Sementsov-Ogievskiy, 2020/04/08
- [PATCH 9/9] block/io: expand in_flight inc/dec section: bdrv_make_zero, Vladimir Sementsov-Ogievskiy, 2020/04/08
- [PATCH 5/9] block/io: expand in_flight inc/dec section: simple cases, Vladimir Sementsov-Ogievskiy, 2020/04/08