1+ #include < common/dout.h>
12#include < errno.h>
23#include < fcntl.h>
34#include < deque>
5+ #include < iostream>
46#include < sstream>
57#include < string>
68#include < utility>
@@ -2347,7 +2349,7 @@ void pool_io_callback(completion_t cb, void *arg /* Actually AioCompletion* */)
23472349 ASSERT_EQ (0 , info->c ->wait_for_complete ());
23482350 }
23492351 int r = info->c ->get_return_value ();
2350- // cout << "finish " << i << " r = " << r << std::endl;
2352+ cout << " finish " << i << " r = " << r << std::endl;
23512353
23522354 std::scoped_lock l (my_lock);
23532355 inflight.erase (i);
@@ -2369,8 +2371,9 @@ TEST(LibRadosAio, PoolEIOFlag) {
23692371 bufferlist bl;
23702372 bl.append (" some data" );
23712373 std::thread *t = nullptr ;
2374+ std::atomic<bool > missed_eio{false };
23722375
2373- unsigned max = 100 ;
2376+ unsigned max = 1000 ;
23742377 unsigned timeout = max * 10 ;
23752378 unsigned long i = 1 ;
23762379 my_lock.lock ();
@@ -2385,19 +2388,23 @@ TEST(LibRadosAio, PoolEIOFlag) {
23852388 // cout << "start " << i << " r = " << r << std::endl;
23862389
23872390 if (i == max / 2 ) {
2388- cout << " setting pool EIO" << std::endl;
2389- t = new std::thread (
2390- [&] {
2391- bufferlist empty;
2392- ASSERT_EQ (0 , test_data.m_cluster .mon_command (
2393- fmt::format (R"( {{
2394- "prefix": "osd pool set",
2395- "pool": "{}",
2396- "var": "eio",
2397- "val": "true"
2398- }})" , test_data.m_pool_name ),
2399- empty, nullptr , nullptr ));
2400- });
2391+ t = new std::thread ([&] {
2392+ bufferlist empty;
2393+ cout << " sending pool EIO time: " << ceph_clock_now () << std::endl;
2394+ ASSERT_EQ (0 , test_data.m_cluster .mon_command (
2395+ fmt::format (R"( {{
2396+ "prefix": "osd pool set",
2397+ "pool": "{}",
2398+ "var": "eio",
2399+ "val": "true"
2400+ }})" , test_data.m_pool_name ),
2401+ empty, nullptr , nullptr ));
2402+
2403+ {
2404+ std::scoped_lock lk (my_lock);
2405+ missed_eio = (!min_failed && max_success == max);
2406+ }
2407+ });
24012408 }
24022409
24032410 std::this_thread::sleep_for (10ms);
@@ -2418,6 +2425,10 @@ TEST(LibRadosAio, PoolEIOFlag) {
24182425 my_lock.lock ();
24192426 }
24202427
2428+ if (!missed_eio) {
2429+ GTEST_SKIP () << " eio flag missed all ios that already completed" ;
2430+ my_lock.unlock ();
2431+ }
24212432 cout << " max_success " << max_success << " , min_failed " << min_failed << std::endl;
24222433 ASSERT_TRUE (max_success + 1 == min_failed);
24232434 my_lock.unlock ();
0 commit comments