From efb3678606aae209f61e24a0c5b1d72b1a1217ab Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Thu, 8 Apr 2021 10:52:21 +0300 Subject: [PATCH] Fix qemu-img broken in 0.5.11 Caused by the lack of reenterability of the main cluster_client function --- src/cluster_client.cpp | 16 ++++++++++++++++ src/cluster_client.h | 1 + tests/test_write.sh | 10 +++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/cluster_client.cpp b/src/cluster_client.cpp index a1a4b5b8..3682f08c 100644 --- a/src/cluster_client.cpp +++ b/src/cluster_client.cpp @@ -95,6 +95,14 @@ void cluster_client_t::continue_ops(bool up_retry) // We're offline return; } + if (continuing_ops) + { + // Attempt to reenter the function + continuing_ops = 2; + return; + } +restart: + continuing_ops = 1; bool has_flushes = false, has_writes = false; int j = 0; for (int i = 0; i < op_queue.size(); i++) @@ -141,6 +149,14 @@ void cluster_client_t::continue_ops(bool up_retry) } } op_queue.resize(j); + if (continuing_ops == 2) + { + goto restart; + } + else + { + continuing_ops = 0; + } } static uint32_t is_power_of_two(uint64_t value) diff --git a/src/cluster_client.h b/src/cluster_client.h index dfa8aa7a..da7e22a5 100644 --- a/src/cluster_client.h +++ b/src/cluster_client.h @@ -82,6 +82,7 @@ class cluster_client_t bool pgs_loaded = false; ring_consumer_t consumer; std::vector> on_ready_hooks; + int continuing_ops = 0; public: etcd_state_client_t st_cli; diff --git a/tests/test_write.sh b/tests/test_write.sh index 5f1002c0..73c96ff5 100755 --- a/tests/test_write.sh +++ b/tests/test_write.sh @@ -35,6 +35,14 @@ fi # fio -thread -name=test -ioengine=build/src/libfio_vitastor_sec.so -bs=4k -fsync=128 `$ETCDCTL get /vitastor/osd/state/1 --print-value-only | jq -r '"-host="+.addresses[0]+" -port="+(.port|tostring)'` -rw=write -size=32M LD_PRELOAD=libasan.so.5 \ - fio -thread -name=test -ioengine=build/src/libfio_vitastor.so -bs=4M -direct=1 -iodepth=1 -fsync=1 -rw=write -etcd=$ETCD_URL -pool=1 -inode=1 -size=1G -cluster_log_level=10 + fio -thread -name=test -ioengine=build/src/libfio_vitastor.so -bs=4M -direct=1 -iodepth=1 -fsync=1 -rw=write -etcd=$ETCD_URL -pool=1 -inode=1 -size=128M -cluster_log_level=10 + +qemu-img convert -S 4096 -p \ + -f raw "vitastor:etcd_host=127.0.0.1\:$ETCD_PORT/v3:pool=1:inode=1:size=$((128*1024*1024))" \ + -O raw ./testdata/read.bin + +qemu-img convert -S 4096 -p \ + -f raw ./testdata/read.bin \ + -O raw "vitastor:etcd_host=127.0.0.1\:$ETCD_PORT/v3:pool=1:inode=1:size=$((128*1024*1024))" format_green OK