Blame SOURCES/kvm-nbd-server-Fix-blockstatus-trace.patch

383d26
From cd17af9ea6c8ef48387770a2fd65c93b93f0de65 Mon Sep 17 00:00:00 2001
383d26
From: John Snow <jsnow@redhat.com>
383d26
Date: Mon, 6 May 2019 17:56:25 +0200
383d26
Subject: [PATCH 15/53] nbd/server: Fix blockstatus trace
383d26
383d26
RH-Author: John Snow <jsnow@redhat.com>
383d26
Message-id: <20190506175629.11079-16-jsnow@redhat.com>
383d26
Patchwork-id: 87197
383d26
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 15/19] nbd/server: Fix blockstatus trace
383d26
Bugzilla: 1692018
383d26
RH-Acked-by: Max Reitz <mreitz@redhat.com>
383d26
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
383d26
RH-Acked-by: Thomas Huth <thuth@redhat.com>
383d26
383d26
From: Eric Blake <eblake@redhat.com>
383d26
383d26
Don't increment remaining_bytes until we know that we will actually be
383d26
including the current block status extent in the reply; otherwise, the
383d26
value traced will include a bytes value that is oversized by the
383d26
length of the next block status extent which did not get sent because
383d26
it instead ended the loop.
383d26
383d26
Fixes: fb7afc79
383d26
Signed-off-by: Eric Blake <eblake@redhat.com>
383d26
Message-Id: <20190403030526.12258-2-eblake@redhat.com>
383d26
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
383d26
(cherry picked from commit 2178a569be16b18f04ed854d24fd2281b6a429c5)
383d26
Signed-off-by: John Snow <jsnow@redhat.com>
383d26
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
---
383d26
 nbd/server.c | 9 +++------
383d26
 1 file changed, 3 insertions(+), 6 deletions(-)
383d26
383d26
diff --git a/nbd/server.c b/nbd/server.c
383d26
index 706f95a..6ae2154 100644
383d26
--- a/nbd/server.c
383d26
+++ b/nbd/server.c
383d26
@@ -1880,17 +1880,12 @@ static int blockstatus_to_extents(BlockDriverState *bs, uint64_t offset,
383d26
 
383d26
         flags = (ret & BDRV_BLOCK_ALLOCATED ? 0 : NBD_STATE_HOLE) |
383d26
                 (ret & BDRV_BLOCK_ZERO      ? NBD_STATE_ZERO : 0);
383d26
-        offset += num;
383d26
-        remaining_bytes -= num;
383d26
 
383d26
         if (first_extent) {
383d26
             extent->flags = flags;
383d26
             extent->length = num;
383d26
             first_extent = false;
383d26
-            continue;
383d26
-        }
383d26
-
383d26
-        if (flags == extent->flags) {
383d26
+        } else if (flags == extent->flags) {
383d26
             /* extend current extent */
383d26
             extent->length += num;
383d26
         } else {
383d26
@@ -1903,6 +1898,8 @@ static int blockstatus_to_extents(BlockDriverState *bs, uint64_t offset,
383d26
             extent->flags = flags;
383d26
             extent->length = num;
383d26
         }
383d26
+        offset += num;
383d26
+        remaining_bytes -= num;
383d26
     }
383d26
 
383d26
     extents_end = extent + 1;
383d26
-- 
383d26
1.8.3.1
383d26