rocksdb/env
Omkar Gawde 1e1097d8d3 Fix close(-1) on failed open in btrfs rename fsync path (#14443)
Summary:
Pull Request resolved: https://github.com/facebook/rocksdb/pull/14443

In `PosixDirectory::FsyncWithDirOptions()`, when handling btrfs file rename
syncing, if `open()` fails and `fd` is -1, the code unconditionally calls
`close(fd)`. Calling `close(-1)` is undefined behavior per POSIX (returns
EBADF on Linux), and overwrites the original meaningful open error with a
misleading "While closing file after fsync" error message.

Fix: Guard the `close()` call with `fd >= 0`.

Reviewed By: xingbowang

Differential Revision: D95303407

fbshipit-source-id: 9b64b45a09e6ba41d87d164a1c094b4d22f7c186
2026-03-13 12:26:44 -07:00
..
composite_env.cc Support GetFileSize API in FSRandomAccessFile (#13676) 2025-07-09 10:40:28 -07:00
composite_env_wrapper.h Revert "Create a new API FileSystem::SyncFile for file sync (#13762)" (#13987) 2025-09-22 15:30:24 -07:00
emulated_clock.h Remove 'virtual' when implied by 'override' (#12319) 2024-01-31 13:14:42 -08:00
env.cc Remove obsolete compression code and some .h->.cc movement (#14325) 2026-02-13 11:18:05 -08:00
env_basic_test.cc internal_repo_rocksdb (4372117296613874540) (#12117) 2023-12-04 11:17:32 -08:00
env_chroot.cc internal_repo_rocksdb (4372117296613874540) (#12117) 2023-12-04 11:17:32 -08:00
env_chroot.h Remove RocksDB LITE (#11147) 2023-01-27 13:14:19 -08:00
env_encryption.cc Revert "Create a new API FileSystem::SyncFile for file sync (#13762)" (#13987) 2025-09-22 15:30:24 -07:00
env_encryption_ctr.h Standardize on clang-format version 18 (#13233) 2024-12-19 10:58:40 -08:00
env_posix.cc Port codemod changes from fbcode/rocksdb (#13714) 2025-06-20 17:56:24 -07:00
env_test.cc Remove deprecated DB::Open raw pointer variants (and more) (#14335) 2026-02-17 23:33:39 -08:00
file_system.cc Revert "Create a new API FileSystem::SyncFile for file sync (#13762)" (#13987) 2025-09-22 15:30:24 -07:00
file_system_tracer.cc Use C++20 in public API, fix CI (#13915) 2025-09-08 13:11:28 -07:00
file_system_tracer.h Change ReadAsync callback API to remove const from FSReadRequest (#11649) 2024-02-16 09:14:55 -08:00
fs_on_demand.cc Fix compile error in Clang (#12588) 2024-05-02 16:54:21 -07:00
fs_on_demand.h Basic RocksDB follower implementation (#12540) 2024-04-19 19:13:31 -07:00
fs_posix.cc Check io_uring probe result in SupportedOps (#14355) 2026-02-20 10:43:30 -08:00
fs_readonly.h Standardize on clang-format version 18 (#13233) 2024-12-19 10:58:40 -08:00
fs_remap.cc Standardize on clang-format version 18 (#13233) 2024-12-19 10:58:40 -08:00
fs_remap.h Standardize on clang-format version 18 (#13233) 2024-12-19 10:58:40 -08:00
io_posix.cc Fix close(-1) on failed open in btrfs rename fsync path (#14443) 2026-03-13 12:26:44 -07:00
io_posix.h Check io_uring probe result in SupportedOps (#14355) 2026-02-20 10:43:30 -08:00
io_posix_test.cc Fix close(-1) on failed open in btrfs rename fsync path (#14443) 2026-03-13 12:26:44 -07:00
mock_env.cc Revert "Create a new API FileSystem::SyncFile for file sync (#13762)" (#13987) 2025-09-22 15:30:24 -07:00
mock_env.h Revert "Create a new API FileSystem::SyncFile for file sync (#13762)" (#13987) 2025-09-22 15:30:24 -07:00
mock_env_test.cc internal_repo_rocksdb (4372117296613874540) (#12117) 2023-12-04 11:17:32 -08:00
unique_id_gen.cc Fix windows build errors (rdtsc and fnptr) (#12008) 2023-10-24 16:20:37 -07:00
unique_id_gen.h Internal API for generating semi-random salt (#11331) 2023-06-21 11:32:49 -07:00