Commit c2a35d4b05 for qemu.org

commit c2a35d4b05f6f1118800295a06fa407249c14701
Author: Denis V. Lunev <den@openvz.org>
Date:   Fri Aug 14 21:13:26 2026 +0200

    parallels: Limit search in parallels_mark_used to the last marked cluster

    There is no necessity to search to the end of the bitmap. Limit the
    search area as cluster_index + count.

    Add cluster_end variable to avoid its calculation in a few places.

    Based on the original work from Alexander Ivanov.

    Cc: Stefan Hajnoczi <stefanha@redhat.com>
    Signed-off-by: Denis V. Lunev <den@openvz.org>

diff --git a/block/parallels.c b/block/parallels.c
index 6f7a9911d7..d537b0bb53 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -192,12 +192,14 @@ int parallels_mark_used(BlockDriverState *bs, unsigned long *bitmap,
 {
     BDRVParallelsState *s = bs->opaque;
     uint32_t cluster_index = host_cluster_index(s, off);
+    uint64_t cluster_end = (uint64_t)cluster_index + count;
     unsigned long next_used;
-    if ((uint64_t)cluster_index + count > bitmap_size) {
+
+    if (cluster_end > bitmap_size) {
         return -E2BIG;
     }
-    next_used = find_next_bit(bitmap, bitmap_size, cluster_index);
-    if (next_used < (uint64_t)cluster_index + count) {
+    next_used = find_next_bit(bitmap, cluster_end, cluster_index);
+    if (next_used < cluster_end) {
         return -EBUSY;
     }
     bitmap_set(bitmap, cluster_index, count);