yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-block-backend-Reorder-flush-pdiscard-function-defini.patch

22c213
From 6cc456c4c1e6557fdc7e138e8ef8171b71609222 Mon Sep 17 00:00:00 2001
22c213
From: Kevin Wolf <kwolf@redhat.com>
22c213
Date: Wed, 8 Apr 2020 17:29:15 +0100
22c213
Subject: [PATCH 4/6] block-backend: Reorder flush/pdiscard function
22c213
 definitions
22c213
22c213
RH-Author: Kevin Wolf <kwolf@redhat.com>
22c213
Message-id: <20200408172917.18712-5-kwolf@redhat.com>
22c213
Patchwork-id: 94598
22c213
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH 4/6] block-backend: Reorder flush/pdiscard function definitions
22c213
Bugzilla: 1817621
22c213
RH-Acked-by: Eric Blake <eblake@redhat.com>
22c213
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>
22c213
RH-Acked-by: Max Reitz <mreitz@redhat.com>
22c213
22c213
Move all variants of the flush/pdiscard functions to a single place and
22c213
put the blk_co_*() version first because it is called by all other
22c213
variants (and will become static in the next patch).
22c213
22c213
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
22c213
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
22c213
Reviewed-by: Max Reitz <mreitz@redhat.com>
22c213
Message-Id: <20200407121259.21350-2-kwolf@redhat.com>
22c213
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
22c213
(cherry picked from commit 564806c529d4e0acad209b1e5b864a8886092f1f)
22c213
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
22c213
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
22c213
---
22c213
 block/block-backend.c | 92 +++++++++++++++++++++++++--------------------------
22c213
 1 file changed, 46 insertions(+), 46 deletions(-)
22c213
22c213
diff --git a/block/block-backend.c b/block/block-backend.c
22c213
index 8b8f2a8..17b2e87 100644
22c213
--- a/block/block-backend.c
22c213
+++ b/block/block-backend.c
22c213
@@ -1488,38 +1488,6 @@ BlockAIOCB *blk_aio_pwritev(BlockBackend *blk, int64_t offset,
22c213
                         blk_aio_write_entry, flags, cb, opaque);
22c213
 }
22c213
 
22c213
-static void blk_aio_flush_entry(void *opaque)
22c213
-{
22c213
-    BlkAioEmAIOCB *acb = opaque;
22c213
-    BlkRwCo *rwco = &acb->rwco;
22c213
-
22c213
-    rwco->ret = blk_co_flush(rwco->blk);
22c213
-    blk_aio_complete(acb);
22c213
-}
22c213
-
22c213
-BlockAIOCB *blk_aio_flush(BlockBackend *blk,
22c213
-                          BlockCompletionFunc *cb, void *opaque)
22c213
-{
22c213
-    return blk_aio_prwv(blk, 0, 0, NULL, blk_aio_flush_entry, 0, cb, opaque);
22c213
-}
22c213
-
22c213
-static void blk_aio_pdiscard_entry(void *opaque)
22c213
-{
22c213
-    BlkAioEmAIOCB *acb = opaque;
22c213
-    BlkRwCo *rwco = &acb->rwco;
22c213
-
22c213
-    rwco->ret = blk_co_pdiscard(rwco->blk, rwco->offset, acb->bytes);
22c213
-    blk_aio_complete(acb);
22c213
-}
22c213
-
22c213
-BlockAIOCB *blk_aio_pdiscard(BlockBackend *blk,
22c213
-                             int64_t offset, int bytes,
22c213
-                             BlockCompletionFunc *cb, void *opaque)
22c213
-{
22c213
-    return blk_aio_prwv(blk, offset, bytes, NULL, blk_aio_pdiscard_entry, 0,
22c213
-                        cb, opaque);
22c213
-}
22c213
-
22c213
 void blk_aio_cancel(BlockAIOCB *acb)
22c213
 {
22c213
     bdrv_aio_cancel(acb);
22c213
@@ -1586,6 +1554,37 @@ int blk_co_pdiscard(BlockBackend *blk, int64_t offset, int bytes)
22c213
     return bdrv_co_pdiscard(blk->root, offset, bytes);
22c213
 }
