diff --git a/database.cc b/database.cc index 94306526b3..b40ae4ba10 100644 --- a/database.cc +++ b/database.cc @@ -1862,7 +1862,7 @@ seal_snapshot(sstring jsondir) { dblog.debug("Storing manifest {}", jsonfile); return recursive_touch_directory(jsondir).then([jsonfile, json = std::move(json)] { - return engine().open_file_dma(jsonfile, open_flags::wo | open_flags::create | open_flags::truncate).then([json](file f) { + return open_file_dma(jsonfile, open_flags::wo | open_flags::create | open_flags::truncate).then([json](file f) { return do_with(make_file_output_stream(std::move(f)), [json] (output_stream& out) { return out.write(json.c_str(), json.size()).then([&out] { return out.flush(); diff --git a/db/commitlog/commitlog.cc b/db/commitlog/commitlog.cc index 3bce44fed0..9da70efaf7 100644 --- a/db/commitlog/commitlog.cc +++ b/db/commitlog/commitlog.cc @@ -887,7 +887,7 @@ void db::commitlog::segment_manager::flush_segments(bool force) { future db::commitlog::segment_manager::allocate_segment(bool active) { descriptor d(next_id()); - return engine().open_file_dma(cfg.commit_log_location + "/" + d.filename(), open_flags::wo | open_flags::create).then([this, d, active](file f) { + return open_file_dma(cfg.commit_log_location + "/" + d.filename(), open_flags::wo | open_flags::create).then([this, d, active](file f) { // xfs doesn't like files extended betond eof, so enlarge the file return f.truncate(max_size).then([this, d, active, f] () mutable { auto s = make_lw_shared(this, d, std::move(f), active); @@ -1215,7 +1215,7 @@ const db::commitlog::config& db::commitlog::active_config() const { future, db::replay_position>>> db::commitlog::read_log_file(const sstring& filename, commit_load_reader_func next, position_type off) { - return engine().open_file_dma(filename, open_flags::ro).then([next = std::move(next), off](file f) { + return open_file_dma(filename, open_flags::ro).then([next = std::move(next), off](file f) { return std::make_unique, replay_position>>( read_log_file(std::move(f), std::move(next), off)); }); diff --git a/db/config.cc b/db/config.cc index 01b5f60d79..f83a793664 100644 --- a/db/config.cc +++ b/db/config.cc @@ -410,7 +410,7 @@ future<> db::config::read_from_file(file f) { } future<> db::config::read_from_file(const sstring& filename) { - return engine().open_file_dma(filename, open_flags::ro).then([this](file f) { + return open_file_dma(filename, open_flags::ro).then([this](file f) { return read_from_file(std::move(f)); }); } diff --git a/locator/gossiping_property_file_snitch.cc b/locator/gossiping_property_file_snitch.cc index 45a37e080a..c4b1d00485 100644 --- a/locator/gossiping_property_file_snitch.cc +++ b/locator/gossiping_property_file_snitch.cc @@ -41,7 +41,7 @@ namespace locator { future gossiping_property_file_snitch::property_file_was_modified() { - return engine().open_file_dma(_prop_file_name, open_flags::ro) + return open_file_dma(_prop_file_name, open_flags::ro) .then([this](file f) { return do_with(std::move(f), [] (file& f) { return f.stat(); diff --git a/locator/production_snitch_base.cc b/locator/production_snitch_base.cc index 2728202eab..d00d15c757 100644 --- a/locator/production_snitch_base.cc +++ b/locator/production_snitch_base.cc @@ -2,7 +2,7 @@ namespace locator { future<> production_snitch_base::load_property_file() { - return engine().open_file_dma(_prop_file_name, open_flags::ro) + return open_file_dma(_prop_file_name, open_flags::ro) .then([this] (file f) { return do_with(std::move(f), [this] (file& f) { return f.size().then([this, &f] (size_t s) { diff --git a/sstables/sstables.cc b/sstables/sstables.cc index 9d0d3b22c5..66583bdedd 100644 --- a/sstables/sstables.cc +++ b/sstables/sstables.cc @@ -654,7 +654,7 @@ future<> sstable::read_toc() { sstlog.debug("Reading TOC file {} ", file_path); - return engine().open_file_dma(file_path, open_flags::ro).then([this] (file f) { + return open_file_dma(file_path, open_flags::ro).then([this] (file f) { auto bufptr = allocate_aligned_buffer(4096, 4096); auto buf = bufptr.get(); @@ -724,7 +724,7 @@ void sstable::write_toc() { sstlog.debug("Writing TOC file {} ", file_path); // Writing TOC content to temporary file. - file f = engine().open_file_dma(file_path, open_flags::wo | open_flags::create | open_flags::truncate).get0(); + file f = open_file_dma(file_path, open_flags::wo | open_flags::create | open_flags::truncate).get0(); auto out = file_writer(std::move(f), 4096); auto w = file_writer(std::move(out)); @@ -764,7 +764,7 @@ void write_crc(const sstring file_path, checksum& c) { sstlog.debug("Writing CRC file {} ", file_path); auto oflags = open_flags::wo | open_flags::create | open_flags::exclusive; - file f = engine().open_file_dma(file_path, oflags).get0(); + file f = open_file_dma(file_path, oflags).get0(); auto out = file_writer(std::move(f), 4096); auto w = file_writer(std::move(out)); write(w, c); @@ -776,7 +776,7 @@ void write_digest(const sstring file_path, uint32_t full_checksum) { sstlog.debug("Writing Digest file {} ", file_path); auto oflags = open_flags::wo | open_flags::create | open_flags::exclusive; - auto f = engine().open_file_dma(file_path, oflags).get0(); + auto f = open_file_dma(file_path, oflags).get0(); auto out = file_writer(std::move(f), 4096); auto w = file_writer(std::move(out)); @@ -821,7 +821,7 @@ future<> sstable::read_simple(T& component) { auto file_path = filename(Type); sstlog.debug(("Reading " + _component_map[Type] + " file {} ").c_str(), file_path); - return engine().open_file_dma(file_path, open_flags::ro).then([this, &component] (file f) { + return open_file_dma(file_path, open_flags::ro).then([this, &component] (file f) { auto r = make_lw_shared(std::move(f), sstable_buffer_size); auto fut = parse(*r, component); return fut.finally([r = std::move(r)] { @@ -842,7 +842,7 @@ template void sstable::write_simple(T& component) { auto file_path = filename(Type); sstlog.debug(("Writing " + _component_map[Type] + " file {} ").c_str(), file_path); - file f = engine().open_file_dma(file_path, open_flags::wo | open_flags::create | open_flags::truncate).get0(); + file f = open_file_dma(file_path, open_flags::wo | open_flags::create | open_flags::truncate).get0(); auto out = file_writer(std::move(f), sstable_buffer_size); auto w = file_writer(std::move(out)); write(w, component); @@ -879,8 +879,8 @@ void sstable::write_statistics() { } future<> sstable::open_data() { - return when_all(engine().open_file_dma(filename(component_type::Index), open_flags::ro), - engine().open_file_dma(filename(component_type::Data), open_flags::ro)).then([this] (auto files) { + return when_all(open_file_dma(filename(component_type::Index), open_flags::ro), + open_file_dma(filename(component_type::Data), open_flags::ro)).then([this] (auto files) { _index_file = std::get(std::get<0>(files).get()); _data_file = std::get(std::get<1>(files).get()); return _data_file.size().then([this] (auto size) { @@ -900,8 +900,8 @@ future<> sstable::open_data() { future<> sstable::create_data() { auto oflags = open_flags::wo | open_flags::create | open_flags::exclusive; - return when_all(engine().open_file_dma(filename(component_type::Index), oflags), - engine().open_file_dma(filename(component_type::Data), oflags)).then([this] (auto files) { + return when_all(open_file_dma(filename(component_type::Index), oflags), + open_file_dma(filename(component_type::Data), oflags)).then([this] (auto files) { // FIXME: If both files could not be created, the first get below will // throw an exception, and second get() will not be attempted, and // we'll get a warning about the second future being destructed diff --git a/tests/commitlog_test.cc b/tests/commitlog_test.cc index ad171aade2..45d0fe7167 100644 --- a/tests/commitlog_test.cc +++ b/tests/commitlog_test.cc @@ -321,7 +321,7 @@ SEASTAR_TEST_CASE(test_commitlog_reader){ } static future<> corrupt_segment(sstring seg, uint64_t off, uint32_t value) { - return engine().open_file_dma(seg, open_flags::rw).then([off, value](file f) { + return open_file_dma(seg, open_flags::rw).then([off, value](file f) { size_t size = align_up(off, 4096); return do_with(std::move(f), [size, off, value](file& f) { return f.dma_read_exactly(0, size).then([&f, off, value](auto buf) { diff --git a/tests/sstable_datafile_test.cc b/tests/sstable_datafile_test.cc index da73da0828..0597570b50 100644 --- a/tests/sstable_datafile_test.cc +++ b/tests/sstable_datafile_test.cc @@ -90,7 +90,7 @@ SEASTAR_TEST_CASE(datafile_generation_01) { auto fname = sstable::filename("tests/sstables/tests-temporary", "ks", "cf", la, 1, big, sstable::component_type::Data); return sst->write_components(*mt).then([mt, sst, s, fname] { - return engine().open_file_dma(fname, open_flags::ro).then([] (file f) { + return open_file_dma(fname, open_flags::ro).then([] (file f) { auto bufptr = allocate_aligned_buffer(4096, 4096); auto fut = f.dma_read(0, bufptr.get(), 4096); @@ -156,7 +156,7 @@ SEASTAR_TEST_CASE(datafile_generation_02) { auto fname = sstable::filename("tests/sstables/tests-temporary", "ks", "cf", la, 2, big, sstable::component_type::Data); return sst->write_components(*mt).then([mt, sst, s, fname] { - return engine().open_file_dma(fname, open_flags::ro).then([] (file f) { + return open_file_dma(fname, open_flags::ro).then([] (file f) { auto bufptr = allocate_aligned_buffer(4096, 4096); auto fut = f.dma_read(0, bufptr.get(), 4096); @@ -224,7 +224,7 @@ SEASTAR_TEST_CASE(datafile_generation_03) { auto fname = sstable::filename("tests/sstables/tests-temporary", "ks", "cf", la, 3, big, sstable::component_type::Data); return sst->write_components(*mt).then([mt, sst, s, fname] { - return engine().open_file_dma(fname, open_flags::ro).then([] (file f) { + return open_file_dma(fname, open_flags::ro).then([] (file f) { auto bufptr = allocate_aligned_buffer(4096, 4096); auto fut = f.dma_read(0, bufptr.get(), 4096); @@ -295,7 +295,7 @@ SEASTAR_TEST_CASE(datafile_generation_04) { auto fname = sstable::filename("tests/sstables/tests-temporary", "ks", "cf", la, 4, big, sstable::component_type::Data); return sst->write_components(*mt).then([mt, sst, s, fname] { - return engine().open_file_dma(fname, open_flags::ro).then([] (file f) { + return open_file_dma(fname, open_flags::ro).then([] (file f) { auto bufptr = allocate_aligned_buffer(4096, 4096); auto fut = f.dma_read(0, bufptr.get(), 4096); @@ -366,7 +366,7 @@ SEASTAR_TEST_CASE(datafile_generation_05) { return sst->write_components(*mt).then([mt, sst, s] { auto fname = sstable::filename("tests/sstables/tests-temporary", "ks", "cf", la, 5, big, sstable::component_type::Data); - return engine().open_file_dma(fname, open_flags::ro).then([] (file f) { + return open_file_dma(fname, open_flags::ro).then([] (file f) { auto bufptr = allocate_aligned_buffer(4096, 4096); auto fut = f.dma_read(0, bufptr.get(), 4096); @@ -438,7 +438,7 @@ SEASTAR_TEST_CASE(datafile_generation_06) { return sst->write_components(*mt).then([mt, sst, s] { auto fname = sstable::filename("tests/sstables/tests-temporary", "ks", "cf", la, 6, big, sstable::component_type::Data); - return engine().open_file_dma(fname, open_flags::ro).then([] (file f) { + return open_file_dma(fname, open_flags::ro).then([] (file f) { auto bufptr = allocate_aligned_buffer(4096, 4096); auto fut = f.dma_read(0, bufptr.get(), 4096); @@ -514,7 +514,7 @@ SEASTAR_TEST_CASE(datafile_generation_07) { return sst->write_components(*mt).then([mt, sst, s] { auto fname = sstable::filename("tests/sstables/tests-temporary", "ks", "cf", la, 7, big, sstable::component_type::Index); - return engine().open_file_dma(fname, open_flags::ro).then([] (file f) { + return open_file_dma(fname, open_flags::ro).then([] (file f) { auto bufptr = allocate_aligned_buffer(4096, 4096); auto fut = f.dma_read(0, bufptr.get(), 4096); @@ -571,7 +571,7 @@ SEASTAR_TEST_CASE(datafile_generation_08) { return sst->write_components(*mt).then([mt, sst, s] { auto fname = sstable::filename("tests/sstables/tests-temporary", "ks", "cf", la, 8, big, sstable::component_type::Summary); - return engine().open_file_dma(fname, open_flags::ro).then([] (file f) { + return open_file_dma(fname, open_flags::ro).then([] (file f) { auto bufptr = allocate_aligned_buffer(4096, 4096); auto fut = f.dma_read(0, bufptr.get(), 4096); @@ -680,7 +680,7 @@ SEASTAR_TEST_CASE(datafile_generation_10) { return sst->write_components(*mt).then([mt, sst, s] { auto fname = sstable::filename("tests/sstables/tests-temporary", "ks", "cf", la, 10, big, sstable::component_type::Data); - return engine().open_file_dma(fname, open_flags::ro).then([] (file f) { + return open_file_dma(fname, open_flags::ro).then([] (file f) { auto bufptr = allocate_aligned_buffer(4096, 4096); auto fut = f.dma_read(0, bufptr.get(), 4096); @@ -691,7 +691,7 @@ SEASTAR_TEST_CASE(datafile_generation_10) { f.close().finally([f]{}); auto fname = sstable::filename("tests/sstables/tests-temporary", "ks", "cf", la, 10, big, sstable::component_type::CRC); - return engine().open_file_dma(fname, open_flags::ro).then([adler] (file f) { + return open_file_dma(fname, open_flags::ro).then([adler] (file f) { auto bufptr = allocate_aligned_buffer(4096, 4096); auto fut = f.dma_read(0, bufptr.get(), 4096); @@ -713,7 +713,7 @@ SEASTAR_TEST_CASE(datafile_generation_10) { }); }).then([adler] { auto fname = sstable::filename("tests/sstables/tests-temporary", "ks", "cf", la, 10, big, sstable::component_type::Digest); - return engine().open_file_dma(fname, open_flags::ro).then([adler] (file f) { + return open_file_dma(fname, open_flags::ro).then([adler] (file f) { auto bufptr = allocate_aligned_buffer(4096, 4096); auto fut = f.dma_read(0, bufptr.get(), 4096); @@ -1456,7 +1456,7 @@ SEASTAR_TEST_CASE(datafile_generation_40) { return sst->write_components(*mt).then([mt, sst, s] { auto fname = sstable::filename("tests/sstables/tests-temporary", "ks", "cf", la, 40, big, sstable::component_type::Data); - return engine().open_file_dma(fname, open_flags::ro).then([] (file f) { + return open_file_dma(fname, open_flags::ro).then([] (file f) { auto bufptr = allocate_aligned_buffer(4096, 4096); auto fut = f.dma_read(0, bufptr.get(), 4096); diff --git a/tests/sstable_test.cc b/tests/sstable_test.cc index c9bebb2c96..7cf2fe9f61 100644 --- a/tests/sstable_test.cc +++ b/tests/sstable_test.cc @@ -187,7 +187,7 @@ static future<> write_sst_info(sstring dir, unsigned long generation) { using bufptr_t = std::unique_ptr; static future> read_file(sstring file_path) { - return engine().open_file_dma(file_path, open_flags::rw).then([] (file f) { + return open_file_dma(file_path, open_flags::rw).then([] (file f) { return f.size().then([f] (auto size) mutable { auto aligned_size = align_up(size, 512UL); auto buf = allocate_aligned_buffer(aligned_size, 512UL); @@ -803,7 +803,7 @@ SEASTAR_TEST_CASE(wrong_range) { static future<> test_sstable_exists(sstring dir, unsigned long generation, bool exists) { auto file_path = sstable::filename(dir, "ks", "cf", la, generation, big, sstable::component_type::Data); - return engine().open_file_dma(file_path, open_flags::ro).then_wrapped([exists] (future f) { + return open_file_dma(file_path, open_flags::ro).then_wrapped([exists] (future f) { if (exists) { BOOST_CHECK_NO_THROW(f.get0()); } else {