[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 08/69] hbitmap: handle set/reset with zero length
From: |
Max Reitz |
Subject: |
[PULL 08/69] hbitmap: handle set/reset with zero length |
Date: |
Mon, 28 Oct 2019 13:14:00 +0100 |
From: Vladimir Sementsov-Ogievskiy <address@hidden>
Passing zero length to these functions leads to unpredicted results.
Zero-length set/reset may occur in active-mirror, on zero-length write
(which is unlikely, but not guaranteed to never happen).
Let's just do nothing on zero-length request.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Message-id: address@hidden
Reviewed-by: Max Reitz <address@hidden>
Cc: address@hidden
Signed-off-by: Max Reitz <address@hidden>
---
util/hbitmap.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/util/hbitmap.c b/util/hbitmap.c
index 66db87c6ff..242c6e519c 100644
--- a/util/hbitmap.c
+++ b/util/hbitmap.c
@@ -387,6 +387,10 @@ void hbitmap_set(HBitmap *hb, uint64_t start, uint64_t
count)
uint64_t first, n;
uint64_t last = start + count - 1;
+ if (count == 0) {
+ return;
+ }
+
trace_hbitmap_set(hb, start, count,
start >> hb->granularity, last >> hb->granularity);
@@ -478,6 +482,10 @@ void hbitmap_reset(HBitmap *hb, uint64_t start, uint64_t
count)
uint64_t last = start + count - 1;
uint64_t gran = 1ULL << hb->granularity;
+ if (count == 0) {
+ return;
+ }
+
assert(QEMU_IS_ALIGNED(start, gran));
assert(QEMU_IS_ALIGNED(count, gran) || (start + count == hb->orig_size));
--
2.21.0
- [PULL 00/69] Block patches for softfreeze, Max Reitz, 2019/10/28
- [PULL 01/69] iotests: Prefer null-co over null-aio, Max Reitz, 2019/10/28
- [PULL 02/69] iotests: Allow skipping test cases, Max Reitz, 2019/10/28
- [PULL 03/69] iotests: Use case_skip() in skip_if_unsupported(), Max Reitz, 2019/10/28
- [PULL 06/69] iotests: Test driver whitelisting in 136, Max Reitz, 2019/10/28
- [PULL 04/69] iotests: Let skip_if_unsupported accept a function, Max Reitz, 2019/10/28
- [PULL 08/69] hbitmap: handle set/reset with zero length,
Max Reitz <=
- [PULL 05/69] iotests: Test driver whitelisting in 093, Max Reitz, 2019/10/28
- [PULL 07/69] iotests: Cache supported_formats(), Max Reitz, 2019/10/28
- [PULL 09/69] block/mirror: simplify do_sync_target_write, Max Reitz, 2019/10/28
- [PULL 10/69] block/block-backend: add blk_co_pwritev_part, Max Reitz, 2019/10/28
- [PULL 11/69] block/mirror: support unaligned write in active mirror, Max Reitz, 2019/10/28
- [PULL 12/69] Revert "mirror: Only mirror granularity-aligned chunks", Max Reitz, 2019/10/28
- [PULL 13/69] iotests: Introduce $SOCK_DIR, Max Reitz, 2019/10/28
- [PULL 14/69] iotests.py: Store socket files in $SOCK_DIR, Max Reitz, 2019/10/28
- [PULL 15/69] iotests.py: Add @base_dir to FilePaths etc., Max Reitz, 2019/10/28
- [PULL 16/69] iotests: Filter $SOCK_DIR, Max Reitz, 2019/10/28