yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-blkdebug-Add-BLKDBG_FLUSH_TO_OS-DISK-events.patch

34b321
From 89f3f5eafd6aed8a79b4570553af711dffc3a1d6 Mon Sep 17 00:00:00 2001
34b321
From: John Snow <jsnow@redhat.com>
34b321
Date: Mon, 23 Nov 2015 17:38:36 +0100
34b321
Subject: [PATCH 17/27] blkdebug: Add BLKDBG_FLUSH_TO_OS/DISK events
34b321
34b321
RH-Author: John Snow <jsnow@redhat.com>
34b321
Message-id: <1448300320-7772-18-git-send-email-jsnow@redhat.com>
34b321
Patchwork-id: 68448
34b321
O-Subject: [RHEL-7.3 qemu-kvm PATCH v2 17/21] blkdebug: Add BLKDBG_FLUSH_TO_OS/DISK events
34b321
Bugzilla: 1272523
34b321
RH-Acked-by: Thomas Huth <thuth@redhat.com>
34b321
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
34b321
RH-Acked-by: Max Reitz <mreitz@redhat.com>
34b321
34b321
From: Kevin Wolf <kwolf@redhat.com>
34b321
34b321
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
34b321
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
34b321
(cherry picked from commit bf736fe34caba0688c9095c31b9d097ea15c1296)
34b321
Signed-off-by: John Snow <jsnow@redhat.com>
34b321
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
34b321
34b321
Conflicts:
34b321
  block/blkdebug.c:      debug event ordering
34b321
  include/block/block.h: debug event ordering
34b321
34b321
Signed-off-by: John Snow <jsnow@redhat.com>
34b321
---
34b321
 block.c               | 8 ++++----
34b321
 block/blkdebug.c      | 3 +++
34b321
 include/block/block.h | 3 +++
34b321
 3 files changed, 10 insertions(+), 4 deletions(-)
34b321
34b321
diff --git a/block.c b/block.c
34b321
index bc6e75c..ecb2b09 100644
34b321
--- a/block.c
34b321
+++ b/block.c
34b321
@@ -4026,13 +4026,11 @@ int bdrv_load_vmstate(BlockDriverState *bs, uint8_t *buf,
34b321
 
34b321
 void bdrv_debug_event(BlockDriverState *bs, BlkDebugEvent event)
34b321
 {
34b321
-    BlockDriver *drv = bs->drv;
34b321
-
34b321
-    if (!drv || !drv->bdrv_debug_event) {
34b321
+    if (!bs || !bs->drv || !bs->drv->bdrv_debug_event) {
34b321
         return;
34b321
     }
34b321
 
34b321
-    drv->bdrv_debug_event(bs, event);
34b321
+    bs->drv->bdrv_debug_event(bs, event);
34b321
 }
34b321
 
34b321
 int bdrv_debug_breakpoint(BlockDriverState *bs, const char *event,
34b321
@@ -4879,6 +4877,7 @@ int coroutine_fn bdrv_co_flush(BlockDriverState *bs)
34b321
     }
34b321
 
34b321
     /* Write back cached data to the OS even with cache=unsafe */
34b321
+    BLKDBG_EVENT(bs->file, BLKDBG_FLUSH_TO_OS);
34b321
     if (bs->drv->bdrv_co_flush_to_os) {
34b321
         ret = bs->drv->bdrv_co_flush_to_os(bs);
34b321
         if (ret < 0) {
34b321
@@ -4891,6 +4890,7 @@ int coroutine_fn bdrv_co_flush(BlockDriverState *bs)
34b321
         goto flush_parent;
34b321
     }
34b321
 
34b321
+    BLKDBG_EVENT(bs->file, BLKDBG_FLUSH_TO_DISK);
34b321
     if (bs->drv->bdrv_co_flush_to_disk) {
34b321
         ret = bs->drv->bdrv_co_flush_to_disk(bs);
34b321
     } else if (bs->drv->bdrv_aio_flush) {
34b321
diff --git a/block/blkdebug.c b/block/blkdebug.c
34b321
index c61ce52..8e468b2 100644
34b321
--- a/block/blkdebug.c
34b321
+++ b/block/blkdebug.c
34b321
@@ -184,6 +184,9 @@ static const char *event_names[BLKDBG_EVENT_MAX] = {
34b321
     [BLKDBG_CLUSTER_ALLOC_BYTES]            = "cluster_alloc_bytes",
34b321
     [BLKDBG_CLUSTER_FREE]                   = "cluster_free",
34b321
 
34b321
+    [BLKDBG_FLUSH_TO_OS]                    = "flush_to_os",
34b321
+    [BLKDBG_FLUSH_TO_DISK]                  = "flush_to_disk",
34b321
+
34b321
     [BLKDBG_PWRITEV_RMW_HEAD]               = "pwritev_rmw.head",
34b321
     [BLKDBG_PWRITEV_RMW_AFTER_HEAD]         = "pwritev_rmw.after_head",
34b321
     [BLKDBG_PWRITEV_RMW_TAIL]               = "pwritev_rmw.tail",
34b321
diff --git a/include/block/block.h b/include/block/block.h
34b321
index 8339cac..75147b2 100644
34b321
--- a/include/block/block.h
34b321
+++ b/include/block/block.h
34b321
@@ -508,6 +508,9 @@ typedef enum {
34b321
     BLKDBG_CLUSTER_ALLOC_BYTES,
34b321
     BLKDBG_CLUSTER_FREE,
34b321
 
34b321
+    BLKDBG_FLUSH_TO_OS,
34b321
+    BLKDBG_FLUSH_TO_DISK,
34b321
+
34b321
     BLKDBG_PWRITEV_RMW_HEAD,
34b321
     BLKDBG_PWRITEV_RMW_AFTER_HEAD,
34b321
     BLKDBG_PWRITEV_RMW_TAIL,
34b321
-- 
34b321
1.8.3.1
34b321