From 3d05aa9362a3b86d59f59c25c5453190ff1591ff Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Tue, 6 Oct 2020 02:35:11 +0300 Subject: [PATCH] Make it build with GCC 10, fio 3.20+ (atomics...) and QEMU 5.1 --- Makefile | 6 +++--- blockstore.h | 1 + cluster_client.cpp | 1 + epoll_manager.cpp | 1 + fio_cluster.cpp | 7 +------ fio_engine.cpp | 7 +------ fio_headers.h | 16 ++++++++++++++++ fio_sec_osd.cpp | 7 +------ http_client.cpp | 2 ++ malloc_or_die.h | 1 + messenger.cpp | 1 + qemu_driver.c | 9 +++++---- ringloop.cpp | 4 ++++ ringloop.h | 1 + timerfd_manager.cpp | 2 ++ 15 files changed, 41 insertions(+), 25 deletions(-) create mode 100644 fio_headers.h diff --git a/Makefile b/Makefile index 7572c846..207e9f14 100644 --- a/Makefile +++ b/Makefile @@ -99,11 +99,11 @@ epoll_manager.o: epoll_manager.cpp epoll_manager.h ringloop.h timerfd_manager.h g++ $(CXXFLAGS) -c -o $@ $< etcd_state_client.o: etcd_state_client.cpp base64.h etcd_state_client.h http_client.h json11/json11.hpp object_id.h osd_id.h osd_ops.h pg_states.h timerfd_manager.h g++ $(CXXFLAGS) -c -o $@ $< -fio_cluster.o: fio_cluster.cpp cluster_client.h epoll_manager.h etcd_state_client.h fio/fio.h fio/optgroup.h http_client.h json11/json11.hpp malloc_or_die.h messenger.h object_id.h osd_id.h osd_ops.h ringloop.h timerfd_manager.h +fio_cluster.o: fio_cluster.cpp cluster_client.h epoll_manager.h etcd_state_client.h fio/arch/arch.h fio/fio.h fio/optgroup.h fio_headers.h http_client.h json11/json11.hpp malloc_or_die.h messenger.h object_id.h osd_id.h osd_ops.h ringloop.h timerfd_manager.h g++ $(CXXFLAGS) -c -o $@ $< -fio_engine.o: fio_engine.cpp blockstore.h fio/fio.h fio/optgroup.h json11/json11.hpp object_id.h ringloop.h +fio_engine.o: fio_engine.cpp blockstore.h fio/arch/arch.h fio/fio.h fio/optgroup.h fio_headers.h json11/json11.hpp object_id.h ringloop.h g++ $(CXXFLAGS) -c -o $@ $< -fio_sec_osd.o: fio_sec_osd.cpp fio/fio.h fio/optgroup.h object_id.h osd_id.h osd_ops.h rw_blocking.h +fio_sec_osd.o: fio_sec_osd.cpp fio/arch/arch.h fio/fio.h fio/optgroup.h fio_headers.h object_id.h osd_id.h osd_ops.h rw_blocking.h g++ $(CXXFLAGS) -c -o $@ $< http_client.o: http_client.cpp http_client.h json11/json11.hpp timerfd_manager.h g++ $(CXXFLAGS) -c -o $@ $< diff --git a/blockstore.h b/blockstore.h index 09943c67..12ee1151 100644 --- a/blockstore.h +++ b/blockstore.h @@ -9,6 +9,7 @@ #include +#include #include #include #include diff --git a/cluster_client.cpp b/cluster_client.cpp index 90bb86b8..c3f46602 100644 --- a/cluster_client.cpp +++ b/cluster_client.cpp @@ -1,6 +1,7 @@ // Copyright (c) Vitaliy Filippov, 2019+ // License: VNPL-1.0 or GNU GPL-2.0+ (see README.md for details) +#include #include "cluster_client.h" cluster_client_t::cluster_client_t(ring_loop_t *ringloop, timerfd_manager_t *tfd, json11::Json & config) diff --git a/epoll_manager.cpp b/epoll_manager.cpp index 30afaa11..02092469 100644 --- a/epoll_manager.cpp +++ b/epoll_manager.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "epoll_manager.h" diff --git a/fio_cluster.cpp b/fio_cluster.cpp index 533ff998..3e388178 100644 --- a/fio_cluster.cpp +++ b/fio_cluster.cpp @@ -28,12 +28,7 @@ #include "epoll_manager.h" #include "cluster_client.h" -extern "C" { -#define CONFIG_HAVE_GETTID -#define CONFIG_PWRITEV2 -#include "fio/fio.h" -#include "fio/optgroup.h" -} +#include "fio_headers.h" struct sec_data { diff --git a/fio_engine.cpp b/fio_engine.cpp index b19e7760..47b7ec24 100644 --- a/fio_engine.cpp +++ b/fio_engine.cpp @@ -25,12 +25,7 @@ // -bs_config='{"data_device":"./test_data.bin"}' -size=1000M #include "blockstore.h" -extern "C" { -#define CONFIG_HAVE_GETTID -#define CONFIG_PWRITEV2 -#include "fio/fio.h" -#include "fio/optgroup.h" -} +#include "fio_headers.h" #include "json11/json11.hpp" diff --git a/fio_headers.h b/fio_headers.h new file mode 100644 index 00000000..f4ea0953 --- /dev/null +++ b/fio_headers.h @@ -0,0 +1,16 @@ +extern "C" { +// Kill atomics in fio headers +#define _STDATOMIC_H +#include "fio/arch/arch.h" + +#undef atomic_load_acquire +#undef atomic_store_release +#define atomic_load_acquire(p) *(p) +#define atomic_store_release(p, v) (*(p)) = (v) + +#define CONFIG_HAVE_GETTID +#define CONFIG_SYNC_FILE_RANGE +#define CONFIG_PWRITEV2 +#include "fio/fio.h" +#include "fio/optgroup.h" +} diff --git a/fio_sec_osd.cpp b/fio_sec_osd.cpp index 16006341..dd7fa605 100644 --- a/fio_sec_osd.cpp +++ b/fio_sec_osd.cpp @@ -30,12 +30,7 @@ #include "rw_blocking.h" #include "osd_ops.h" -extern "C" { -#define CONFIG_HAVE_GETTID -#define CONFIG_PWRITEV2 -#include "fio/fio.h" -#include "fio/optgroup.h" -} +#include "fio_headers.h" struct sec_data { diff --git a/http_client.cpp b/http_client.cpp index 2ea62896..ef818716 100644 --- a/http_client.cpp +++ b/http_client.cpp @@ -13,6 +13,8 @@ #include #include +#include + #include "json11/json11.hpp" #include "http_client.h" #include "timerfd_manager.h" diff --git a/malloc_or_die.h b/malloc_or_die.h index d08b3b3e..af31cf10 100644 --- a/malloc_or_die.h +++ b/malloc_or_die.h @@ -4,6 +4,7 @@ #pragma once #include +#include inline void* memalign_or_die(size_t alignment, size_t size) { diff --git a/messenger.cpp b/messenger.cpp index 21d4ac4a..dbc575a6 100644 --- a/messenger.cpp +++ b/messenger.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "messenger.h" diff --git a/qemu_driver.c b/qemu_driver.c index 3bcea75e..a9c6edba 100644 --- a/qemu_driver.c +++ b/qemu_driver.c @@ -212,7 +212,11 @@ static int coroutine_fn vitastor_co_truncate(BlockDriverState *bs, int64_t offse #if QEMU_VERSION_MAJOR >= 4 bool exact, #endif - PreallocMode prealloc, Error **errp) + PreallocMode prealloc, +#if QEMU_VERSION_MAJOR >= 5 && QEMU_VERSION_MINOR >= 1 || QEMU_VERSION_MAJOR > 5 + BdrvRequestFlags flags, +#endif + Error **errp) { VitastorClient *client = bs->opaque; @@ -357,9 +361,6 @@ static BlockDriver bdrv_vitastor = { .bdrv_parse_filename = vitastor_parse_filename, .bdrv_has_zero_init = bdrv_has_zero_init_1, -#if QEMU_VERSION_MAJOR >= 4 - .bdrv_has_zero_init_truncate = bdrv_has_zero_init_1, -#endif .bdrv_get_info = vitastor_get_info, .bdrv_getlength = vitastor_getlength, .bdrv_probe_blocksizes = vitastor_probe_blocksizes, diff --git a/ringloop.cpp b/ringloop.cpp index b18384bb..8d0b57f5 100644 --- a/ringloop.cpp +++ b/ringloop.cpp @@ -1,6 +1,10 @@ // Copyright (c) Vitaliy Filippov, 2019+ // License: VNPL-1.0 or GNU GPL-2.0+ (see README.md for details) +#include + +#include + #include "ringloop.h" ring_loop_t::ring_loop_t(int qd) diff --git a/ringloop.h b/ringloop.h index 21cad183..350bcaf1 100644 --- a/ringloop.h +++ b/ringloop.h @@ -11,6 +11,7 @@ #include #include +#include #include #include diff --git a/timerfd_manager.cpp b/timerfd_manager.cpp index 0977114b..11dcf89c 100644 --- a/timerfd_manager.cpp +++ b/timerfd_manager.cpp @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include "timerfd_manager.h" timerfd_manager_t::timerfd_manager_t(std::function)> set_fd_handler)