bool exceeded_size_limit;
public:
+ static uint64_t cache_limit_inodes(void) {
+ return g_conf->get_val<int64_t>("mds_cache_size");
+ }
+ static uint64_t cache_limit_memory(void) {
+ return g_conf->get_val<uint64_t>("mds_cache_memory_limit");
+ }
+ static double cache_reservation(void) {
+ return g_conf->get_val<double>("mds_cache_reservation");
+ }
+ static double cache_mid(void) {
+ return g_conf->get_val<double>("mds_cache_mid");
+ }
+ static double cache_health_threshold(void) {
+ return g_conf->get_val<double>("mds_health_cache_threshold");
+ }
+ double cache_toofull_ratio(void) const {
+ uint64_t inode_limit = cache_limit_inodes();
+ double inode_reserve = inode_limit*(1.0-cache_reservation());
+ double memory_reserve = cache_limit_memory()*(1.0-cache_reservation());
+ return fmax(0.0, fmax((cache_size()-memory_reserve)/memory_reserve, inode_limit == 0 ? 0.0 : (CInode::count()-inode_reserve)/inode_reserve));
+ }
+ bool cache_toofull(void) const {
+ return cache_toofull_ratio() > 0.0;
+ }
+ uint64_t cache_size(void) const {
+ return mempool::get_pool(mempool::mds_co::id).allocated_bytes();
+ }
+ bool cache_overfull(void) const {
+ uint64_t inode_limit = cache_limit_inodes();
+ return (inode_limit > 0 && CInode::count() > inode_limit*cache_health_threshold()) || (cache_size() > cache_limit_memory()*cache_health_threshold());
+ }
+
void advance_stray() {
stray_index = (stray_index+1)%NUM_STRAY;
}
CInode *get_root() { return root; }
CInode *get_myin() { return myin; }
- // cache
- void set_cache_size(size_t max) { lru.lru_set_max(max); }
size_t get_cache_size() { return lru.lru_get_size(); }
// trimming
- bool trim(int max=-1, int count=-1); // trim cache
+ bool trim(uint64_t count=0);
+private:
+ void trim_lru(uint64_t count, map<mds_rank_t, MCacheExpire*>& expiremap);
bool trim_dentry(CDentry *dn, map<mds_rank_t, MCacheExpire*>& expiremap);
void trim_dirfrag(CDir *dir, CDir *con,
map<mds_rank_t, MCacheExpire*>& expiremap);
map<mds_rank_t,class MCacheExpire*>& expiremap);
void send_expire_messages(map<mds_rank_t, MCacheExpire*>& expiremap);
void trim_non_auth(); // trim out trimmable non-auth items
+public:
bool trim_non_auth_subtree(CDir *directory);
void standby_trim_segment(LogSegment *ls);
void try_trim_non_auth_subtree(CDir *dir);
int dump_cache(Formatter *f);
int dump_cache(const std::string& dump_root, int depth, Formatter *f);
+ int cache_status(Formatter *f);
+
void dump_resolve_status(Formatter *f) const;
void dump_rejoin_status(Formatter *f) const;