Skip to content

Commit

Permalink
mds: trim empty non-auth dirfrags
Browse files Browse the repository at this point in the history
Fragmenting a non-auth dirfrag results several smaller dirfrags. Some
of the resulting dirfrags can be empty, which are not used to connected
to auth subtree.

Signed-off-by: Yan, Zheng <[email protected]>
  • Loading branch information
Yan, Zheng committed Mar 28, 2014
1 parent 3c6c712 commit 598c5f1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/mds/MDCache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3460,9 +3460,14 @@ void MDCache::recalc_auth_bits()
dfq.pop_front();

// dir
if (auth)
if (auth) {
dir->state_set(CDir::STATE_AUTH);
else {
} else {
// close empty non-auth dirfrag
if (!dir->is_subtree_root() && dir->get_num_any() == 0) {
dir->inode->close_dirfrag(dir->get_frag());
continue;
}
dir->state_set(CDir::STATE_REJOINING);
dir->state_clear(CDir::STATE_AUTH);
dir->state_clear(CDir::STATE_COMPLETE);
Expand Down Expand Up @@ -6644,6 +6649,9 @@ void MDCache::trim_non_auth()
dir->remove_dentry(dn);
// adjust the dir state
dir->state_clear(CDir::STATE_COMPLETE); // dir incomplete!
// close empty non-auth dirfrag
if (!dir->is_subtree_root() && dir->get_num_any() == 0)
dir->inode->close_dirfrag(dir->get_frag());
}
}

Expand Down
12 changes: 12 additions & 0 deletions src/mds/journal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,18 @@ void EMetaBlob::fullbit::update_inode(MDS *mds, CInode *in)
<< dirfragtree << " on " << *in << dendl;
in->dirfragtree = dirfragtree;
in->force_dirfrags();
if (in->has_dirfrags() && in->authority() == CDIR_AUTH_UNDEF) {
list<CDir*> ls;
in->get_nested_dirfrags(ls);
for (list<CDir*>::iterator p = ls.begin(); p != ls.end(); ++p) {
CDir *dir = *p;
if (dir->get_num_any() == 0 &&
mds->mdcache->can_trim_non_auth_dirfrag(dir)) {
dout(10) << " closing empty non-auth dirfrag " << *dir << dendl;
in->close_dirfrag(dir->get_frag());
}
}
}
}

/*
Expand Down

0 comments on commit 598c5f1

Please sign in to comment.