From 1eb94da2f6275a37ae49c299af7c2695890be5c9 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sat, 6 Nov 2010 11:18:13 -0700 Subject: [PATCH] mds: introduce/use helpers to resync stale fragstat/rstat; update version Simplifies code. Also, update the version when we resync! Signed-off-by: Sage Weil --- src/mds/CDir.cc | 27 +++++++++++++++++++++++++++ src/mds/CDir.h | 2 ++ src/mds/MDCache.cc | 16 ++++++++-------- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc index b4dbfdbf09485..ba3cba06c851a 100644 --- a/src/mds/CDir.cc +++ b/src/mds/CDir.cc @@ -787,6 +787,33 @@ void CDir::merge(list& subs, list& waiters, bool replay) +void CDir::resync_accounted_fragstat() +{ + fnode_t *pf = get_projected_fnode(); + inode_t *pi = inode->get_projected_inode(); + + if (pf->accounted_fragstat.version != pi->dirstat.version) { + pf->fragstat.version = pi->dirstat.version; + dout(10) << "resync_accounted_fragstat " << pf->accounted_fragstat << " -> " << pf->fragstat << dendl; + pf->accounted_fragstat = pf->fragstat; + } +} + +/* + * resync rstat and accounted_rstat with inode + */ +void CDir::resync_accounted_rstat() +{ + fnode_t *pf = get_projected_fnode(); + inode_t *pi = inode->get_projected_inode(); + + if (pf->accounted_rstat.version != pi->rstat.version) { + pf->rstat.version = pi->rstat.version; + dout(10) << "resync_accounted_rstat " << pf->accounted_rstat << " -> " << pf->rstat << dendl; + pf->accounted_rstat = pf->rstat; + dirty_old_rstat.clear(); + } +} void CDir::assimilate_dirty_rstat_inodes() { diff --git a/src/mds/CDir.h b/src/mds/CDir.h index f3be970f7a47f..5262841b01e82 100644 --- a/src/mds/CDir.h +++ b/src/mds/CDir.h @@ -170,6 +170,8 @@ public: // my inodes with dirty rstat data elist dirty_rstat_inodes; + void resync_accounted_fragstat(); + void resync_accounted_rstat(); void assimilate_dirty_rstat_inodes(); void assimilate_dirty_rstat_inodes_finish(Mutation *mut, EMetaBlob *blob); diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 2088e8f9cce41..a82d717c8c134 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -1733,6 +1733,9 @@ void MDCache::predirty_journal_parents(Mutation *mut, EMetaBlob *blob, mut->is_slave()); // we are slave. master will have wrlocked the dir. assert(cfollows == CEPH_NOSNAP); + // update stale fragstat? + parent->resync_accounted_fragstat(); + if (do_parent_mtime) { pf->fragstat.mtime = mut->now; if (mut->now > pf->rstat.rctime) { @@ -1782,8 +1785,11 @@ void MDCache::predirty_journal_parents(Mutation *mut, EMetaBlob *blob, if (cur->first > first) first = cur->first; - project_rstat_inode_to_frag(cur, parent, first, linkunlink); + // first, if the frag is stale, bring it back in sync. + parent->resync_accounted_rstat(); + // now push inode rstats into frag + project_rstat_inode_to_frag(cur, parent, first, linkunlink); cur->clear_dirty_rstat(); } @@ -1900,13 +1906,7 @@ void MDCache::predirty_journal_parents(Mutation *mut, EMetaBlob *blob, dout(10) << "predirty_journal_parents frag->inode on " << *parent << dendl; // first, if the frag is stale, bring it back in sync. - // this matches the logic in CInode::finish_scatter_gather_update(); - if (pf->accounted_rstat.version != pi->rstat.version) { - dout(10) << " resyncing stale rstat (rstat->accounted_rstat)" << dendl; - pf->rstat.version = pi->rstat.version; - pf->accounted_rstat = pf->rstat; - parent->dirty_old_rstat.clear(); - } + parent->resync_accounted_rstat(); for (map::iterator p = parent->dirty_old_rstat.begin(); p != parent->dirty_old_rstat.end(); -- 2.39.5