[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 1/5] hbitmap: handle set/reset with zero length
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH v2 1/5] hbitmap: handle set/reset with zero length |
Date: |
Fri, 11 Oct 2019 12:07:07 +0300 |
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>
---
util/hbitmap.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/util/hbitmap.c b/util/hbitmap.c
index fd44c897ab..86b0231046 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);
@@ -477,6 +481,10 @@ void hbitmap_reset(HBitmap *hb, uint64_t start, uint64_t
count)
uint64_t first;
uint64_t last = start + count - 1;
+ if (count == 0) {
+ return;
+ }
+
trace_hbitmap_reset(hb, start, count,
start >> hb->granularity, last >> hb->granularity);
--
2.21.0
- [PATCH v2 0/5] active-mirror: support unaligned guest operations, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [PATCH v2 3/5] block/block-backend: add blk_co_pwritev_part, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [PATCH v2 2/5] block/mirror: simplify do_sync_target_write, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [PATCH v2 4/5] block/mirror: support unaligned write in active mirror, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [PATCH v2 5/5] Revert "mirror: Only mirror granularity-aligned chunks", Vladimir Sementsov-Ogievskiy, 2019/10/11
- [PATCH v2 1/5] hbitmap: handle set/reset with zero length,
Vladimir Sementsov-Ogievskiy <=
- Re: [PATCH v2 0/5] active-mirror: support unaligned guest operations, Max Reitz, 2019/10/18