sstables: extract default write open flags into a constant

Extract the commonly used `open_flags::wo | open_flags::create |
open_flags::exclusive` into a reusable constant
`sstable_write_open_flags` to reduce duplication.
This commit is contained in:
Taras Veretilnyk
2026-02-05 23:26:51 +01:00
parent c8281b7b8b
commit f140ab0332
4 changed files with 7 additions and 5 deletions

View File

@@ -965,7 +965,7 @@ void writer::init_file_writers() {
file_output_stream_options options;
options.buffer_size = 32 * 1024;
_hashes_writer = std::make_unique<file_writer>(_sst.make_component_file_writer(component_type::TemporaryHashes, std::move(options),
open_flags::wo | open_flags::create | open_flags::exclusive).get());
sstable_write_open_flags).get());
}
}

View File

@@ -641,7 +641,7 @@ future<sstring> sstable_directory::create_pending_deletion_log(opened_directory&
dirlog.trace("Writing {}", tmp_pending_delete_log);
touch_directory(pending_delete_dir).get();
auto oflags = open_flags::wo | open_flags::create | open_flags::exclusive;
auto oflags = sstable_write_open_flags;
// Create temporary pending_delete log file.
auto f = open_file_dma(tmp_pending_delete_log, oflags).get();
// Write all toc names into the log file.

View File

@@ -1516,7 +1516,7 @@ future<> sstable::update_info_for_opened_data(sstable_open_config cfg) {
}
future<> sstable::create_data() noexcept {
auto oflags = open_flags::wo | open_flags::create | open_flags::exclusive;
auto oflags = sstable_write_open_flags;
file_open_options opt;
opt.extent_allocation_size_hint = 32 << 20;
opt.sloppy_size = true;

View File

@@ -182,6 +182,8 @@ inline fs::path make_path(std::string_view table_dir, sstable_state state) {
constexpr const char* repair_origin = "repair";
const open_flags sstable_write_open_flags = open_flags::wo | open_flags::create | open_flags::exclusive;
class delayed_commit_changes {
std::unordered_set<sstring> _dirs;
friend class filesystem_storage;
@@ -673,10 +675,10 @@ private:
future<> unlink_component(component_type type) noexcept;
future<file_writer> make_component_file_writer(component_type c, file_output_stream_options options,
open_flags oflags = open_flags::wo | open_flags::create | open_flags::exclusive) noexcept;
open_flags oflags = sstable_write_open_flags) noexcept;
future<std::unique_ptr<crc32_digest_file_writer>> make_digests_component_file_writer(component_type c, file_output_stream_options options,
open_flags oflags = open_flags::wo | open_flags::create | open_flags::exclusive) noexcept;
open_flags oflags = sstable_write_open_flags) noexcept;
void generate_toc();
void open_sstable(const sstring& origin);