dnl->inode = 0;
}
+void CDentry::push_projected_linkage()
+{
+ _project_linkage();
+
+ if (is_auth()) {
+ CInode *diri = dir->inode;
+ if (diri->is_stray())
+ diri->mdcache->notify_stray_removed();
+ }
+}
+
+
void CDentry::push_projected_linkage(CInode *inode)
{
// dirty rstat tracking is in the projected plane
if (dirty_rstat)
inode->mark_dirty_rstat();
+
+ if (is_auth()) {
+ CInode *diri = dir->inode;
+ if (diri->is_stray())
+ diri->mdcache->notify_stray_created();
+ }
}
CDentry::linkage_t *CDentry::pop_projected_linkage()
projected.push_back(linkage_t());
return &projected.back();
}
- void push_projected_linkage() {
- _project_linkage();
- }
+ void push_projected_linkage();
void push_projected_linkage(inodeno_t ino, char d_type) {
linkage_t *p = _project_linkage();
p->remote_ino = ino;
}
// open or create stray
+ uint64_t num_strays = 0;
for (int i = 0; i < NUM_STRAY; ++i) {
stringstream name;
name << "stray" << i;
dir->fetch(new C_MDS_RetryOpenRoot(this));
return;
}
+
+ if (dir->get_frag_size() > 0)
+ num_strays += dir->get_frag_size();
}
}
+ stray_manager.set_num_strays(num_strays);
+
// okay!
dout(10) << "populate_mydir done" << dendl;
assert(!open);
assert(straydn->get_projected_linkage()->is_null());
}
- // Notify even if a null dentry already existed, because
- // StrayManager counts the number of stray inodes, not the
- // number of dentries in the directory.
- stray_manager.notify_stray_created();
-
straydn->state_set(CDentry::STATE_STRAY);
return straydn;
}
for (CDir::map_t::iterator q = dir->items.begin(); q != dir->items.end(); ++q) {
CDentry *dn = q->second;
dn->state_set(CDentry::STATE_STRAY);
- stray_manager.notify_stray_created();
CDentry::linkage_t *dnl = dn->get_projected_linkage();
if (dnl->is_primary()) {
CInode *in = dnl->get_inode();
stray_manager.set_logger(logger.get());
}
+void MDCache::activate_stray_manager()
+{
+ if (open) {
+ stray_manager.activate();
+ } else {
+ wait_for_open(
+ new MDSInternalContextWrapper(mds,
+ new FunctionContext([this](int r){
+ stray_manager.activate();
+ })
+ )
+ );
+ }
+}
+
/**
* Call this when putting references to an inode/dentry or
* when attempting to trim it.
stray_index = (stray_index+1)%NUM_STRAY;
}
- void activate_stray_manager() {
- stray_manager.activate();
- }
+ void activate_stray_manager();
/**
* Call this when you know that a CDentry is ready to be passed
}
}
- if (srcdn->get_dir()->inode->is_stray() &&
- srcdn->get_dir()->inode->get_stray_owner() == mds->get_nodeid()) {
- // A reintegration event or a migration away from me
- dout(20) << __func__ << ": src dentry was a stray, updating stats" << dendl;
- mdcache->notify_stray_removed();
- }
-
- if (destdn->get_dir()->inode->is_stray() &&
- destdn->get_dir()->inode->get_stray_owner() == mds->get_nodeid()) {
- // A stray migration (to me)
- dout(20) << __func__ << ": dst dentry was a stray, updating stats" << dendl;
- mdcache->notify_stray_created();
- }
-
// src
if (srcdn->is_auth())
srcdn->mark_dirty(mdr->more()->pvmap[srcdn], mdr->ls);
mds->mdlog->submit_entry(le, new C_PurgeStrayLogged(this, dn, pdv,
mds->mdlog->get_current_segment()));
- num_strays--;
logger->set(l_mdc_num_strays, num_strays);
}
}
logger->set(l_mdc_num_strays_delayed, num_strays_delayed);
}
+void StrayManager::set_num_strays(uint64_t num)
+{
+ assert(!started);
+ num_strays = num;
+ logger->set(l_mdc_num_strays, num_strays);
+}
+
void StrayManager::notify_stray_created()
{
num_strays++;
bool eval_stray(CDentry *dn, bool delay=false);
+ void set_num_strays(uint64_t num);
uint64_t get_num_strays() const { return num_strays; }
/**