auto cur = it++;
CInode *in = *cur;
ceph_assert(in->is_dir());
+
+ in->check_pin_policy();
mds_rank_t export_pin = in->get_export_pin(false);
if (export_pin >= mds->mdsmap->get_max_mds()) {
- dout(20) << " delay export pin on " << *in << dendl;
+ dout(20) << " delay export_pin=" << export_pin << " on " << *in << dendl;
in->state_clear(CInode::STATE_QUEUEDEXPORTPIN);
q.erase(cur);
in->state_set(CInode::STATE_DELAYEDEXPORTPIN);
mds->mdcache->export_pin_delayed_queue.insert(in);
continue;
+ } else {
+ dout(20) << " executing export_pin=" << export_pin << " on " << *in << dendl;
}
bool remove = true;
- auto&& dfls = in->get_dirfrags();
- for (auto dir : dfls) {
+ for (auto&& dir : in->get_dirfrags()) {
if (!dir->is_auth())
continue;
mds->mdcache->try_subtree_merge(dir);
}
} else if (export_pin == mds->get_nodeid()) {
- if (dir->state_test(CDir::STATE_CREATING) ||
- dir->is_frozen() || dir->is_freezing()) {
+ if (dir->state_test(CDir::STATE_AUXSUBTREE)) {
+ ceph_assert(dir->is_subtree_root());
+ } else if (dir->state_test(CDir::STATE_CREATING) ||
+ dir->is_frozen() || dir->is_freezing()) {
// try again later
remove = false;
continue;
- }
- if (!dir->is_subtree_root()) {
+ } else if (!dir->is_subtree_root()) {
dir->state_set(CDir::STATE_AUXSUBTREE);
mds->mdcache->adjust_subtree_auth(dir, mds->get_nodeid());
dout(10) << " create aux subtree on " << *dir << dendl;
- } else if (!dir->state_test(CDir::STATE_AUXSUBTREE)) {
+ } else {
dout(10) << " set auxsubtree bit on " << *dir << dendl;
dir->state_set(CDir::STATE_AUXSUBTREE);
}
} else {
- mds->mdcache->migrator->export_dir(dir, export_pin);
+ /* Only export a directory if it's non-empty. An empty directory will
+ * be sent back by the importer.
+ */
+ if (dir->get_num_head_items() > 0) {
+ mds->mdcache->migrator->export_dir(dir, export_pin);
+ }
remove = false;
}
}
dendl;
}
- if (export_pin >= 0 && export_pin < mds->mdsmap->get_max_mds()
- && export_pin != mds->get_nodeid()) {
- mds->mdcache->migrator->export_dir(cd, export_pin);
+ if (export_pin >= 0 && export_pin < mds->mdsmap->get_max_mds()) {
+ if (export_pin == mds->get_nodeid()) {
+ cd->get_inode()->check_pin_policy();
+ } else {
+ mds->mdcache->migrator->export_dir(cd, export_pin);
+ }
}
}
}