}
if (state == EXPORT_WARNING) {
// notify bystanders
- export_notify_abort(dir, bounds);
+ export_notify_abort(dir, it->second, bounds);
// process delayed expires
cache->process_delayed_expire(dir);
}
case EXPORT_EXPORTING:
dout(10) << "export state=exporting : reversing, and unfreezing" << dendl;
it->second.state = EXPORT_CANCELLING;
- export_reverse(dir);
+ export_reverse(dir, it->second);
break;
case EXPORT_LOGGINGFINISH:
case IMPORT_PREPPING:
assert(dir);
dout(10) << "import state=prepping : unpinning base+bounds " << *dir << dendl;
- import_reverse_prepping(dir);
+ import_reverse_prepping(dir, q->second);
break;
case IMPORT_PREPPED:
cache->adjust_subtree_auth(dir, q->second.peer);
// notify bystanders ; wait in aborting state
- import_state[df].state = IMPORT_ABORTING;
+ q->second.state = IMPORT_ABORTING;
import_notify_abort(dir, bounds);
assert(g_conf->mds_kill_import_at != 10);
}
void Migrator::export_go(CDir *dir)
{
- assert(export_state.count(dir));
- dout(7) << "export_go " << *dir << " to " << export_state[dir].peer << dendl;
+ auto it = export_state.find(dir);
+ assert(it != export_state.end());
+ dout(7) << "export_go " << *dir << " to " << it->second.peer << dendl;
// first sync log to flush out e.g. any cap imports
- mds->mdlog->wait_for_safe(new C_M_ExportGo(this, dir, export_state[dir].tid));
+ mds->mdlog->wait_for_safe(new C_M_ExportGo(this, dir, it->second.tid));
mds->mdlog->flush();
}
m->put();
}
-void Migrator::export_notify_abort(CDir *dir, set<CDir*>& bounds)
+void Migrator::export_notify_abort(CDir *dir, export_state_t& stat, set<CDir*>& bounds)
{
dout(7) << "export_notify_abort " << *dir << dendl;
- export_state_t& stat = export_state[dir];
assert(stat.state == EXPORT_CANCELLING);
if (stat.notify_ack_waiting.empty()) {
for (set<mds_rank_t>::iterator p = stat.notify_ack_waiting.begin();
p != stat.notify_ack_waiting.end();
++p) {
- MExportDirNotify *notify = new MExportDirNotify(dir->dirfrag(),stat.tid, true,
- pair<int,int>(mds->get_nodeid(),stat.peer),
- pair<int,int>(mds->get_nodeid(),CDIR_AUTH_UNKNOWN));
+ MExportDirNotify *notify = new MExportDirNotify(dir->dirfrag(), stat.tid, true,
+ pair<int,int>(mds->get_nodeid(), stat.peer),
+ pair<int,int>(mds->get_nodeid(), CDIR_AUTH_UNKNOWN));
for (set<CDir*>::iterator i = bounds.begin(); i != bounds.end(); ++i)
notify->get_bounds().push_back((*i)->dirfrag());
mds->send_message_mds(notify, *p);
* that is, we don't know they safely received and logged it, so we reverse our changes
* and go on.
*/
-void Migrator::export_reverse(CDir *dir)
+void Migrator::export_reverse(CDir *dir, export_state_t& stat)
{
dout(7) << "export_reverse " << *dir << dendl;
}
// unpin bounds
- for (const auto &bd : bounds) {
+ for (auto bd : bounds) {
bd->put(CDir::PIN_EXPORTBOUND);
bd->state_clear(CDir::STATE_EXPORTBOUND);
}
// notify bystanders
- export_notify_abort(dir, bounds);
+ export_notify_abort(dir, stat, bounds);
// unfreeze tree, with possible subtree merge.
cache->adjust_subtree_auth(dir, mds->get_nodeid(), mds->get_nodeid());
}
// only start discovering on this message once.
+ import_state_t *p_state;
map<dirfrag_t,import_state_t>::iterator it = import_state.find(df);
if (!m->started) {
assert(it == import_state.end());
m->started = true;
- import_state[df].state = IMPORT_DISCOVERING;
- import_state[df].peer = from;
- import_state[df].tid = m->get_tid();
+ p_state = &import_state[df];
+ p_state->state = IMPORT_DISCOVERING;
+ p_state->peer = from;
+ p_state->tid = m->get_tid();
} else {
// am i retrying after ancient path_traverse results?
if (it == import_state.end() ||
return;
}
assert(it->second.state == IMPORT_DISCOVERING);
+ p_state = &it->second;
}
if (!mds->mdcache->is_open()) {
// yay
dout(7) << "handle_export_discover have " << df << " inode " << *in << dendl;
- import_state[df].state = IMPORT_DISCOVERED;
+ p_state->state = IMPORT_DISCOVERED;
// pin inode in the cache (for now)
assert(in->is_dir());
// reply
dout(7) << " sending export_discover_ack on " << *in << dendl;
- mds->send_message_mds(new MExportDirDiscoverAck(df, m->get_tid()), import_state[df].peer);
+ mds->send_message_mds(new MExportDirDiscoverAck(df, m->get_tid()), p_state->peer);
m->put();
assert (g_conf->mds_kill_import_at != 2);
}
import_state.erase(df);
}
-void Migrator::import_reverse_prepping(CDir *dir)
+void Migrator::import_reverse_prepping(CDir *dir, import_state_t& stat)
{
set<CDir*> bounds;
- cache->map_dirfrag_set(import_state[dir->dirfrag()].bound_ls, bounds);
+ cache->map_dirfrag_set(stat.bound_ls, bounds);
import_remove_pins(dir, bounds);
import_reverse_final(dir);
}
} else if (it->second.state == IMPORT_PREPPING) {
CDir *dir = mds->mdcache->get_dirfrag(df);
assert(dir);
- import_reverse_prepping(dir);
+ import_reverse_prepping(dir, it->second);
} else if (it->second.state == IMPORT_PREPPED) {
CDir *dir = mds->mdcache->get_dirfrag(df);
assert(dir);
}
if (!success)
- import_reverse_prepping(dir);
+ import_reverse_prepping(dir, it->second);
// ok!
dout(7) << " sending export_prep_ack on " << *dir << dendl;