mirror of
https://github.com/ceph/ceph
synced 2025-01-20 10:01:45 +00:00
mds: Move SnapRealm::project_past_parent to the CInode and fix users.
For now, delete the projected version of the inode so it matches (or fixes?) old behavior. Once users have been fixed to use pop_projected_snaprealm et al, remove that.
This commit is contained in:
parent
e4ea064edd
commit
830b62a9e1
@ -253,6 +253,28 @@ sr_t *CInode::project_snaprealm(snapid_t snapid)
|
||||
return projected_srnode.back();
|
||||
}
|
||||
|
||||
/* if newparent != parent, add parent to past_parents
|
||||
if parent DNE, we need to find what the parent actually is and fill that in */
|
||||
void CInode::project_past_parent(SnapRealm *newparent, bufferlist& snapbl)
|
||||
{
|
||||
sr_t *new_snap = project_snaprealm();
|
||||
SnapRealm *oldparent;
|
||||
if (!snaprealm)
|
||||
oldparent = find_snaprealm();
|
||||
else
|
||||
oldparent = snaprealm->parent;
|
||||
|
||||
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;
|
||||
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()
|
||||
{
|
||||
assert(!projected_srnode.empty());
|
||||
|
@ -239,7 +239,7 @@ public:
|
||||
else
|
||||
return projected_srnode.back();
|
||||
}
|
||||
|
||||
void project_past_parent(SnapRealm *newparent, bufferlist& snapbl);
|
||||
|
||||
old_inode_t& cow_old_inode(snapid_t follows, inode_t *pi);
|
||||
old_inode_t *pick_old_inode(snapid_t last);
|
||||
|
@ -4055,12 +4055,7 @@ void Server::_unlink_local(MDRequest *mdr, CDentry *dn, CDentry *straydn)
|
||||
|
||||
// project snaprealm, too
|
||||
bufferlist snapbl;
|
||||
if (!in->snaprealm) {
|
||||
in->open_snaprealm(true); // don't do a split
|
||||
in->snaprealm->project_past_parent(straydn->get_dir()->inode->find_snaprealm(), snapbl);
|
||||
in->close_snaprealm(true); // or a matching join
|
||||
} else
|
||||
in->snaprealm->project_past_parent(straydn->get_dir()->inode->find_snaprealm(), snapbl);
|
||||
in->project_past_parent(straydn->get_dir()->inode->find_snaprealm(), snapbl);
|
||||
|
||||
le->metablob.add_primary_dentry(straydn, true, in, 0, &snapbl);
|
||||
} else {
|
||||
@ -4794,12 +4789,7 @@ void Server::_rename_prepare(MDRequest *mdr,
|
||||
if (destdnl->is_primary()) {
|
||||
// project snaprealm, too
|
||||
bufferlist snapbl;
|
||||
if (!destdnl->get_inode()->snaprealm) {
|
||||
destdnl->get_inode()->open_snaprealm(true); // don't do a split
|
||||
destdnl->get_inode()->snaprealm->project_past_parent(straydn->get_dir()->inode->find_snaprealm(), snapbl);
|
||||
destdnl->get_inode()->close_snaprealm(true); // or a matching join
|
||||
} else
|
||||
destdnl->get_inode()->snaprealm->project_past_parent(straydn->get_dir()->inode->find_snaprealm(), snapbl);
|
||||
destdnl->get_inode()->project_past_parent(straydn->get_dir()->inode->find_snaprealm(), snapbl);
|
||||
straydn->first = destdnl->get_inode()->first; // XXX hmm, is this right?
|
||||
tji = metablob->add_primary_dentry(straydn, true, destdnl->get_inode(), 0, &snapbl);
|
||||
} else if (destdnl->is_remote()) {
|
||||
@ -4830,7 +4820,7 @@ void Server::_rename_prepare(MDRequest *mdr,
|
||||
// project snap parent update?
|
||||
bufferlist snapbl;
|
||||
if (destdn->is_auth() && srcdnl->get_inode()->snaprealm)
|
||||
srcdnl->get_inode()->snaprealm->project_past_parent(destdn->get_dir()->inode->find_snaprealm(), snapbl);
|
||||
srcdnl->get_inode()->project_past_parent(destdn->get_dir()->inode->find_snaprealm(), snapbl);
|
||||
|
||||
if (!destdnl->is_null())
|
||||
mdcache->journal_cow_dentry(mdr, metablob, destdn, CEPH_NOSNAP, 0, destdnl);
|
||||
|
@ -467,29 +467,6 @@ void SnapRealm::build_snap_trace(bufferlist& snapbl)
|
||||
|
||||
|
||||
|
||||
|
||||
void SnapRealm::project_past_parent(SnapRealm *newparent, bufferlist& snapbl)
|
||||
{
|
||||
snapid_t newlast = newparent->get_last_created();
|
||||
snapid_t oldlast = parent->get_newest_seq();
|
||||
snapid_t first = srnode.current_parent_since;
|
||||
|
||||
if (oldlast >= srnode.current_parent_since) {
|
||||
srnode.past_parents[oldlast].ino = parent->inode->ino();
|
||||
srnode.past_parents[oldlast].first = first;
|
||||
dout(10) << "project_past_parent new past_parent [" << first << "," << oldlast << "] = "
|
||||
<< parent->inode->ino() << dendl;
|
||||
}
|
||||
srnode.current_parent_since = MAX(oldlast, newlast) + 1;
|
||||
dout(10) << "project_past_parent current_parent_since " << srnode.current_parent_since << dendl;
|
||||
|
||||
::encode(*this, snapbl);
|
||||
|
||||
if (oldlast >= first)
|
||||
srnode.past_parents.erase(oldlast);
|
||||
srnode.current_parent_since = first;
|
||||
}
|
||||
|
||||
void SnapRealm::add_past_parent(SnapRealm *oldparent)
|
||||
{
|
||||
snapid_t newlast = parent->get_last_created();
|
||||
|
@ -208,7 +208,6 @@ struct SnapRealm {
|
||||
void add_open_past_parent(SnapRealm *parent);
|
||||
void close_parents();
|
||||
|
||||
void project_past_parent(SnapRealm *newparent, bufferlist& snapbl);
|
||||
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