mirror of
https://github.com/ceph/ceph
synced 2025-01-03 01:22:53 +00:00
Merge branch 'wip-mds'
This commit is contained in:
commit
db7c41934b
@ -386,8 +386,10 @@ void CInode::project_past_snaprealm_parent(SnapRealm *newparent)
|
||||
|
||||
if (newparent != oldparent) {
|
||||
snapid_t oldparentseq = oldparent->get_newest_seq();
|
||||
new_snap->past_parents[oldparentseq].ino = oldparent->inode->ino();
|
||||
new_snap->past_parents[oldparentseq].first = new_snap->current_parent_since;
|
||||
if (oldparentseq + 1 > new_snap->current_parent_since) {
|
||||
new_snap->past_parents[oldparentseq].ino = oldparent->inode->ino();
|
||||
new_snap->past_parents[oldparentseq].first = new_snap->current_parent_since;
|
||||
}
|
||||
new_snap->current_parent_since = MAX(oldparentseq, newparent->get_last_created()) + 1;
|
||||
}
|
||||
}
|
||||
|
@ -3132,6 +3132,11 @@ void MDCache::recalc_auth_bits()
|
||||
for (map<CDir*,set<CDir*> >::iterator p = subtrees.begin();
|
||||
p != subtrees.end();
|
||||
++p) {
|
||||
|
||||
CInode *inode = p->first->get_inode();
|
||||
if (inode->is_mdsdir() && inode->ino() != MDS_INO_MDSDIR(mds->get_nodeid()))
|
||||
inode->state_clear(CInode::STATE_AUTH);
|
||||
|
||||
list<CDir*> dfq; // dirfrag queue
|
||||
dfq.push_back(p->first);
|
||||
|
||||
@ -5412,6 +5417,17 @@ bool MDCache::trim(int max)
|
||||
++i)
|
||||
lru.lru_insert_mid(*i);
|
||||
|
||||
// trim non-auth, non-bound subtrees
|
||||
for (map<CDir*, set<CDir*> >::iterator p = subtrees.begin();
|
||||
p != subtrees.end();) {
|
||||
CDir *dir = p->first;
|
||||
p++;
|
||||
if (!dir->is_auth() && !dir->get_inode()->is_auth()) {
|
||||
if (dir->get_num_ref() == 1) // subtree pin
|
||||
trim_dirfrag(dir, 0, expiremap);
|
||||
}
|
||||
}
|
||||
|
||||
// trim root?
|
||||
if (max == 0 && root) {
|
||||
list<CDir*> ls;
|
||||
@ -7225,8 +7241,9 @@ void MDCache::find_ino_peers(inodeno_t ino, Context *c, int hint)
|
||||
void MDCache::_do_find_ino_peer(find_ino_peer_info_t& fip)
|
||||
{
|
||||
set<int> all, active;
|
||||
mds->mdsmap->get_active_mds_set(active);
|
||||
mds->mdsmap->get_mds_set(all);
|
||||
mds->mdsmap->get_active_mds_set(active);
|
||||
mds->mdsmap->get_mds_set(active, MDSMap::STATE_STOPPING);
|
||||
|
||||
dout(10) << "_do_find_ino_peer " << fip.tid << " " << fip.ino
|
||||
<< " active " << active << " all " << all
|
||||
@ -7473,7 +7490,8 @@ void MDCache::request_forward(MDRequest *mdr, int who, int port)
|
||||
void MDCache::dispatch_request(MDRequest *mdr)
|
||||
{
|
||||
if (mdr->client_request) {
|
||||
if (!mdr->item_session_request.is_on_list()) {
|
||||
if (!mdr->reqid.name.is_mds() &&
|
||||
!mdr->item_session_request.is_on_list()) {
|
||||
dout(10) << "request " << *mdr << " is canceled" << dendl;
|
||||
return;
|
||||
}
|
||||
@ -8288,16 +8306,20 @@ void MDCache::reintegrate_stray(CDentry *straydn, CDentry *rdn)
|
||||
|
||||
void MDCache::migrate_stray(CDentry *dn, int to)
|
||||
{
|
||||
CInode *fromino = dn->dir->get_inode();
|
||||
dout(10) << "migrate_stray from mds"
|
||||
<< MDS_INO_STRAY_OWNER(fromino->inode.ino) << " to mds." << to
|
||||
<< " " << *dn << " " << *dn->get_projected_linkage()->get_inode() << dendl;
|
||||
CInode *in = dn->get_linkage()->get_inode();
|
||||
assert(in);
|
||||
CInode *diri = dn->dir->get_inode();
|
||||
assert(diri->is_stray());
|
||||
dout(10) << "migrate_stray from mds." << MDS_INO_STRAY_OWNER(diri->inode.ino)
|
||||
<< " to mds." << to
|
||||
<< " " << *dn << " " << *in << dendl;
|
||||
|
||||
// rename it to another mds.
|
||||
string dname;
|
||||
dn->get_projected_linkage()->get_inode()->name_stray_dentry(dname);
|
||||
filepath src;
|
||||
dn->make_path(src);
|
||||
|
||||
filepath src(dname, fromino->inode.ino);
|
||||
string dname;
|
||||
in->name_stray_dentry(dname);
|
||||
filepath dst(dname, MDS_INO_STRAY(to, 0));
|
||||
|
||||
MClientRequest *req = new MClientRequest(CEPH_MDS_OP_RENAME);
|
||||
@ -8339,8 +8361,8 @@ void MDCache::discover_base_ino(inodeno_t want_ino,
|
||||
discover_info_t& d = _create_discover(from);
|
||||
d.ino = want_ino;
|
||||
_send_discover(d);
|
||||
waiting_for_base_ino[from][want_ino].push_back(onfinish);
|
||||
}
|
||||
waiting_for_base_ino[from][want_ino].push_back(onfinish);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1716,9 +1716,9 @@ bool MDS::handle_deferrable_message(Message *m)
|
||||
switch (m->get_type()) {
|
||||
// SERVER
|
||||
case CEPH_MSG_CLIENT_SESSION:
|
||||
case CEPH_MSG_CLIENT_REQUEST:
|
||||
case CEPH_MSG_CLIENT_RECONNECT:
|
||||
ALLOW_MESSAGES_FROM(CEPH_ENTITY_TYPE_CLIENT);
|
||||
case CEPH_MSG_CLIENT_REQUEST:
|
||||
server->dispatch(m);
|
||||
break;
|
||||
case MSG_MDS_SLAVE_REQUEST:
|
||||
|
@ -640,7 +640,8 @@ void Migrator::export_dir(CDir *dir, int dest)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!dir->inode->is_base() && dir->inode->get_parent_dir()->get_inode()->is_stray()) {
|
||||
if (!dir->inode->is_base() &&
|
||||
dir->inode->get_parent_dir()->ino() == MDS_INO_MDSDIR(mds->get_nodeid())) {
|
||||
dout(7) << "i won't export anything in stray" << dendl;
|
||||
return;
|
||||
}
|
||||
|
@ -1983,7 +1983,7 @@ CDentry* Server::rdlock_path_xlock_dentry(MDRequest *mdr, int n,
|
||||
}
|
||||
|
||||
CInode *diri = dir->get_inode();
|
||||
if (diri->is_system() && !diri->is_root()) {
|
||||
if (!mdr->reqid.name.is_mds() && diri->is_system() && !diri->is_root()) {
|
||||
reply_request(mdr, -EROFS);
|
||||
return 0;
|
||||
}
|
||||
@ -4577,7 +4577,8 @@ void Server::_unlink_local(MDRequest *mdr, CDentry *dn, CDentry *straydn)
|
||||
mdcache->predirty_journal_parents(mdr, &le->metablob, in, straydn->get_dir(), PREDIRTY_PRIMARY|PREDIRTY_DIR, 1);
|
||||
|
||||
// project snaprealm, too
|
||||
in->project_past_snaprealm_parent(straydn->get_dir()->inode->find_snaprealm());
|
||||
if (in->snaprealm || follows + 1 > dn->first)
|
||||
in->project_past_snaprealm_parent(straydn->get_dir()->inode->find_snaprealm());
|
||||
|
||||
le->metablob.add_primary_dentry(straydn, true, in);
|
||||
} else {
|
||||
@ -5065,7 +5066,8 @@ void Server::handle_client_rename(MDRequest *mdr)
|
||||
|
||||
// src+dest traces _must_ share a common ancestor for locking to prevent orphans
|
||||
if (destpath.get_ino() != srcpath.get_ino() &&
|
||||
!MDS_INO_IS_STRAY(srcpath.get_ino())) { // <-- mds 'rename' out of stray dir is ok!
|
||||
!(req->get_source().is_mds() &&
|
||||
MDS_INO_IS_MDSDIR(srcpath.get_ino()))) { // <-- mds 'rename' out of stray dir is ok!
|
||||
// do traces share a dentry?
|
||||
CDentry *common = 0;
|
||||
for (unsigned i=0; i < srctrace.size(); i++) {
|
||||
@ -5126,10 +5128,12 @@ void Server::handle_client_rename(MDRequest *mdr)
|
||||
pdn = pdn->get_dir()->inode->parent;
|
||||
}
|
||||
|
||||
// is this a stray reintegration or merge? (sanity checks!)
|
||||
// is this a stray migration, reintegration or merge? (sanity checks!)
|
||||
if (mdr->reqid.name.is_mds() &&
|
||||
(!destdnl->is_remote() ||
|
||||
destdnl->get_remote_ino() != srci->ino())) {
|
||||
!(MDS_INO_IS_STRAY(srcpath.get_ino()) &&
|
||||
MDS_INO_IS_STRAY(destpath.get_ino())) &&
|
||||
!(destdnl->is_remote() &&
|
||||
destdnl->get_remote_ino() == srci->ino())) {
|
||||
reply_request(mdr, -EINVAL); // actually, this won't reply, but whatev.
|
||||
return;
|
||||
}
|
||||
@ -5245,11 +5249,16 @@ void Server::handle_client_rename(MDRequest *mdr)
|
||||
}
|
||||
|
||||
// moving between snaprealms?
|
||||
if (srcdnl->is_primary() && !srci->snaprealm &&
|
||||
srci->find_snaprealm() != destdn->get_dir()->inode->find_snaprealm()) {
|
||||
dout(10) << " renaming between snaprealms, creating snaprealm for " << *srci << dendl;
|
||||
mds->mdcache->snaprealm_create(mdr, srci);
|
||||
return;
|
||||
if (srcdnl->is_primary() && srci->is_multiversion() && !srci->snaprealm) {
|
||||
SnapRealm *srcrealm = srci->find_snaprealm();
|
||||
SnapRealm *destrealm = destdn->get_dir()->inode->find_snaprealm();
|
||||
if (srcrealm != destrealm &&
|
||||
(srcrealm->get_newest_seq() + 1 > srcdn->first ||
|
||||
destrealm->get_newest_seq() + 1 > srcdn->first)) {
|
||||
dout(10) << " renaming between snaprealms, creating snaprealm for " << *srci << dendl;
|
||||
mds->mdcache->snaprealm_create(mdr, srci);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
assert(g_conf->mds_kill_rename_at != 1);
|
||||
@ -5648,6 +5657,7 @@ void Server::_rename_prepare(MDRequest *mdr,
|
||||
if (destdn->is_auth())
|
||||
mdcache->predirty_journal_parents(mdr, metablob, srci, destdn->get_dir(), flags, 1);
|
||||
|
||||
SnapRealm *src_realm = srci->find_snaprealm();
|
||||
SnapRealm *dest_realm = destdn->get_dir()->inode->find_snaprealm();
|
||||
snapid_t next_dest_snap = dest_realm->get_newest_seq() + 1;
|
||||
|
||||
@ -5657,7 +5667,8 @@ void Server::_rename_prepare(MDRequest *mdr,
|
||||
if (destdnl->is_primary()) {
|
||||
if (destdn->is_auth()) {
|
||||
// project snaprealm, too
|
||||
oldin->project_past_snaprealm_parent(straydn->get_dir()->inode->find_snaprealm());
|
||||
if (oldin->snaprealm || src_realm->get_newest_seq() + 1 > srcdn->first)
|
||||
oldin->project_past_snaprealm_parent(straydn->get_dir()->inode->find_snaprealm());
|
||||
straydn->first = MAX(oldin->first, next_dest_snap);
|
||||
metablob->add_primary_dentry(straydn, true, oldin);
|
||||
}
|
||||
@ -5701,7 +5712,8 @@ void Server::_rename_prepare(MDRequest *mdr,
|
||||
}
|
||||
} else if (srcdnl->is_primary()) {
|
||||
// project snap parent update?
|
||||
if (destdn->is_auth() && srci->snaprealm)
|
||||
if (destdn->is_auth() &&
|
||||
(srci->snaprealm || src_realm->get_newest_seq() + 1 > srcdn->first))
|
||||
srci->project_past_snaprealm_parent(dest_realm);
|
||||
|
||||
if (destdn->is_auth() && !destdnl->is_null())
|
||||
@ -5836,16 +5848,16 @@ void Server::_rename_apply(MDRequest *mdr, CDentry *srcdn, CDentry *destdn, CDen
|
||||
if (mdr->more()->cap_imports.count(destdnl->get_inode())) {
|
||||
mds->mdcache->migrator->finish_import_inode_caps(destdnl->get_inode(), srcdn->authority().first,
|
||||
mdr->more()->cap_imports[destdnl->get_inode()]);
|
||||
/* hack: add an auth pin for each xlock we hold. These were
|
||||
* remote xlocks previously but now they're local and
|
||||
* we're going to try and unpin when we xlock_finish. */
|
||||
for (set<SimpleLock *>::iterator i = mdr->xlocks.begin();
|
||||
i != mdr->xlocks.end();
|
||||
++i)
|
||||
if ((*i)->get_parent() == destdnl->get_inode() &&
|
||||
!(*i)->is_locallock())
|
||||
mds->locker->xlock_import(*i, mdr);
|
||||
}
|
||||
/* hack: add an auth pin for each xlock we hold. These were
|
||||
* remote xlocks previously but now they're local and
|
||||
* we're going to try and unpin when we xlock_finish. */
|
||||
for (set<SimpleLock *>::iterator i = mdr->xlocks.begin();
|
||||
i != mdr->xlocks.end();
|
||||
++i)
|
||||
if ((*i)->get_parent() == destdnl->get_inode() &&
|
||||
!(*i)->is_locallock())
|
||||
mds->locker->xlock_import(*i, mdr);
|
||||
|
||||
// hack: fix auth bit
|
||||
in->state_set(CInode::STATE_AUTH);
|
||||
@ -6393,8 +6405,11 @@ void Server::do_rename_rollback(bufferlist &rbl, int master, MDRequest *mdr)
|
||||
le->commit.add_null_dentry(straydn, true);
|
||||
}
|
||||
|
||||
if (in->is_dir())
|
||||
if (in->is_dir()) {
|
||||
dout(10) << " noting renamed dir ino " << in->ino() << " in metablob" << dendl;
|
||||
le->commit.renamed_dirino = in->ino();
|
||||
mdcache->project_subtree_rename(in, destdir, srcdir);
|
||||
}
|
||||
|
||||
mdlog->submit_entry(le, new C_MDS_LoggedRenameRollback(this, mut, mdr,
|
||||
srcdnl->get_inode(), destdir));
|
||||
|
@ -488,14 +488,20 @@ void EMetaBlob::replay(MDS *mds, LogSegment *logseg)
|
||||
dir->get_inode()->filelock.mark_dirty();
|
||||
dir->get_inode()->nestlock.mark_dirty();
|
||||
|
||||
if (!(dir->fnode.rstat == dir->fnode.accounted_rstat) ||
|
||||
!(dir->fnode.fragstat == dir->fnode.accounted_fragstat)) {
|
||||
if (!(dir->fnode.rstat == dir->fnode.accounted_rstat)) {
|
||||
dout(10) << "EMetaBlob.replay dirty nestinfo on " << *dir << dendl;
|
||||
mds->locker->mark_updated_scatterlock(&dir->inode->nestlock);
|
||||
logseg->dirty_dirfrag_nest.push_back(&dir->inode->item_dirty_dirfrag_nest);
|
||||
} else {
|
||||
dout(10) << "EMetaBlob.replay clean nestinfo on " << *dir << dendl;
|
||||
}
|
||||
if (!(dir->fnode.fragstat == dir->fnode.accounted_fragstat)) {
|
||||
dout(10) << "EMetaBlob.replay dirty fragstat on " << *dir << dendl;
|
||||
mds->locker->mark_updated_scatterlock(&dir->inode->filelock);
|
||||
logseg->dirty_dirfrag_dir.push_back(&dir->inode->item_dirty_dirfrag_dir);
|
||||
} else {
|
||||
dout(10) << "EMetaBlob.replay clean fragstat on " << *dir << dendl;
|
||||
}
|
||||
}
|
||||
if (lump.is_new())
|
||||
dir->mark_new(logseg);
|
||||
|
Loading…
Reference in New Issue
Block a user