diff --git a/conanfile.py b/conanfile.py index 5be3f5a50..cfff42b6c 100644 --- a/conanfile.py +++ b/conanfile.py @@ -5,7 +5,7 @@ class HomestoreConan(ConanFile): name = "homestore" - version = "6.4.6" + version = "6.4.7" homepage = "https://github.com/eBay/Homestore" description = "HomeStore Storage Engine" diff --git a/src/lib/device/virtual_dev.cpp b/src/lib/device/virtual_dev.cpp index 2529097ee..a3da54c9f 100644 --- a/src/lib/device/virtual_dev.cpp +++ b/src/lib/device/virtual_dev.cpp @@ -51,6 +51,24 @@ SISL_LOGGING_DECL(device) namespace homestore { +#ifdef _PRERELEASE +#define SYNC_FLIP_INJECTION(IO_TYPE) \ + if (iomgr_flip::instance()->test_flip("IO_TYPE_failure")) { return std::make_error_code(std::errc::io_error); } \ + if (iomgr_flip::instance()->test_flip("IO_TYPE_stuck")) { \ + std::this_thread::sleep_for(std::chrono::hours(24 * 365 * 100)); // Sleep for 100 years\ + return std::make_error_code(std::errc::resource_unavailable_try_again);\ + } + +#define ASYNC_FLIP_INJECTION(IO_TYPE) \ + if (iomgr_flip::instance()->test_flip("IO_TYPE_failure")) { \ + return folly::makeFuture< std::error_code >(std::make_error_code(std::errc::io_error)); \ + } \ + if (iomgr_flip::instance()->test_flip("IO_TYPE_stuck")) { \ + std::this_thread::sleep_for(std::chrono::hours(24 * 365 * 100)); // Sleep for 100 years\ + return folly::makeFuture< std::error_code >(std::make_error_code(std::errc::resource_unavailable_try_again));\ +} +#endif + static std::shared_ptr< BlkAllocator > create_blk_allocator(blk_allocator_type_t btype, uint32_t vblock_size, uint32_t ppage_sz, uint32_t align_sz, uint64_t size, bool is_auto_recovery, uint32_t unique_id, bool is_init) { @@ -314,18 +332,12 @@ uint64_t VirtualDev::get_len(const iovec* iov, int iovcnt) { ////////////////////////// async write section ////////////////////////////////// folly::Future< std::error_code > VirtualDev::async_write(const char* buf, uint32_t size, BlkId const& bid, bool part_of_batch) { + HS_DBG_ASSERT_EQ(bid.is_multi(), false, "async_write needs individual pieces of blkid - not MultiBlkid"); + #ifdef _PRERELEASE - if (iomgr_flip::instance()->test_flip("blk_write_failure")) { - return folly::makeFuture< std::error_code >(std::make_error_code(std::errc::io_error)); - } - if (iomgr_flip::instance()->test_flip("blk_write_stuck")) { - std::this_thread::sleep_for(std::chrono::hours(24 * 365 * 100)); // Sleep for 100 years - return folly::makeFuture< std::error_code >(std::make_error_code(std::errc::resource_unavailable_try_again)); - } + ASYNC_FLIP_INJECTION(blk_write) #endif - HS_DBG_ASSERT_EQ(bid.is_multi(), false, "async_write needs individual pieces of blkid - not MultiBlkid"); - Chunk* chunk; uint64_t const dev_offset = to_dev_offset(bid, &chunk); if (sisl_unlikely(dev_offset == INVALID_DEV_OFFSET)) { @@ -345,14 +357,9 @@ folly::Future< std::error_code > VirtualDev::async_write(const char* buf, uint32 folly::Future< std::error_code > VirtualDev::async_write(const char* buf, uint32_t size, cshared< Chunk >& chunk, uint64_t offset_in_chunk) { #ifdef _PRERELEASE - if (iomgr_flip::instance()->test_flip("blk_write_failure")) { - return folly::makeFuture< std::error_code >(std::make_error_code(std::errc::io_error)); - } - if (iomgr_flip::instance()->test_flip("blk_write_stuck")) { - std::this_thread::sleep_for(std::chrono::hours(24 * 365 * 100)); // Sleep for 100 years - return folly::makeFuture< std::error_code >(std::make_error_code(std::errc::resource_unavailable_try_again)); - } + ASYNC_FLIP_INJECTION(blk_write) #endif + if (sisl_unlikely(!is_chunk_available(chunk))) { return folly::makeFuture< std::error_code >(std::make_error_code(std::errc::resource_unavailable_try_again)); } @@ -370,15 +377,11 @@ folly::Future< std::error_code > VirtualDev::async_write(const char* buf, uint32 folly::Future< std::error_code > VirtualDev::async_writev(const iovec* iov, const int iovcnt, BlkId const& bid, bool part_of_batch) { HS_DBG_ASSERT_EQ(bid.is_multi(), false, "async_writev needs individual pieces of blkid - not MultiBlkid"); + #ifdef _PRERELEASE - if (iomgr_flip::instance()->test_flip("blk_write_failure")) { - return folly::makeFuture< std::error_code >(std::make_error_code(std::errc::io_error)); - } - if (iomgr_flip::instance()->test_flip("blk_write_stuck")) { - std::this_thread::sleep_for(std::chrono::hours(24 * 365 * 100)); // Sleep for 100 years - return folly::makeFuture< std::error_code >(std::make_error_code(std::errc::resource_unavailable_try_again)); - } + ASYNC_FLIP_INJECTION(blk_write) #endif + Chunk* chunk; uint64_t const dev_offset = to_dev_offset(bid, &chunk); if (sisl_unlikely(dev_offset == INVALID_DEV_OFFSET)) { @@ -398,13 +401,7 @@ folly::Future< std::error_code > VirtualDev::async_writev(const iovec* iov, cons folly::Future< std::error_code > VirtualDev::async_writev(const iovec* iov, const int iovcnt, cshared< Chunk >& chunk, uint64_t offset_in_chunk) { #ifdef _PRERELEASE - if (iomgr_flip::instance()->test_flip("blk_write_failure")) { - return folly::makeFuture< std::error_code >(std::make_error_code(std::errc::io_error)); - } - if (iomgr_flip::instance()->test_flip("blk_write_stuck")) { - std::this_thread::sleep_for(std::chrono::hours(24 * 365 * 100)); // Sleep for 100 years - return folly::makeFuture< std::error_code >(std::make_error_code(std::errc::resource_unavailable_try_again)); - } + ASYNC_FLIP_INJECTION(blk_write) #endif if (sisl_unlikely(!is_chunk_available(chunk))) { return folly::makeFuture< std::error_code >(std::make_error_code(std::errc::resource_unavailable_try_again)); @@ -425,11 +422,7 @@ folly::Future< std::error_code > VirtualDev::async_writev(const iovec* iov, cons std::error_code VirtualDev::sync_write(const char* buf, uint32_t size, BlkId const& bid) { HS_DBG_ASSERT_EQ(bid.is_multi(), false, "sync_write needs individual pieces of blkid - not MultiBlkid"); #ifdef _PRERELEASE - if (iomgr_flip::instance()->test_flip("blk_write_failure")) { return std::make_error_code(std::errc::io_error); } - if (iomgr_flip::instance()->test_flip("blk_write_stuck")) { - std::this_thread::sleep_for(std::chrono::hours(24 * 365 * 100)); // Sleep for 100 years - return std::make_error_code(std::errc::resource_unavailable_try_again); - } + SYNC_FLIP_INJECTION(blk_write) #endif Chunk* chunk; uint64_t const dev_offset = to_dev_offset(bid, &chunk); @@ -442,11 +435,7 @@ std::error_code VirtualDev::sync_write(const char* buf, uint32_t size, BlkId con std::error_code VirtualDev::sync_write(const char* buf, uint32_t size, cshared< Chunk >& chunk, uint64_t offset_in_chunk) { #ifdef _PRERELEASE - if (iomgr_flip::instance()->test_flip("blk_write_failure")) { return std::make_error_code(std::errc::io_error); } - if (iomgr_flip::instance()->test_flip("blk_write_stuck")) { - std::this_thread::sleep_for(std::chrono::hours(24 * 365 * 100)); // Sleep for 100 years - return std::make_error_code(std::errc::resource_unavailable_try_again); - } + SYNC_FLIP_INJECTION(blk_write) #endif if (sisl_unlikely(!is_chunk_available(chunk))) { return std::make_error_code(std::errc::resource_unavailable_try_again); @@ -457,11 +446,7 @@ std::error_code VirtualDev::sync_write(const char* buf, uint32_t size, cshared< std::error_code VirtualDev::sync_writev(const iovec* iov, int iovcnt, BlkId const& bid) { HS_DBG_ASSERT_EQ(bid.is_multi(), false, "sync_writev needs individual pieces of blkid - not MultiBlkid"); #ifdef _PRERELEASE - if (iomgr_flip::instance()->test_flip("blk_write_failure")) { return std::make_error_code(std::errc::io_error); } - if (iomgr_flip::instance()->test_flip("blk_write_stuck")) { - std::this_thread::sleep_for(std::chrono::hours(24 * 365 * 100)); // Sleep for 100 years - return std::make_error_code(std::errc::resource_unavailable_try_again); - } + SYNC_FLIP_INJECTION(blk_write) #endif Chunk* chunk; uint64_t const dev_offset = to_dev_offset(bid, &chunk); @@ -482,11 +467,7 @@ std::error_code VirtualDev::sync_writev(const iovec* iov, int iovcnt, BlkId cons std::error_code VirtualDev::sync_writev(const iovec* iov, int iovcnt, cshared< Chunk >& chunk, uint64_t offset_in_chunk) { #ifdef _PRERELEASE - if (iomgr_flip::instance()->test_flip("blk_write_failure")) { return std::make_error_code(std::errc::io_error); } - if (iomgr_flip::instance()->test_flip("blk_write_stuck")) { - std::this_thread::sleep_for(std::chrono::hours(24 * 365 * 100)); // Sleep for 100 years - return std::make_error_code(std::errc::resource_unavailable_try_again); - } + SYNC_FLIP_INJECTION(blk_write) #endif if (sisl_unlikely(!is_chunk_available(chunk))) { return std::make_error_code(std::errc::resource_unavailable_try_again); @@ -510,13 +491,7 @@ folly::Future< std::error_code > VirtualDev::async_read(char* buf, uint64_t size bool part_of_batch) { HS_DBG_ASSERT_EQ(bid.is_multi(), false, "async_read needs individual pieces of blkid - not MultiBlkid"); #ifdef _PRERELEASE - if (iomgr_flip::instance()->test_flip("blk_read_failure")) { - return folly::makeFuture< std::error_code >(std::make_error_code(std::errc::io_error)); - } - if (iomgr_flip::instance()->test_flip("blk_read_stuck")) { - std::this_thread::sleep_for(std::chrono::hours(24 * 365 * 100)); // Sleep for 100 years - return folly::makeFuture< std::error_code >(std::make_error_code(std::errc::resource_unavailable_try_again)); - } + ASYNC_FLIP_INJECTION(blk_read) #endif Chunk* pchunk; @@ -531,13 +506,7 @@ folly::Future< std::error_code > VirtualDev::async_readv(iovec* iovs, int iovcnt bool part_of_batch) { HS_DBG_ASSERT_EQ(bid.is_multi(), false, "async_readv needs individual pieces of blkid - not MultiBlkid"); #ifdef _PRERELEASE - if (iomgr_flip::instance()->test_flip("blk_read_failure")) { - return folly::makeFuture< std::error_code >(std::make_error_code(std::errc::io_error)); - } - if (iomgr_flip::instance()->test_flip("blk_read_stuck")) { - std::this_thread::sleep_for(std::chrono::hours(24 * 365 * 100)); // Sleep for 100 years - return folly::makeFuture< std::error_code >(std::make_error_code(std::errc::resource_unavailable_try_again)); - } + ASYNC_FLIP_INJECTION(blk_read) #endif Chunk* pchunk; @@ -552,11 +521,7 @@ folly::Future< std::error_code > VirtualDev::async_readv(iovec* iovs, int iovcnt std::error_code VirtualDev::sync_read(char* buf, uint32_t size, BlkId const& bid) { HS_DBG_ASSERT_EQ(bid.is_multi(), false, "sync_read needs individual pieces of blkid - not MultiBlkid"); #ifdef _PRERELEASE - if (iomgr_flip::instance()->test_flip("blk_read_failure")) { return std::make_error_code(std::errc::io_error); } - if (iomgr_flip::instance()->test_flip("blk_read_stuck")) { - std::this_thread::sleep_for(std::chrono::hours(24 * 365 * 100)); // Sleep for 100 years - return std::make_error_code(std::errc::resource_unavailable_try_again); - } + SYNC_FLIP_INJECTION(blk_read) #endif Chunk* chunk; @@ -569,11 +534,7 @@ std::error_code VirtualDev::sync_read(char* buf, uint32_t size, BlkId const& bid std::error_code VirtualDev::sync_read(char* buf, uint32_t size, cshared< Chunk >& chunk, uint64_t offset_in_chunk) { #ifdef _PRERELEASE - if (iomgr_flip::instance()->test_flip("blk_read_failure")) { return std::make_error_code(std::errc::io_error); } - if (iomgr_flip::instance()->test_flip("blk_read_stuck")) { - std::this_thread::sleep_for(std::chrono::hours(24 * 365 * 100)); // Sleep for 100 years - return std::make_error_code(std::errc::resource_unavailable_try_again); - } + SYNC_FLIP_INJECTION(blk_read) #endif if (sisl_unlikely(!is_chunk_available(chunk))) { return std::make_error_code(std::errc::resource_unavailable_try_again); @@ -584,11 +545,7 @@ std::error_code VirtualDev::sync_read(char* buf, uint32_t size, cshared< Chunk > std::error_code VirtualDev::sync_readv(iovec* iov, int iovcnt, BlkId const& bid) { HS_DBG_ASSERT_EQ(bid.is_multi(), false, "sync_readv needs individual pieces of blkid - not MultiBlkid"); #ifdef _PRERELEASE - if (iomgr_flip::instance()->test_flip("blk_read_failure")) { return std::make_error_code(std::errc::io_error); } - if (iomgr_flip::instance()->test_flip("blk_read_stuck")) { - std::this_thread::sleep_for(std::chrono::hours(24 * 365 * 100)); // Sleep for 100 years - return std::make_error_code(std::errc::resource_unavailable_try_again); - } + SYNC_FLIP_INJECTION(blk_read) #endif Chunk* chunk; @@ -609,11 +566,7 @@ std::error_code VirtualDev::sync_readv(iovec* iov, int iovcnt, BlkId const& bid) std::error_code VirtualDev::sync_readv(iovec* iov, int iovcnt, cshared< Chunk >& chunk, uint64_t offset_in_chunk) { #ifdef _PRERELEASE - if (iomgr_flip::instance()->test_flip("blk_read_failure")) { return std::make_error_code(std::errc::io_error); } - if (iomgr_flip::instance()->test_flip("blk_read_stuck")) { - std::this_thread::sleep_for(std::chrono::hours(24 * 365 * 100)); // Sleep for 100 years - return std::make_error_code(std::errc::resource_unavailable_try_again); - } + SYNC_FLIP_INJECTION(blk_read) #endif if (sisl_unlikely(!is_chunk_available(chunk))) { return std::make_error_code(std::errc::resource_unavailable_try_again);