* seastar f0298e40...4dcd4df5 (29):
> file: provide a default implementation for file_impl::statat
> util: Genralize memory_data_sink
> defer: Replace static_assert() with concept
> treewide: drop the support of fmtlib < 9.0.0
> test: Improve resilience of netsed scheduling fairness test
> Merge 'file: Use query_device_alignment_info in blkdev_alignments ' from Kefu Chai
file: Put alignment helpers in anonymous namespace
file: Use query_device_alignment_info in blkdev_alignments
> Merge 'file: Query physical block size and minimum I/O size' from Kefu Chai
file: Apply physical_block_size override to filesystem files
file: Use designated initializers in xfs_alignments
iotune: Add physical block size detection
disk_params: Add support for physical_block_size overrides from io_properties.yaml
block_device: Query alignment requirements separately for memory and I/O
> Merge 'json: formatter: fix formatting of std:string_view' from Benny Halevy
json: formatter: fix formatting of std:string_view
json: formatter: make sure std::string_view conforms to is_string_like
Fixes #27887
> demos:improve the output of demo_with_io_intent() in file_demo
> test: Add accept() vs accept_abort() socket test
> file: Refine posix_file_impl alignments initialization
> Add file::statat and a corresponding file_stat overload
> cmake: don't compile memcached app for API < 9
> Merge 'Revert to ~old lifetime semantics for lvalues passed to then()-alikes' from Travis Downs
future: adjust lifetime for lvalue continuations
future: fix value class operator()
> pollable_fd: Unfriend everything
> Merge 'file: experimental_list_directory: use buffered generator' from Benny Halevy
file: experimental_list_directory: use buffered generator
file: define list_directory_generator_type
> Merge 'Make datagram API use temporary_buffer<>-s' from Pavel Emelyanov
net: Deprecate datagram::get_data() returning packet
memcache: Fix indentation after previous patch
memcache: Use new datagram::get_buffers() API
dns: Use new datagram::get_buffers() API
tests: Use new datagram::get_buffers() API
demo: Use new datagram::get_buffers() API
udp: Make datagram implementations return span of temporary_buffer-s
> Merge 'Remove callback from timer_set::complete()' from Pavel Emelyanov
reactor: Fix indentation after previous patch
timers: Remove enabling callback from timer_set::complete()
> treewide: avoid 'static sstring' in favor of 'constexpr string_view'
> resource: Hide hwloc from public interface
> Merge 'Fix handle_exception_type for lvalues' from Travis Downs
futures_test: compile-time tests
function_traits: handle reference_wrapper
> posix_data_sink_impl: Assert to guard put UB
> treewide: fix build with `SEASTAR_SSTRING` undefined
> avoid deprecation warnings for json_exception
> `util/variant_utils`: correct type deduction for `seastar::visit`
> net/dns: fixed socket concurrent access
> treewide: add missing headers
> Merge 'Remove posix file helper file_read_state class' from Pavel Emelyanov
file: Remove file_read_state
test: Add a test for posix_file_impl::do_dma_read_bulk()
> membarrier: simplify locking
Adjust scylla to the following changes in scylla:
- file_stat became polymorphic
- needs explicit inference in table::snapshot_exists, table::get_snapshot_details
- file::experimental_list_directory now returns list_directory_generator_type
Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
Closes scylladb/scylladb#27916
151 lines
4.8 KiB
C++
151 lines
4.8 KiB
C++
/*
|
|
* Copyright (C) 2016-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <seastar/core/file.hh>
|
|
#include <seastar/core/seastar.hh>
|
|
#include "utils/disk-error-handler.hh"
|
|
|
|
#include "seastarx.hh"
|
|
|
|
class checked_file_impl : public file_impl {
|
|
public:
|
|
|
|
checked_file_impl(const io_error_handler& error_handler, file f)
|
|
: file_impl(*get_file_impl(f)), _error_handler(error_handler), _file(f) {
|
|
}
|
|
|
|
virtual future<size_t> write_dma(uint64_t pos, const void* buffer, size_t len, io_intent* intent) override {
|
|
return do_io_check(_error_handler, [&] {
|
|
return get_file_impl(_file)->write_dma(pos, buffer, len, intent);
|
|
});
|
|
}
|
|
|
|
virtual future<size_t> write_dma(uint64_t pos, std::vector<iovec> iov, io_intent* intent) override {
|
|
return do_io_check(_error_handler, [&] {
|
|
return get_file_impl(_file)->write_dma(pos, iov, intent);
|
|
});
|
|
}
|
|
|
|
virtual future<size_t> read_dma(uint64_t pos, void* buffer, size_t len, io_intent* intent) override {
|
|
return do_io_check(_error_handler, [&] {
|
|
return get_file_impl(_file)->read_dma(pos, buffer, len, intent);
|
|
});
|
|
}
|
|
|
|
virtual future<size_t> read_dma(uint64_t pos, std::vector<iovec> iov, io_intent* intent) override {
|
|
return do_io_check(_error_handler, [&] {
|
|
return get_file_impl(_file)->read_dma(pos, iov, intent);
|
|
});
|
|
}
|
|
|
|
virtual future<> flush(void) override {
|
|
return do_io_check(_error_handler, [&] {
|
|
return get_file_impl(_file)->flush();
|
|
});
|
|
}
|
|
|
|
virtual future<struct stat> stat(void) override {
|
|
return do_io_check(_error_handler, [&] {
|
|
return get_file_impl(_file)->stat();
|
|
});
|
|
}
|
|
|
|
virtual future<> truncate(uint64_t length) override {
|
|
return do_io_check(_error_handler, [&] {
|
|
return get_file_impl(_file)->truncate(length);
|
|
});
|
|
}
|
|
|
|
virtual future<> discard(uint64_t offset, uint64_t length) override {
|
|
return do_io_check(_error_handler, [&] {
|
|
return get_file_impl(_file)->discard(offset, length);
|
|
});
|
|
}
|
|
|
|
virtual future<> allocate(uint64_t position, uint64_t length) override {
|
|
return do_io_check(_error_handler, [&] {
|
|
return get_file_impl(_file)->allocate(position, length);
|
|
});
|
|
}
|
|
|
|
virtual future<uint64_t> size(void) override {
|
|
return do_io_check(_error_handler, [&] {
|
|
return get_file_impl(_file)->size();
|
|
});
|
|
}
|
|
|
|
virtual future<> close() override {
|
|
return do_io_check(_error_handler, [&] {
|
|
return get_file_impl(_file)->close();
|
|
});
|
|
}
|
|
|
|
// returns a handle for plain file, so make_checked_file() should be called
|
|
// on file returned by handle.
|
|
virtual std::unique_ptr<seastar::file_handle_impl> dup() override {
|
|
return get_file_impl(_file)->dup();
|
|
}
|
|
|
|
virtual subscription<directory_entry> list_directory(std::function<future<> (directory_entry de)> next) override {
|
|
return do_io_check(_error_handler, [&] {
|
|
return get_file_impl(_file)->list_directory(next);
|
|
});
|
|
}
|
|
|
|
virtual future<temporary_buffer<uint8_t>> dma_read_bulk(uint64_t offset, size_t range_size, io_intent* intent) override {
|
|
return do_io_check(_error_handler, [&] {
|
|
return get_file_impl(_file)->dma_read_bulk(offset, range_size, intent);
|
|
});
|
|
}
|
|
|
|
virtual list_directory_generator_type experimental_list_directory() override {
|
|
try {
|
|
auto gen = get_file_impl(_file)->experimental_list_directory();
|
|
while (auto de = co_await gen()) {
|
|
co_yield *de;
|
|
}
|
|
} catch (...) {
|
|
_error_handler(std::current_exception());
|
|
throw;
|
|
}
|
|
}
|
|
private:
|
|
const io_error_handler& _error_handler;
|
|
file _file;
|
|
};
|
|
|
|
inline file make_checked_file(const io_error_handler& error_handler, file f)
|
|
{
|
|
return file(::make_shared<checked_file_impl>(error_handler, f));
|
|
}
|
|
|
|
future<file>
|
|
inline open_checked_file_dma(const io_error_handler& error_handler,
|
|
sstring name, open_flags flags,
|
|
file_open_options options = {})
|
|
{
|
|
return do_io_check(error_handler, [&] {
|
|
return open_file_dma(name, flags, options).then([&] (file f) {
|
|
return make_ready_future<file>(make_checked_file(error_handler, f));
|
|
});
|
|
});
|
|
}
|
|
|
|
future<file>
|
|
inline open_checked_directory(const io_error_handler& error_handler,
|
|
sstring name)
|
|
{
|
|
return do_io_check(error_handler, [&] {
|
|
return open_directory(name).then([&] (file f) {
|
|
return make_ready_future<file>(make_checked_file(error_handler, f));
|
|
});
|
|
});
|
|
}
|