Blame SOURCES/kvm-file-posix-Factor-out-raw_thread_pool_submit.patch

8b1478
From aa184b19787e6f9701c6b273394d502e03d8b0c1 Mon Sep 17 00:00:00 2001
8b1478
From: Maxim Levitsky <mlevitsk@redhat.com>
8b1478
Date: Wed, 5 Jun 2019 13:57:01 +0200
8b1478
Subject: [PATCH 13/23] file-posix: Factor out raw_thread_pool_submit()
8b1478
8b1478
RH-Author: Maxim Levitsky <mlevitsk@redhat.com>
8b1478
Message-id: <20190605135705.24526-6-mlevitsk@redhat.com>
8b1478
Patchwork-id: 88556
8b1478
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 5/9] file-posix: Factor out raw_thread_pool_submit()
8b1478
Bugzilla: 1648622
8b1478
RH-Acked-by: Max Reitz <mreitz@redhat.com>
8b1478
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
8b1478
RH-Acked-by: John Snow <jsnow@redhat.com>
8b1478
8b1478
From: Kevin Wolf <kwolf@redhat.com>
8b1478
8b1478
Getting the thread pool of the AioContext of a block node and scheduling
8b1478
some work in it is an operation that is already done twice, and we'll
8b1478
get more instances. Factor it out into a separate function.
8b1478
8b1478
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8b1478
8b1478
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1648622
8b1478
8b1478
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
8b1478
(Cherry picked from 5d5de250056b0972cde2e88133db702960a32b72 with some conflicts)
8b1478
8b1478
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
8b1478
---
8b1478
 block/file-posix.c | 17 ++++++++++-------
8b1478
 1 file changed, 10 insertions(+), 7 deletions(-)
8b1478
8b1478
diff --git a/block/file-posix.c b/block/file-posix.c
8b1478
index 5b93d06..74da336 100644
8b1478
--- a/block/file-posix.c
8b1478
+++ b/block/file-posix.c
8b1478
@@ -1818,13 +1818,20 @@ static int aio_worker(void *arg)
8b1478
     return ret;
8b1478
 }
8b1478
 
8b1478
+static int coroutine_fn raw_thread_pool_submit(BlockDriverState *bs,
8b1478
+                                               ThreadPoolFunc func, void *arg)
8b1478
+{
8b1478
+    /* @bs can be NULL, bdrv_get_aio_context() returns the main context then */
8b1478
+    ThreadPool *pool = aio_get_thread_pool(bdrv_get_aio_context(bs));
8b1478
+    return thread_pool_submit_co(pool, func, arg);
8b1478
+}
8b1478
+
8b1478
 static int paio_submit_co_full(BlockDriverState *bs, int fd,
8b1478
                                int64_t offset, int fd2, int64_t offset2,
8b1478
                                QEMUIOVector *qiov,
8b1478
                                int bytes, int type)
8b1478
 {
8b1478
     RawPosixAIOData *acb = g_new(RawPosixAIOData, 1);
8b1478
-    ThreadPool *pool;
8b1478
 
8b1478
     acb->bs = bs;
8b1478
     acb->aio_type = type;
8b1478
@@ -1842,8 +1849,7 @@ static int paio_submit_co_full(BlockDriverState *bs, int fd,
8b1478
     }
8b1478
 
8b1478
     trace_paio_submit_co(offset, bytes, type);
8b1478
-    pool = aio_get_thread_pool(bdrv_get_aio_context(bs));
8b1478
-    return thread_pool_submit_co(pool, aio_worker, acb);
8b1478
+    return raw_thread_pool_submit(bs, aio_worker, acb);
8b1478
 }
8b1478
 
8b1478
 static inline int paio_submit_co(BlockDriverState *bs, int fd,
8b1478
@@ -1976,7 +1982,6 @@ raw_regular_truncate(BlockDriverState *bs, int fd, int64_t offset,
8b1478
                      PreallocMode prealloc, Error **errp)
8b1478
 {
8b1478
     RawPosixAIOData *acb = g_new(RawPosixAIOData, 1);
8b1478
-    ThreadPool *pool;
8b1478
 
8b1478
     *acb = (RawPosixAIOData) {
8b1478
         .bs             = bs,
8b1478
@@ -1987,9 +1992,7 @@ raw_regular_truncate(BlockDriverState *bs, int fd, int64_t offset,
8b1478
         .errp           = errp,
8b1478
     };
8b1478
 
8b1478
-    /* @bs can be NULL, bdrv_get_aio_context() returns the main context then */
8b1478
-    pool = aio_get_thread_pool(bdrv_get_aio_context(bs));
8b1478
-    return thread_pool_submit_co(pool, aio_worker, acb);
8b1478
+    return raw_thread_pool_submit(bs, aio_worker, acb);
8b1478
 }
8b1478
 
8b1478
 static int coroutine_fn raw_co_truncate(BlockDriverState *bs, int64_t offset,
8b1478
-- 
8b1478
1.8.3.1
8b1478