mirror of
https://github.com/ceph/ceph
synced 2025-02-22 10:37:15 +00:00
mds: Use project_past_parent and pop_projected_snaprealm instead of
add_past_parent hack. Adjusted pop_projected to invalidate caches if needed, and removed project_past_parent's deletion of projected snaprealm. Removed add_past_parent.
This commit is contained in:
parent
b590b4bc1f
commit
7beeecc852
@ -259,8 +259,10 @@ void CInode::project_past_parent(SnapRealm *newparent, bufferlist& snapbl)
|
||||
{
|
||||
sr_t *new_snap = project_snaprealm();
|
||||
SnapRealm *oldparent;
|
||||
if (!snaprealm)
|
||||
if (!snaprealm) {
|
||||
oldparent = find_snaprealm();
|
||||
new_snap->seq = oldparent->get_newest_seq();
|
||||
}
|
||||
else
|
||||
oldparent = snaprealm->parent;
|
||||
|
||||
@ -271,8 +273,6 @@ void CInode::project_past_parent(SnapRealm *newparent, bufferlist& snapbl)
|
||||
new_snap->current_parent_since = MAX(oldparentseq, newparent->get_last_created()) + 1;
|
||||
}
|
||||
new_snap->encode(snapbl);
|
||||
projected_srnode.pop_back();
|
||||
delete new_snap;
|
||||
}
|
||||
|
||||
void CInode::pop_projected_snaprealm()
|
||||
@ -280,11 +280,18 @@ void CInode::pop_projected_snaprealm()
|
||||
assert(!projected_srnode.empty());
|
||||
dout(0) << "pop_projected_snaprealm " << projected_srnode.front()
|
||||
<< " seq" << projected_srnode.front()->seq << dendl;
|
||||
bool invalidate_cached_snaps = false;
|
||||
if (!snaprealm)
|
||||
open_snaprealm();
|
||||
else if (projected_srnode.front()->past_parents.size() !=
|
||||
snaprealm->srnode.past_parents.size())
|
||||
invalidate_cached_snaps = true;
|
||||
snaprealm->srnode = *projected_srnode.front();
|
||||
delete projected_srnode.front();
|
||||
projected_srnode.pop_front();
|
||||
|
||||
if (invalidate_cached_snaps)
|
||||
snaprealm->invalidate_cached_snaps();
|
||||
}
|
||||
|
||||
|
||||
|
@ -4092,15 +4092,10 @@ void Server::_unlink_local_finish(MDRequest *mdr,
|
||||
dout(20) << " straydn is " << *straydn << dendl;
|
||||
straydnl = straydn->pop_projected_linkage();
|
||||
|
||||
SnapRealm *oldparent = dn->get_dir()->inode->find_snaprealm();
|
||||
|
||||
bool isnew = false;
|
||||
if (!straydnl->get_inode()->snaprealm) {
|
||||
straydnl->get_inode()->open_snaprealm();
|
||||
straydnl->get_inode()->snaprealm->srnode.seq = oldparent->get_newest_seq();
|
||||
if (!straydnl->get_inode()->snaprealm)
|
||||
isnew = true;
|
||||
}
|
||||
straydnl->get_inode()->snaprealm->add_past_parent(oldparent);
|
||||
straydnl->get_inode()->pop_projected_snaprealm();
|
||||
if (isnew)
|
||||
mdcache->do_realm_invalidate_and_update_notify(straydnl->get_inode(), CEPH_SNAP_OP_SPLIT, true);
|
||||
|
||||
@ -4882,14 +4877,10 @@ void Server::_rename_apply(MDRequest *mdr, CDentry *srcdn, CDentry *destdn, CDen
|
||||
straydn->get_dir()->link_primary_inode(straydn, oldin);
|
||||
|
||||
if (straydn->is_auth()) {
|
||||
SnapRealm *oldparent = destdn->get_dir()->inode->find_snaprealm();
|
||||
bool isnew = false;
|
||||
if (!straydnl->get_inode()->snaprealm) {
|
||||
straydnl->get_inode()->open_snaprealm();
|
||||
straydnl->get_inode()->snaprealm->srnode.seq = oldparent->get_newest_seq();
|
||||
if (!straydnl->get_inode()->snaprealm)
|
||||
isnew = true;
|
||||
}
|
||||
straydnl->get_inode()->snaprealm->add_past_parent(oldparent);
|
||||
straydnl->get_inode()->pop_projected_snaprealm();
|
||||
if (isnew)
|
||||
mdcache->do_realm_invalidate_and_update_notify(straydnl->get_inode(), CEPH_SNAP_OP_SPLIT);
|
||||
}
|
||||
@ -4962,7 +4953,7 @@ void Server::_rename_apply(MDRequest *mdr, CDentry *srcdn, CDentry *destdn, CDen
|
||||
|
||||
// snap parent update?
|
||||
if (destdn->is_auth() && destdnl->get_inode()->snaprealm)
|
||||
destdnl->get_inode()->snaprealm->add_past_parent(srcdn->get_dir()->inode->find_snaprealm());
|
||||
destdnl->get_inode()->pop_projected_snaprealm();
|
||||
}
|
||||
|
||||
// src
|
||||
|
@ -467,25 +467,6 @@ void SnapRealm::build_snap_trace(bufferlist& snapbl)
|
||||
|
||||
|
||||
|
||||
void SnapRealm::add_past_parent(SnapRealm *oldparent)
|
||||
{
|
||||
snapid_t newlast = parent->get_last_created();
|
||||
snapid_t oldlast = oldparent->get_newest_seq();
|
||||
snapid_t first = srnode.current_parent_since;
|
||||
|
||||
if (oldlast >= srnode.current_parent_since) {
|
||||
srnode.past_parents[oldlast].ino = oldparent->inode->ino();
|
||||
srnode.past_parents[oldlast].first = first;
|
||||
add_open_past_parent(oldparent);
|
||||
dout(10) << "add_past_parent [" << first << "," << oldlast << "] = "
|
||||
<< oldparent->inode->ino() << dendl;
|
||||
}
|
||||
srnode.current_parent_since = MAX(oldlast, newlast) + 1;
|
||||
dout(10) << "add_past_parent current_parent_since " << srnode.current_parent_since << dendl;
|
||||
|
||||
invalidate_cached_snaps();
|
||||
}
|
||||
|
||||
void SnapRealm::prune_past_parents()
|
||||
{
|
||||
dout(10) << "prune_past_parents" << dendl;
|
||||
|
@ -208,7 +208,6 @@ struct SnapRealm {
|
||||
void add_open_past_parent(SnapRealm *parent);
|
||||
void close_parents();
|
||||
|
||||
void add_past_parent(SnapRealm *oldparent);
|
||||
void prune_past_parents();
|
||||
bool has_past_parents() { return !srnode.past_parents.empty(); }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user