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 <zheng.z.yan@intel.com>
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);
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());
}
}
<< 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());
+ }
+ }
+ }
}
/*