autotier
Automatic Tiering Fuse Filesystem
|
Class to represent each tier in the filesystem. More...
#include <tier.hpp>
Public Member Functions | |
Tier (std::string id, const fs::path &path, const ffd::Quota "a) | |
Construct a new Tier object. More... | |
Tier (Tier &&other) | |
Copy construct a new Tier object. More... | |
~Tier ()=default | |
Destroy the Tier object. More... | |
void | add_file_size (ffd::Bytes size) |
Add size bytes to usage_. More... | |
void | subtract_file_size (ffd::Bytes size) |
Subtract size bytes from usage. More... | |
void | size_delta (ffd::Bytes old_size, ffd::Bytes new_size) |
Subtract old_size then add new_size, locking mutex for thread safety. More... | |
void | add_file_size_sim (ffd::Bytes size) |
Add size bytes to sim_usage_. More... | |
void | subtract_file_size_sim (ffd::Bytes size) |
Subtract size bytes from sim_usage. More... | |
void | quota_percent (double quota_percent) |
Set quota percentage. More... | |
double | quota_percent (void) const |
Get quota percentage. More... | |
ffd::Quota | quota (void) const |
Get quota_. More... | |
bool | full_test (const ffd::Bytes &file_size) const |
returns true if file would make tier overfilled. (usage_ + file.size() > quota_bytes_). More... | |
const fs::path & | path (void) const |
Get path to root of tier. More... | |
const std::string & | id (void) const |
Get user-defined ID of tier. More... | |
void | enqueue_file_ptr (File *fptr) |
Push file pointer into incoming_files_. More... | |
void | transfer_files (int buff_sz, const fs::path &run_path) |
Iterate through incoming_files_ and move each file into the tier. More... | |
bool | move_file (const fs::path &old_path, const fs::path &new_path, int buff_sz, bool *conflicted=nullptr, std::string orig_tier="") const |
Called in transfer_files() to actually copy the file and remove the old one. More... | |
void | usage (ffd::Bytes usage) |
Set tier usage_ in bytes. More... | |
double | usage_percent (void) const |
Return real current usage as percent. More... | |
ffd::Bytes | usage_bytes (void) const |
Return real current usage in bytes. More... | |
void | reset_sim (void) |
Set sim_usage_ to zero. More... | |
ffd::Bytes | capacity (void) const |
Return capacity in bytes. More... | |
Private Member Functions | |
void | copy_ownership_and_perms (const fs::path &old_path, const fs::path &new_path) const |
Copy ownership and permissions from old_path to new_path, called after copying a file to a different tier. More... | |
Private Attributes | |
ffd::Quota | quota_ |
Holds maximum size and percent allotted. | |
ffd::Bytes | usage_ |
Real current bytes used in underlying filesystem. | |
ffd::Bytes | sim_usage_ |
Number of bytes used, used while simulating the tiering of files to determine where to place each file. | |
std::string | id_ |
User-defined friendly name of tier, in square bracket header of tier definition in config file. | |
fs::path | path_ |
Backend path to tier. | |
std::vector< File * > | incoming_files_ |
Queue of files to be placed into the tier, filled during the simulation of tiering and used while actually tiering. | |
std::mutex | usage_mt_ |
Mutex to be used in {add,subtract}_file_size() for FUSE threads. | |
Class to represent each tier in the filesystem.
Tier::Tier | ( | std::string | id, |
const fs::path & | path, | ||
const ffd::Quota & | quota | ||
) |
Construct a new Tier object.
id | User-defined ID of tier from config subsection header |
path | Path to tier in filesystem |
|
inline |
|
default |
Destroy the Tier object.
void Tier::add_file_size | ( | ffd::Bytes | size | ) |
Add size bytes to usage_.
size |
void Tier::add_file_size_sim | ( | ffd::Bytes | size | ) |
Add size bytes to sim_usage_.
size |
ffd::Bytes Tier::capacity | ( | void | ) | const |
Return capacity in bytes.
|
private |
Copy ownership and permissions from old_path to new_path, called after copying a file to a different tier.
old_path | Path to file before moving |
new_path | Path to file after moving |
void Tier::enqueue_file_ptr | ( | File * | fptr | ) |
Push file pointer into incoming_files_.
fptr |
bool Tier::full_test | ( | const ffd::Bytes & | file_size | ) | const |
returns true if file would make tier overfilled. (usage_ + file.size() > quota_bytes_).
file | File to test |
const std::string & Tier::id | ( | void | ) | const |
Get user-defined ID of tier.
bool Tier::move_file | ( | const fs::path & | old_path, |
const fs::path & | new_path, | ||
int | buff_sz, | ||
bool * | conflicted = nullptr , |
||
std::string | orig_tier = "" |
||
) | const |
Called in transfer_files() to actually copy the file and remove the old one.
old_path | |
new_path | |
buff_sz | |
conflicted | |
orig_tier |
const fs::path & Tier::path | ( | void | ) | const |
Get path to root of tier.
ffd::Quota Tier::quota | ( | void | ) | const |
Get quota_.
void Tier::quota_percent | ( | double | quota_percent | ) |
Set quota percentage.
quota_percent |
double Tier::quota_percent | ( | void | ) | const |
Get quota percentage.
void Tier::reset_sim | ( | void | ) |
Set sim_usage_ to zero.
void Tier::size_delta | ( | ffd::Bytes | old_size, |
ffd::Bytes | new_size | ||
) |
Subtract old_size then add new_size, locking mutex for thread safety.
old_size | Subtract this |
new_size | Add this |
void Tier::subtract_file_size | ( | ffd::Bytes | size | ) |
Subtract size bytes from usage.
size |
void Tier::subtract_file_size_sim | ( | ffd::Bytes | size | ) |
Subtract size bytes from sim_usage.
size |
void Tier::transfer_files | ( | int | buff_sz, |
const fs::path & | run_path | ||
) |
Iterate through incoming_files_ and move each file into the tier.
buff_sz | |
run_path |
void Tier::usage | ( | ffd::Bytes | usage | ) |
Set tier usage_ in bytes.
usage |
ffd::Bytes Tier::usage_bytes | ( | void | ) | const |
Return real current usage in bytes.
double Tier::usage_percent | ( | void | ) | const |
Return real current usage as percent.