[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 09/13] qcow2: move is_zero_sectors() up
From: |
Anton Nefedov |
Subject: |
[Qemu-devel] [PATCH v3 09/13] qcow2: move is_zero_sectors() up |
Date: |
Mon, 31 Jul 2017 19:22:01 +0300 |
To be used in the following commit without a forward declaration.
Signed-off-by: Anton Nefedov <address@hidden>
---
block/qcow2.c | 39 +++++++++++++++++++--------------------
1 file changed, 19 insertions(+), 20 deletions(-)
diff --git a/block/qcow2.c b/block/qcow2.c
index 0f4de40..5c7c2b5 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1943,6 +1943,25 @@ static bool merge_cow(uint64_t offset, unsigned bytes,
return false;
}
+static bool is_zero_sectors(BlockDriverState *bs, int64_t start,
+ uint32_t count)
+{
+ int nr;
+ BlockDriverState *file;
+ int64_t res;
+
+ if (start + count > bs->total_sectors) {
+ count = bs->total_sectors - start;
+ }
+
+ if (!count) {
+ return true;
+ }
+ res = bdrv_get_block_status_above(bs, NULL, start, count,
+ &nr, &file);
+ return res >= 0 && (res & BDRV_BLOCK_ZERO) && nr == count;
+}
+
/*
* If the specified area is beyond EOF, allocates it + prealloc_size
* bytes ahead.
@@ -3086,26 +3105,6 @@ finish:
return ret;
}
-
-static bool is_zero_sectors(BlockDriverState *bs, int64_t start,
- uint32_t count)
-{
- int nr;
- BlockDriverState *file;
- int64_t res;
-
- if (start + count > bs->total_sectors) {
- count = bs->total_sectors - start;
- }
-
- if (!count) {
- return true;
- }
- res = bdrv_get_block_status_above(bs, NULL, start, count,
- &nr, &file);
- return res >= 0 && (res & BDRV_BLOCK_ZERO) && nr == count;
-}
-
static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs,
int64_t offset, int bytes, BdrvRequestFlags flags)
{
--
2.7.4
- [Qemu-devel] [PATCH v3 00/13] qcow2: space preallocation and COW improvements, Anton Nefedov, 2017/07/31
- [Qemu-devel] [PATCH v3 02/13] block: treat BDRV_REQ_ALLOCATE as serialising, Anton Nefedov, 2017/07/31
- [Qemu-devel] [PATCH v3 07/13] qcow2: truncate preallocated space, Anton Nefedov, 2017/07/31
- [Qemu-devel] [PATCH v3 03/13] file-posix: support BDRV_REQ_ALLOCATE, Anton Nefedov, 2017/07/31
- [Qemu-devel] [PATCH v3 04/13] block: support BDRV_REQ_ALLOCATE in passthrough drivers, Anton Nefedov, 2017/07/31
- [Qemu-devel] [PATCH v3 06/13] qcow2: set inactive flag, Anton Nefedov, 2017/07/31
- [Qemu-devel] [PATCH v3 01/13] block: introduce BDRV_REQ_ALLOCATE flag, Anton Nefedov, 2017/07/31
- [Qemu-devel] [PATCH v3 05/13] qcow2: preallocation at image expand, Anton Nefedov, 2017/07/31
- [Qemu-devel] [PATCH v3 09/13] qcow2: move is_zero_sectors() up,
Anton Nefedov <=
- [Qemu-devel] [PATCH v3 10/13] qcow2: skip writing zero buffers to empty COW areas, Anton Nefedov, 2017/07/31
- [Qemu-devel] [PATCH v3 08/13] qcow2: check space leak at the end of the image, Anton Nefedov, 2017/07/31
- [Qemu-devel] [PATCH v3 11/13] qcow2: allocate image space by-cluster, Anton Nefedov, 2017/07/31
- [Qemu-devel] [PATCH v3 13/13] iotest 134: test cluster-misaligned encrypted write, Anton Nefedov, 2017/07/31
- [Qemu-devel] [PATCH v3 12/13] iotest 190: test BDRV_REQ_ALLOCATE, Anton Nefedov, 2017/07/31
- Re: [Qemu-devel] [PATCH v3 00/13] qcow2: space preallocation and COW improvements, no-reply, 2017/07/31