Blame SOURCES/kvm-block-keep-bs-total_sectors-up-to-date-even-for-grow.patch

218e99
From 1c16f135463077e596b9156439d2482a1a8aa9b8 Mon Sep 17 00:00:00 2001
218e99
From: Paolo Bonzini <pbonzini@redhat.com>
218e99
Date: Fri, 18 Oct 2013 08:14:29 +0200
218e99
Subject: [PATCH 04/81] block: keep bs->total_sectors up to date even for growable block devices
218e99
218e99
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
218e99
Message-id: <1382084091-16636-5-git-send-email-pbonzini@redhat.com>
218e99
Patchwork-id: 54986
218e99
O-Subject: [RHEL 7.0 qemu-kvm PATCH 04/26] block: keep bs->total_sectors up to date even for growable block devices
218e99
Bugzilla: 989646
218e99
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
218e99
RH-Acked-by: Max Reitz <mreitz@redhat.com>
218e99
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
218e99
218e99
If a BlockDriverState is growable, after every write we need to
218e99
check if bs->total_sectors might have changed.  With this change,
218e99
bdrv_getlength does not need anymore a system call.
218e99
218e99
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
218e99
(cherry picked from commit df2a6f29a5019707d69f6eeb30cf792841cae5aa)
218e99
---
218e99
 block.c | 5 ++++-
218e99
 1 file changed, 4 insertions(+), 1 deletion(-)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 block.c |    5 ++++-
218e99
 1 files changed, 4 insertions(+), 1 deletions(-)
218e99
218e99
diff --git a/block.c b/block.c
218e99
index 2ba9a0a..d5aeff7 100644
218e99
--- a/block.c
218e99
+++ b/block.c
218e99
@@ -2703,6 +2703,9 @@ static int coroutine_fn bdrv_co_do_writev(BlockDriverState *bs,
218e99
     if (bs->wr_highest_sector < sector_num + nb_sectors - 1) {
218e99
         bs->wr_highest_sector = sector_num + nb_sectors - 1;
218e99
     }
218e99
+    if (bs->growable && ret >= 0) {
218e99
+        bs->total_sectors = MAX(bs->total_sectors, sector_num + nb_sectors);
218e99
+    }
218e99
 
218e99
     tracked_request_end(&req;;
218e99
 
218e99
@@ -2777,7 +2780,7 @@ int64_t bdrv_getlength(BlockDriverState *bs)
218e99
     if (!drv)
218e99
         return -ENOMEDIUM;
218e99
 
218e99
-    if (bs->growable || bdrv_dev_has_removable_media(bs)) {
218e99
+    if (bdrv_dev_has_removable_media(bs)) {
218e99
         if (drv->bdrv_getlength) {
218e99
             return drv->bdrv_getlength(bs);
218e99
         }
218e99
-- 
218e99
1.7.1
218e99