Skip to content

Commit

Permalink
Merge pull request #23789 from ukernel/luminous-mds-export-size
Browse files Browse the repository at this point in the history
luminous: mds: optimize the way how max export size is enforced
  • Loading branch information
ukernel committed Sep 19, 2018
2 parents 5ae7828 + 07b3a64 commit fc9cc68
Show file tree
Hide file tree
Showing 12 changed files with 504 additions and 213 deletions.
2 changes: 1 addition & 1 deletion src/common/options.cc
Expand Up @@ -6275,7 +6275,7 @@ std::vector<Option> get_mds_options() {
.set_description(""),

Option("mds_max_export_size", Option::TYPE_UINT, Option::LEVEL_DEV)
.set_default(1_G)
.set_default(20_M)
.set_description(""),

Option("mds_kill_export_at", Option::TYPE_INT, Option::LEVEL_DEV)
Expand Down
17 changes: 17 additions & 0 deletions src/mds/CDir.cc
Expand Up @@ -2920,6 +2920,23 @@ pair<bool,bool> CDir::is_freezing_or_frozen_tree() const
return make_pair(freezing, frozen);
}

CDir *CDir::get_freezing_tree_root()
{
if (num_freezing_trees == 0)
return nullptr;
CDir *dir = this;
while (true) {
if (dir->is_freezing_tree_root())
return dir;
if (dir->is_subtree_root())
return nullptr;
if (dir->inode->parent)
dir = dir->inode->parent->dir;
else
return nullptr;
}
}

CDir *CDir::get_frozen_tree_root()
{
assert(is_frozen());
Expand Down
5 changes: 2 additions & 3 deletions src/mds/CDir.h
Expand Up @@ -729,6 +729,7 @@ class CDir : public MDSCacheObject, public Counter<CDir> {
}
bool is_freezing_tree_root() const { return state & STATE_FREEZINGTREE; }
bool is_freezing_dir() const { return state & STATE_FREEZINGDIR; }
CDir *get_freezing_tree_root();

bool is_frozen() const override { return is_frozen_dir() || is_frozen_tree(); }
bool is_frozen_tree() const {
Expand All @@ -738,6 +739,7 @@ class CDir : public MDSCacheObject, public Counter<CDir> {
}
bool is_frozen_tree_root() const { return state & STATE_FROZENTREE; }
bool is_frozen_dir() const { return state & STATE_FROZENDIR; }
CDir *get_frozen_tree_root();

bool is_freezeable(bool freezing=false) const {
// no nested auth pins.
Expand All @@ -761,9 +763,6 @@ class CDir : public MDSCacheObject, public Counter<CDir> {
return true;
}

CDir *get_frozen_tree_root();


ostream& print_db_line_prefix(ostream& out) override;
void print(ostream& out) override;
void dump(Formatter *f) const;
Expand Down
25 changes: 0 additions & 25 deletions src/mds/CInode.cc
Expand Up @@ -604,31 +604,6 @@ CDir *CInode::get_approx_dirfrag(frag_t fg)
return NULL;
}

void CInode::get_dirfrags(std::list<CDir*>& ls)
{
// all dirfrags
for (const auto &p : dirfrags) {
ls.push_back(p.second);
}
}
void CInode::get_nested_dirfrags(list<CDir*>& ls)
{
// dirfrags in same subtree
for (const auto &p : dirfrags) {
if (!p.second->is_subtree_root())
ls.push_back(p.second);
}
}
void CInode::get_subtree_dirfrags(list<CDir*>& ls)
{
// dirfrags that are roots of new subtrees
for (const auto &p : dirfrags) {
if (p.second->is_subtree_root())
ls.push_back(p.second);
}
}


CDir *CInode::get_or_open_dirfrag(MDCache *mdcache, frag_t fg)
{
assert(is_dir());
Expand Down
29 changes: 26 additions & 3 deletions src/mds/CInode.h
Expand Up @@ -524,9 +524,32 @@ class CInode : public MDSCacheObject, public InodeStoreBase, public Counter<CIno
}
bool get_dirfrags_under(frag_t fg, std::list<CDir*>& ls);
CDir* get_approx_dirfrag(frag_t fg);
void get_dirfrags(std::list<CDir*>& ls);
void get_nested_dirfrags(std::list<CDir*>& ls);
void get_subtree_dirfrags(std::list<CDir*>& ls);

template<typename Container>
void get_dirfrags(Container& ls) const {
// all dirfrags
for (const auto &p : dirfrags)
ls.push_back(p.second);
}
template<typename Container>
void get_nested_dirfrags(Container& ls) const {
// dirfrags in same subtree
for (const auto &p : dirfrags) {
typename Container::value_type dir = p.second;
if (!dir->is_subtree_root())
ls.push_back(dir);
}
}
template<typename Container>
void get_subtree_dirfrags(Container& ls) {
// dirfrags that are roots of new subtrees
for (const auto &p : dirfrags) {
typename Container::value_type dir = p.second;
if (dir->is_subtree_root())
ls.push_back(dir);
}
}

CDir *get_or_open_dirfrag(MDCache *mdcache, frag_t fg);
CDir *add_dirfrag(CDir *dir);
void close_dirfrag(frag_t fg);
Expand Down
1 change: 1 addition & 0 deletions src/mds/MDSDaemon.cc
Expand Up @@ -374,6 +374,7 @@ const char** MDSDaemon::get_tracked_conf_keys() const
"mds_max_purge_ops_per_pg",
"mds_max_purge_files",
// Migrator
"mds_max_export_size",
"mds_inject_migrator_session_race",
"mds_inject_migrator_message_loss",
"host",
Expand Down
4 changes: 4 additions & 0 deletions src/mds/MDSRank.h
Expand Up @@ -296,6 +296,10 @@ class MDSRank {
finished_queue.push_back(c);
progress_thread.signal();
}
void queue_waiter_front(MDSInternalContextBase *c) {
finished_queue.push_back(c);
progress_thread.signal();
}
void queue_waiters(std::list<MDSInternalContextBase*>& ls) {
finished_queue.splice( finished_queue.end(), ls );
progress_thread.signal();
Expand Down

0 comments on commit fc9cc68

Please sign in to comment.