Thrill
0.1
|
Base for UNIX file system implementations.
Definition at line 32 of file ufs_file_base.hpp.
#include <ufs_file_base.hpp>
Public Member Functions | |
~ufs_file_base () | |
void | close_remove () final |
close and remove file More... | |
const char * | io_type () const override |
bool | is_device () const |
return true if file is special device node More... | |
void | lock () final |
Locks file for reading and writing (acquires a lock in the file system). More... | |
void | set_size (offset_type newsize) final |
offset_type | size () final |
void | unlink () |
unlink file without closing it. More... | |
Public Member Functions inherited from file | |
file (unsigned int device_id=DEFAULT_DEVICE_ID, file_stats *file_stats=nullptr) | |
Construct a new file, usually called by a subclass. More... | |
file (const file &)=delete | |
non-copyable: delete copy-constructor More... | |
file (file &&)=default | |
move-constructor: default More... | |
virtual | ~file () |
void | add_request_ref () |
increment referenced requests More... | |
virtual request_ptr | aread (void *buffer, offset_type pos, size_type bytes, const completion_handler &on_complete=completion_handler())=0 |
virtual request_ptr | awrite (void *buffer, offset_type pos, size_type bytes, const completion_handler &on_complete=completion_handler())=0 |
void | delete_request_ref () |
decrement referenced requests More... | |
virtual void | discard (offset_type offset, offset_type size) |
virtual void | export_files (offset_type offset, offset_type length, std::string prefix) |
virtual int | get_allocator_id () const =0 |
Returns the file's parallel disk block allocator number. More... | |
unsigned int | get_device_id () const |
Returns the file's physical device id. More... | |
file_stats * | get_file_stats () const |
virtual int | get_queue_id () const =0 |
size_t | get_request_nref () |
return number of referenced requests More... | |
bool | need_alignment () const |
Returns need_alignment_. More... | |
file & | operator= (const file &)=delete |
non-copyable: delete assignment operator More... | |
file & | operator= (file &&)=default |
move-assignment operator: default More... | |
virtual void | serve (void *buffer, offset_type offset, size_type bytes, request::read_or_write op)=0 |
Public Member Functions inherited from ReferenceCounter | |
ReferenceCounter () noexcept | |
new objects have zero reference count More... | |
ReferenceCounter (const ReferenceCounter &) noexcept | |
coping still creates a new object with zero reference count More... | |
~ReferenceCounter () | |
bool | dec_reference () const noexcept |
Call whenever resetting (i.e. More... | |
void | inc_reference () const noexcept |
Call whenever setting a pointer to the object. More... | |
ReferenceCounter & | operator= (const ReferenceCounter &) noexcept |
assignment operator, leaves pointers unchanged More... | |
size_t | reference_count () const noexcept |
Return the number of references to this object (for debugging) More... | |
bool | unique () const noexcept |
Test if the ReferenceCounter is referenced by only one CountingPtr. More... | |
Protected Member Functions | |
ufs_file_base (const std::string &filename, int mode) | |
void | _after_open () |
void | _set_size (offset_type newsize) |
offset_type | _size () |
void | close () |
Protected Attributes | |
std::mutex | fd_mutex_ |
int | file_des_ |
const std::string | filename_ |
bool | is_device_ |
is special device node More... | |
int | mode_ |
Protected Attributes inherited from file | |
unsigned int | device_id_ |
file_stats * | file_stats_ |
bool | need_alignment_ = false |
Flag whether read/write operations REQUIRE alignment. More... | |
tlx::reference_counter | request_ref_ |
count the number of requests referencing this file More... | |
Additional Inherited Members | |
Public Types inherited from file | |
using | offset_type = request::offset_type |
the offset of a request, also the size of the file More... | |
enum | open_mode { RDONLY = 1, WRONLY = 2, RDWR = 4, CREAT = 8, DIRECT = 16, TRUNC = 32, SYNC = 64, NO_LOCK = 128, REQUIRE_DIRECT = 256 } |
using | size_type = request::size_type |
the size of a request More... | |
Static Public Member Functions inherited from file | |
static int | unlink (const char *path) |
unlink path from filesystem More... | |
static int | truncate (const char *path, external_size_type length) |
Static Public Attributes inherited from file | |
static const unsigned int | DEFAULT_DEVICE_ID = std::numeric_limits<unsigned int>::max() |
static const int | DEFAULT_LINUXAIO_QUEUE = -2 |
static const int | DEFAULT_QUEUE = -1 |
static const int | NO_ALLOCATOR = -1 |
|
protected |
Definition at line 33 of file ufs_file_base.cpp.
References ufs_file_base::_after_open(), file::CREAT, file::DIRECT, ufs_file_base::file_des_, ufs_file_base::filename_, FOXXLL_THROW_ERRNO, file::need_alignment_, O_BINARY, O_DIRECT, O_DSYNC, O_RSYNC, O_SYNC, file::RDONLY, file::RDWR, file::REQUIRE_DIRECT, file::SYNC, TLX_LOG1, file::TRUNC, and file::WRONLY.
~ufs_file_base | ( | ) |
Definition at line 130 of file ufs_file_base.cpp.
References ufs_file_base::close().
|
protected |
Definition at line 135 of file ufs_file_base.cpp.
References file::DIRECT, ufs_file_base::file_des_, ufs_file_base::filename_, FOXXLL_THROW_ERRNO_NE_0, ufs_file_base::is_device_, ufs_file_base::lock(), ufs_file_base::mode_, file::NO_LOCK, file::REQUIRE_DIRECT, S_ISBLK, and TLX_LOG1.
Referenced by ufs_file_base::ufs_file_base().
|
protected |
Definition at line 237 of file ufs_file_base.cpp.
References ufs_file_base::_size(), ufs_file_base::file_des_, ufs_file_base::filename_, FOXXLL_THROW_ERRNO_NE_0, FOXXLL_THROW_IF, ufs_file_base::is_device_, ufs_file_base::mode_, and file::RDONLY.
Referenced by ufs_file_base::set_size().
|
protected |
Definition at line 211 of file ufs_file_base.cpp.
References ufs_file_base::file_des_, ufs_file_base::filename_, and FOXXLL_THROW_ERRNO.
Referenced by ufs_file_base::_set_size(), syscall_file::serve(), and ufs_file_base::size().
|
protected |
Definition at line 182 of file ufs_file_base.cpp.
References ufs_file_base::fd_mutex_, ufs_file_base::file_des_, and FOXXLL_THROW_ERRNO.
Referenced by ufs_file_base::close_remove(), and ufs_file_base::~ufs_file_base().
|
finalvirtual |
close and remove file
Reimplemented from file.
Definition at line 283 of file ufs_file_base.cpp.
References ufs_file_base::close(), ufs_file_base::filename_, ufs_file_base::is_device_, and TLX_LOG1.
|
overridevirtual |
Identifies the type of I/O implementation.
Implements file.
Definition at line 28 of file ufs_file_base.cpp.
bool is_device | ( | ) | const |
return true if file is special device node
Definition at line 310 of file ufs_file_base.cpp.
References ufs_file_base::is_device_.
Referenced by foxxll::create_file().
|
finalvirtual |
Locks file for reading and writing (acquires a lock in the file system).
Implements file.
Definition at line 195 of file ufs_file_base.cpp.
References ufs_file_base::fd_mutex_, ufs_file_base::file_des_, ufs_file_base::filename_, FOXXLL_THROW_ERRNO, ufs_file_base::mode_, and file::RDONLY.
Referenced by ufs_file_base::_after_open(), and foxxll::create_file().
|
finalvirtual |
Changes the size of the file.
newsize | new file size |
Implements file.
Definition at line 231 of file ufs_file_base.cpp.
References ufs_file_base::_set_size(), and ufs_file_base::fd_mutex_.
|
finalvirtual |
Returns size of the file.
Implements file.
Definition at line 225 of file ufs_file_base.cpp.
References ufs_file_base::_size(), and ufs_file_base::fd_mutex_.
Referenced by foxxll::create_file().
void unlink | ( | ) |
unlink file without closing it.
Definition at line 298 of file ufs_file_base.cpp.
References ufs_file_base::file_des_, ufs_file_base::filename_, FOXXLL_THROW_ERRNO, ufs_file_base::is_device_, and TLX_LOG1.
Referenced by foxxll::create_file().
|
protected |
Definition at line 35 of file ufs_file_base.hpp.
Referenced by ufs_file_base::close(), ufs_file_base::lock(), syscall_file::serve(), ufs_file_base::set_size(), and ufs_file_base::size().
|
protected |
Definition at line 36 of file ufs_file_base.hpp.
Referenced by ufs_file_base::_after_open(), ufs_file_base::_set_size(), ufs_file_base::_size(), ufs_file_base::close(), ufs_file_base::lock(), syscall_file::serve(), ufs_file_base::ufs_file_base(), and ufs_file_base::unlink().
|
protected |
Definition at line 38 of file ufs_file_base.hpp.
Referenced by ufs_file_base::_after_open(), ufs_file_base::_set_size(), ufs_file_base::_size(), ufs_file_base::close_remove(), ufs_file_base::lock(), syscall_file::serve(), ufs_file_base::ufs_file_base(), and ufs_file_base::unlink().
|
protected |
is special device node
Definition at line 39 of file ufs_file_base.hpp.
Referenced by ufs_file_base::_after_open(), ufs_file_base::_set_size(), ufs_file_base::close_remove(), ufs_file_base::is_device(), and ufs_file_base::unlink().
|
protected |
Definition at line 37 of file ufs_file_base.hpp.
Referenced by ufs_file_base::_after_open(), ufs_file_base::_set_size(), and ufs_file_base::lock().