diff options
author | Hans Holmberg <hans.holmberg@wdc.com> | 2024-05-07 17:54:50 -0700 |
---|---|---|
committer | Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com> | 2024-05-07 17:54:50 -0700 |
commit | b8400c9fafc1efdb8b75a8459fc725225f953f95 (patch) | |
tree | 84a77050460bcf9ee25ced0bbb6a97e4ce1ad445 | |
parent | 5bf2c00a35debbd59840814090ce4e3b7f007798 (diff) |
Make linux file write life time hinting work (#12595)
Summary:
The life time hint fcntl takes a 64-bit unsigned int, so make sure to pass a uint64_t when doing the syscall.
See:
https://man7.org/linux/man-pages/man2/fcntl.2.html
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c75b1d9421f80f4143e389d2d50ddfc8a28c8c35
This is one of those "How did this ever work?", as Env::WriteLifeTimeHint hint is definitely not the same as an 64-bit unsigned int.
What's surprising is that SetWriteLifeTimeHint does pass a valid hint from time to time.
Thanks,
Hans
Pull Request resolved: https://github.com/facebook/rocksdb/pull/12595
Reviewed By: cbi42
Differential Revision: D56901280
Pulled By: ajkr
fbshipit-source-id: f276348863cbc29a537bed9450b16b0cc513ea78
-rw-r--r-- | env/io_posix.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/env/io_posix.cc b/env/io_posix.cc index 29efb055b..f31ee7d16 100644 --- a/env/io_posix.cc +++ b/env/io_posix.cc @@ -1441,10 +1441,12 @@ void PosixWritableFile::SetWriteLifeTimeHint(Env::WriteLifeTimeHint hint) { #ifdef OS_LINUX // Suppress Valgrind "Unimplemented functionality" error. #ifndef ROCKSDB_VALGRIND_RUN + uint64_t fcntl_hint = hint; + if (hint == write_hint_) { return; } - if (fcntl(fd_, F_SET_RW_HINT, &hint) == 0) { + if (fcntl(fd_, F_SET_RW_HINT, &fcntl_hint) == 0) { write_hint_ = hint; } #else |