This commit is contained in:
Nikita Vasilev 2020-05-24 14:24:45 +03:00
parent c70401b1e4
commit e76cdbdc43
2 changed files with 13 additions and 13 deletions

View File

@ -577,13 +577,12 @@ void SSDCachePartition::getValueFromStorage(const PaddedPODArray<Index> & indice
for (size_t i = 0; i < index_to_out.size(); ++i) for (size_t i = 0; i < index_to_out.size(); ++i)
{ {
#if defined(__FreeBSD__) #if defined(__FreeBSD__)
const auto back_offset = requests.back().aio.aio_offset; const size_t back_offset = requests.empty() ? -1 : static_cast<size_t>(requests.back().aio.aio_offset);
#else #else
const auto back_offset = requests.back().aio_offset; const size_t back_offset = requests.empty() ? -1 : static_cast<size_t>(requests.back().aio_offset);
#endif #endif
if (!requests.empty() && if (!requests.empty() && back_offset == index_to_out[i].first.getBlockId() * block_size)
static_cast<size_t>(back_offset) == index_to_out[i].first.getBlockId() * block_size)
{ {
blocks_to_indices.back().push_back(i); blocks_to_indices.back().push_back(i);
continue; continue;
@ -616,10 +615,7 @@ void SSDCachePartition::getValueFromStorage(const PaddedPODArray<Index> & indice
std::vector<bool> processed(requests.size(), false); std::vector<bool> processed(requests.size(), false);
std::vector<io_event> events(requests.size()); std::vector<io_event> events(requests.size());
#if defined(__FreeBSD__) #if defined(__linux__)
for (auto & event : events)
event.udata = -1;
#else
for (auto & event : events) for (auto & event : events)
event.res = -1; event.res = -1;
#endif #endif
@ -649,7 +645,7 @@ void SSDCachePartition::getValueFromStorage(const PaddedPODArray<Index> & indice
if (bytes_written != static_cast<ssize_t>(block_size)) if (bytes_written != static_cast<ssize_t>(block_size))
{ {
#if defined(__FreeBSD__) #if defined(__FreeBSD__)
throw Exception("AIO failed to read file " + path + BIN_FILE_EXT + "."); throw Exception("AIO failed to read file " + path + BIN_FILE_EXT + ".", ErrorCodes::AIO_READ_ERROR);
#else #else
throw Exception("AIO failed to read file " + path + BIN_FILE_EXT + ". " + throw Exception("AIO failed to read file " + path + BIN_FILE_EXT + ". " +
"request_id= " + std::to_string(request.aio_data) + "/ " + std::to_string(requests.size()) + "request_id= " + std::to_string(request.aio_data) + "/ " + std::to_string(requests.size()) +
@ -658,7 +654,7 @@ void SSDCachePartition::getValueFromStorage(const PaddedPODArray<Index> & indice
#endif #endif
} }
#if defined(__FreeBSD__) #if defined(__FreeBSD__)
const auto* buf_ptr = reinterpret_cast<char *>(request.aio.aio_buf); const volatile auto* buf_ptr = reinterpret_cast<volatile char *>(request.aio.aio_buf);
#else #else
const auto* buf_ptr = reinterpret_cast<char *>(request.aio_buf); const auto* buf_ptr = reinterpret_cast<char *>(request.aio_buf);
#endif #endif
@ -739,13 +735,15 @@ void SSDCachePartition::clearOldestBlocks()
throwFromErrno("io_getevents: Failed to get an event for asynchronous IO", ErrorCodes::CANNOT_IO_GETEVENTS); throwFromErrno("io_getevents: Failed to get an event for asynchronous IO", ErrorCodes::CANNOT_IO_GETEVENTS);
} }
#if defined(__FreeBSD__)
if (event.aio.res != static_cast<ssize_t>(request.aio.aio_nbytes))
throw Exception("GC: AIO failed to read file " + path + BIN_FILE_EXT + ".", ErrorCodes::AIO_READ_ERROR);
#else
if (event.res != static_cast<ssize_t>(request.aio_nbytes)) if (event.res != static_cast<ssize_t>(request.aio_nbytes))
{
throw Exception("GC: AIO failed to read file " + path + BIN_FILE_EXT + ". " + throw Exception("GC: AIO failed to read file " + path + BIN_FILE_EXT + ". " +
"aio_nbytes=" + std::to_string(request.aio_nbytes) + "aio_nbytes=" + std::to_string(request.aio_nbytes) +
", returned=" + std::to_string(event.res) + ".", ErrorCodes::AIO_READ_ERROR); ", returned=" + std::to_string(event.res) + ".", ErrorCodes::AIO_READ_ERROR);
} #endif
__msan_unpoison(read_buffer_memory.data(), read_buffer_memory.size()); __msan_unpoison(read_buffer_memory.data(), read_buffer_memory.size());
} }

View File

@ -32,8 +32,10 @@ void registerDictionaries()
registerDictionaryFlat(factory); registerDictionaryFlat(factory);
registerDictionaryHashed(factory); registerDictionaryHashed(factory);
registerDictionaryCache(factory); registerDictionaryCache(factory);
#if defined(__linux__) || defined(__FreeBSD__)
registerDictionarySSDCache(factory); registerDictionarySSDCache(factory);
registerDictionarySSDComplexKeyCache(factory); registerDictionarySSDComplexKeyCache(factory);
#endif
registerDictionaryPolygon(factory); registerDictionaryPolygon(factory);
registerDictionaryDirect(factory); registerDictionaryDirect(factory);
} }