| 780 | } |
| 781 | |
| 782 | void TFileHandle::PrefetchCache(i64 offset, i64 length, bool wait) const noexcept { |
| 783 | #ifdef _linux_ |
| 784 | #if HAVE_POSIX_FADVISE |
| 785 | // POSIX_FADV_WILLNEED starts reading upto read_ahead_kb in background |
| 786 | ::posix_fadvise(Fd_, offset, length, POSIX_FADV_WILLNEED); |
| 787 | #endif |
| 788 | |
| 789 | if (wait) { |
| 790 | TFileHandle devnull("/dev/null", OpenExisting | WrOnly | CloseOnExec); |
| 791 | off_t end = length ? (offset + length) : GetLength(); |
| 792 | off_t pos = offset; |
| 793 | ssize_t ret; |
| 794 | |
| 795 | do { |
| 796 | ret = ::sendfile((FHANDLE)devnull, Fd_, &pos, end - pos); |
| 797 | } while (pos < end && (ret > 0 || errno == EINTR)); |
| 798 | } |
| 799 | #else |
| 800 | Y_UNUSED(offset); |
| 801 | Y_UNUSED(length); |
| 802 | Y_UNUSED(wait); |
| 803 | #endif |
| 804 | } |
| 805 | |
| 806 | void TFileHandle::EvictCache(i64 offset, i64 length) const noexcept { |
| 807 | #if HAVE_POSIX_FADVISE |