22c213
 
22c213
+static void blk_aio_pdiscard_entry(void *opaque)
22c213
+{
22c213
+    BlkAioEmAIOCB *acb = opaque;
22c213
+    BlkRwCo *rwco = &acb->rwco;
22c213
+
22c213
+    rwco->ret = blk_co_pdiscard(rwco->blk, rwco->offset, acb->bytes);
22c213
+    blk_aio_complete(acb);
22c213
+}
22c213
+
22c213
+BlockAIOCB *blk_aio_pdiscard(BlockBackend *blk,
22c213
+                             int64_t offset, int bytes,
22c213
+                             BlockCompletionFunc *cb, void *opaque)
22c213
+{
22c213
+    return blk_aio_prwv(blk, offset, bytes, NULL, blk_aio_pdiscard_entry, 0,
22c213
+                        cb, opaque);
22c213
+}
22c213
+
22c213
+static void blk_pdiscard_entry(void *opaque)
22c213
+{
22c213
+    BlkRwCo *rwco = opaque;
22c213
+    QEMUIOVector *qiov = rwco->iobuf;
22c213
+
22c213
+    rwco->ret = blk_co_pdiscard(rwco->blk, rwco->offset, qiov->size);
22c213
+    aio_wait_kick();
22c213
+}
22c213
+
22c213
+int blk_pdiscard(BlockBackend *blk, int64_t offset, int bytes)
22c213
+{
22c213
+    return blk_prw(blk, offset, NULL, bytes, blk_pdiscard_entry, 0);
22c213
+}
22c213
+
22c213
 int blk_co_flush(BlockBackend *blk)
22c213
 {
22c213
     blk_wait_while_drained(blk);
22c213
@@ -1597,6 +1596,21 @@ int blk_co_flush(BlockBackend *blk)
22c213
     return bdrv_co_flush(blk_bs(blk));
22c213
 }
22c213
 
22c213
+static void blk_aio_flush_entry(void *opaque)
22c213
+{
22c213
+    BlkAioEmAIOCB *acb = opaque;
22c213
+    BlkRwCo *rwco = &acb->rwco;
22c213
+
22c213
+    rwco->ret = blk_co_flush(rwco->blk);
22c213
+    blk_aio_complete(acb);
22c213
+}
22c213
+
22c213
+BlockAIOCB *blk_aio_flush(BlockBackend *blk,
22c213
+                          BlockCompletionFunc *cb, void *opaque)
22c213
+{
22c213
+    return blk_aio_prwv(blk, 0, 0, NULL, blk_aio_flush_entry, 0, cb, opaque);
22c213
+}
22c213
+
22c213
 static void blk_flush_entry(void *opaque)
22c213
 {
22c213
     BlkRwCo *rwco = opaque;
22c213
@@ -2083,20 +2097,6 @@ int blk_truncate(BlockBackend *blk, int64_t offset, bool exact,
22c213
     return bdrv_truncate(blk->root, offset, exact, prealloc, errp);
22c213
 }
22c213
 
22c213
-static void blk_pdiscard_entry(void *opaque)
22c213
-{
22c213
-    BlkRwCo *rwco = opaque;
22c213
-    QEMUIOVector *qiov = rwco->iobuf;
22c213
-
22c213
-    rwco->ret = blk_co_pdiscard(rwco->blk, rwco->offset, qiov->size);
22c213
-    aio_wait_kick();
22c213
-}
22c213
-
22c213
-int blk_pdiscard(BlockBackend *blk, int64_t offset, int bytes)
22c213
-{
22c213
-    return blk_prw(blk, offset, NULL, bytes, blk_pdiscard_entry, 0);
22c213
-}
22c213
-
22c213
 int blk_save_vmstate(BlockBackend *blk, const uint8_t *buf,
22c213
                      int64_t pos, int size)
22c213
 {
22c213
-- 
22c213
1.8.3.1
22c213