mirror of
https://github.com/scylladb/scylladb.git
synced 2026-06-01 04:26:48 +00:00
sstables/storage: synch "dst_dir" more leanly in create_links_common()
filesystem_storage::create_links_common() runs on directories that generally differ from "_dir", thus, we can't replace its sync_directory() calls with _dir.sync(). We can still use a common (temporary) "opened_directory" object for synching "dst_dir" three times, saving two open and two close operations. This patch is best viewed with "git show -W". Signed-off-by: Laszlo Ersek <laszlo.ersek@scylladb.com>
This commit is contained in:
@@ -355,13 +355,14 @@ future<> filesystem_storage::create_links_common(const sstable& sst, sstring dst
|
||||
// TemporaryTOC is always first, TOC is always last
|
||||
auto dst = sstable::filename(dst_dir, sst._schema->ks_name(), sst._schema->cf_name(), sst._version, generation, sst._format, component_type::TemporaryTOC);
|
||||
co_await sst.sstable_write_io_check(idempotent_link_file, sst.filename(component_type::TOC), std::move(dst));
|
||||
co_await sst.sstable_write_io_check(sync_directory, dst_dir);
|
||||
auto dir = opened_directory(dst_dir);
|
||||
co_await dir.sync(sst._write_error_handler);
|
||||
co_await parallel_for_each(comps, [this, &sst, &dst_dir, generation] (auto p) {
|
||||
auto src = sstable::filename(_dir.native(), sst._schema->ks_name(), sst._schema->cf_name(), sst._version, sst._generation, sst._format, p.second);
|
||||
auto dst = sstable::filename(dst_dir, sst._schema->ks_name(), sst._schema->cf_name(), sst._version, generation, sst._format, p.second);
|
||||
return sst.sstable_write_io_check(idempotent_link_file, std::move(src), std::move(dst));
|
||||
});
|
||||
co_await sst.sstable_write_io_check(sync_directory, dst_dir);
|
||||
co_await dir.sync(sst._write_error_handler);
|
||||
auto dst_temp_toc = sstable::filename(dst_dir, sst._schema->ks_name(), sst._schema->cf_name(), sst._version, generation, sst._format, component_type::TemporaryTOC);
|
||||
if (mark_for_removal) {
|
||||
// Now that the source sstable is linked to new_dir, mark the source links for
|
||||
@@ -374,7 +375,8 @@ future<> filesystem_storage::create_links_common(const sstable& sst, sstring dst
|
||||
// the TemporaryTOC file at the destination.
|
||||
co_await sst.sstable_write_io_check(remove_file, std::move(dst_temp_toc));
|
||||
}
|
||||
co_await sst.sstable_write_io_check(sync_directory, dst_dir);
|
||||
co_await dir.sync(sst._write_error_handler);
|
||||
co_await dir.close();
|
||||
sstlog.trace("create_links: {} -> {} generation={}: done", sst.get_filename(), dst_dir, generation);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user