Fix build

This commit is contained in:
Alexey Milovidov 2021-07-28 02:59:56 +03:00
parent 10752dd1cf
commit 1974ed9d5c
2 changed files with 4 additions and 0 deletions

View File

@ -109,6 +109,7 @@ bool ReadBufferFromFileDescriptor::nextImpl()
void ReadBufferFromFileDescriptor::prefetch()
{
#if defined(POSIX_FADV_WILLNEED)
/// For direct IO, loading data into page cache is pointless.
if (required_alignment)
return;
@ -116,6 +117,7 @@ void ReadBufferFromFileDescriptor::prefetch()
/// Ask OS to prefetch data into page cache.
if (0 != posix_fadvise(fd, file_offset_of_buffer_end, internal_buffer.size(), POSIX_FADV_WILLNEED))
throwFromErrno("Cannot posix_fadvise", ErrorCodes::CANNOT_ADVISE);
#endif
}

View File

@ -33,9 +33,11 @@ private:
public:
RequestID submit(Request request) override
{
#if defined(POSIX_FADV_WILLNEED)
int fd = assert_cast<const LocalFileDescriptor &>(*request.descriptor).fd;
if (0 != posix_fadvise(fd, request.offset, request.size, POSIX_FADV_WILLNEED))
throwFromErrno("Cannot posix_fadvise", ErrorCodes::CANNOT_ADVISE);
#endif
std::lock_guard lock(mutex);
++counter;