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

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