Thrill
0.1
|
Defines interface of file.
It is a base class for different implementations that might base on various file systems or even remote storage interfaces
#include <file.hpp>
Public Types | |
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... | |
Public Member Functions | |
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 |
virtual void | close_remove () |
close and remove file More... | |
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... | |
virtual const char * | io_type () const =0 |
virtual void | lock ()=0 |
Locks file for reading and writing (acquires a lock in the file system). 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 |
virtual void | set_size (offset_type newsize)=0 |
virtual offset_type | size ()=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... | |
Static Public Member Functions | |
Static Functions for Platform Abstraction | |
static int | unlink (const char *path) |
unlink path from filesystem More... | |
static int | truncate (const char *path, external_size_type length) |
Static Public Attributes | |
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 Attributes | |
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... | |
using offset_type = request::offset_type |
using size_type = request::size_type |
enum open_mode |
Definition of acceptable file open modes. Various open modes in a file system must be converted to this set of acceptable modes
|
inlineexplicit |
Construct a new file, usually called by a subclass.
Definition at line 95 of file file.hpp.
References file::aread(), file::awrite(), bytes, file::get_allocator_id(), file::get_queue_id(), file::lock(), file::operator=(), file::serve(), file::set_size(), and file::size().
|
inlinevirtual |
Definition at line 176 of file file.hpp.
References file::get_request_nref(), file::io_type(), and TLX_LOG1.
|
inline |
increment referenced requests
Definition at line 223 of file file.hpp.
References ReferenceCounter::inc_reference().
Referenced by request::request().
|
pure virtual |
Schedules an asynchronous read request to the file.
buffer | pointer to memory buffer to read into |
pos | file position to start read from |
bytes | number of bytes to transfer |
on_complete | I/O completion handler |
request_ptr
request object, which can be used to track the status of the operation Implemented in disk_queued_file.
Referenced by file::file(), BlockPool::PinBlock(), BID< raw_size >::read(), BID< 0 >::read(), and typed_block< RawSize, Type, NRef, MetaInfoType >::read().
|
pure virtual |
Schedules an asynchronous write request to the file.
buffer | pointer to memory buffer to write from |
pos | starting file position to write |
bytes | number of bytes to transfer |
on_complete | I/O completion handler |
request_ptr
request object, which can be used to track the status of the operation Implemented in disk_queued_file.
Referenced by BlockPool::EvictBlockLRU(), file::file(), BID< raw_size >::write(), BID< 0 >::write(), and typed_block< RawSize, Type, NRef, MetaInfoType >::write().
|
inlinevirtual |
|
inline |
decrement referenced requests
Definition at line 229 of file file.hpp.
References ReferenceCounter::dec_reference().
Referenced by request_with_state::cancel(), and request::release_file_reference().
|
inlinevirtual |
Discard a region of the file (mark it unused). Some specialized file types may need to know freed regions
Reimplemented in memory_file.
Definition at line 159 of file file.hpp.
References tlx::unused().
|
inlinevirtual |
Definition at line 165 of file file.hpp.
References tlx::unused().
|
pure virtual |
Returns the file's parallel disk block allocator number.
Implemented in disk_queued_file.
Referenced by file::file(), BID< raw_size >::is_managed(), BID< 0 >::is_managed(), and serving_request::serve().
|
inline |
Returns the file's physical device id.
Definition at line 207 of file file.hpp.
References file::device_id_.
|
inline |
Definition at line 212 of file file.hpp.
References file::file_stats_.
|
pure virtual |
Returns the identifier of the file's queue number.
Implemented in disk_queued_file.
Referenced by request_with_state::cancel(), file::file(), and disk_queues::make_queue().
|
inline |
return number of referenced requests
Definition at line 235 of file file.hpp.
References ReferenceCounter::reference_count(), file::truncate(), and file::unlink().
Referenced by file::~file().
|
pure virtual |
Identifies the type of I/O implementation.
Implemented in fileperblock_file< base_file_type >, memory_file, syscall_file, and ufs_file_base.
Referenced by request::check_nref_failed(), serving_request::io_type(), request::io_type(), and file::~file().
|
pure virtual |
Locks file for reading and writing (acquires a lock in the file system).
Implemented in fileperblock_file< base_file_type >, memory_file, and ufs_file_base.
Referenced by file::file().
|
inline |
Returns need_alignment_.
Definition at line 204 of file file.hpp.
References file::need_alignment_.
Referenced by serving_request::serving_request().
non-copyable: delete assignment operator
Referenced by file::file().
|
pure virtual |
Implemented in syscall_file, and memory_file.
Referenced by file::file(), and serving_request::serve().
|
pure virtual |
Changes the size of the file.
newsize | new file size |
Implemented in memory_file, and ufs_file_base.
Referenced by file::file(), disk_block_allocator::grow_file(), and disk_block_allocator::~disk_block_allocator().
|
pure virtual |
Returns size of the file.
Implemented in fileperblock_file< base_file_type >, memory_file, and ufs_file_base.
Referenced by file::file().
|
static |
truncate a path to given length. Use this only if you dont have a fileio-specific object, which provides truncate().
Referenced by fileperblock_file< base_file_type >::discard(), fileperblock_file< base_file_type >::export_files(), and file::get_request_nref().
|
static |
unlink path from filesystem
Definition at line 18 of file file.cpp.
Referenced by file::get_request_nref().
|
static |
Definition at line 92 of file file.hpp.
Referenced by foxxll::create_file(), disk_config::fileio_string(), foxxll::async_schedule_local::get_disk(), disk_config::parse_line(), and fileperblock_file< base_file_type >::serve().
|
static |
Definition at line 90 of file file.hpp.
Referenced by foxxll::create_file(), and disk_config::fileio_string().
|
static |
Definition at line 89 of file file.hpp.
Referenced by block_manager::block_manager(), disk_config::fileio_string(), and disk_config::parse_line().
|
protected |
The file's physical device id (e.g. used for prefetching sequence calculation)
Definition at line 196 of file file.hpp.
Referenced by file::get_device_id().
|
protected |
pointer to file's stats inside of iostats. Because the stats can live longer than the file, the iostats keeps ownership.
Definition at line 200 of file file.hpp.
Referenced by file::get_file_stats(), memory_file::serve(), syscall_file::serve(), and fileperblock_file< base_file_type >::serve().
|
protected |
Flag whether read/write operations REQUIRE alignment.
Definition at line 192 of file file.hpp.
Referenced by file::need_alignment(), and ufs_file_base::ufs_file_base().
|
static |
Definition at line 91 of file file.hpp.
Referenced by BID< raw_size >::is_managed(), BID< 0 >::is_managed(), and fileperblock_file< base_file_type >::serve().
|
protected |