]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: add change_attr to frag_info_t
authorJeff Layton <jlayton@redhat.com>
Mon, 29 Aug 2016 11:16:40 +0000 (07:16 -0400)
committerJeff Layton <jlayton@redhat.com>
Mon, 29 Aug 2016 14:33:46 +0000 (10:33 -0400)
To give us change attribute support for directories. Whenever we gather
the dirfrags, we just select the largest change_attr out of the set.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
src/mds/CDir.cc
src/mds/CInode.cc
src/mds/MDCache.cc
src/mds/mdstypes.cc
src/mds/mdstypes.h

index e0aaebbab660c2be1d1bb8ed3b882c2f722712d7..7be10cc8de82922ff105246face9c3826bc5c8a8 100644 (file)
@@ -943,7 +943,6 @@ void CDir::split(int bits, list<CDir*>& subs, list<MDSInternalContextBase*>& wai
     rstatdiff.add_delta(fnode.accounted_rstat, fnode.rstat);
   if (fnode.accounted_fragstat.version == dirstat_version)
     fragstatdiff.add_delta(fnode.accounted_fragstat, fnode.fragstat);
-
   dout(10) << " rstatdiff " << rstatdiff << " fragstatdiff " << fragstatdiff << dendl;
 
   prepare_old_fragment(replay);
@@ -1021,7 +1020,7 @@ void CDir::merge(list<CDir*>& subs, list<MDSInternalContextBase*>& waiters, bool
 
   nest_info_t rstatdiff;
   frag_info_t fragstatdiff;
-  bool touched_mtime;
+  bool touched_mtime, touched_chattr;
   version_t rstat_version = inode->get_projected_inode()->rstat.version;
   version_t dirstat_version = inode->get_projected_inode()->dirstat.version;
 
@@ -1034,7 +1033,7 @@ void CDir::merge(list<CDir*>& subs, list<MDSInternalContextBase*>& waiters, bool
       rstatdiff.add_delta(dir->fnode.accounted_rstat, dir->fnode.rstat);
     if (dir->fnode.accounted_fragstat.version == dirstat_version)
       fragstatdiff.add_delta(dir->fnode.accounted_fragstat, dir->fnode.fragstat,
-                            &touched_mtime);
+                            &touched_mtime, &touched_chattr);
 
     dir->prepare_old_fragment(replay);
 
index 22a7be3c70e702b50403d8569d5a1347ab2ec449..9138a0e1622a58e0e8a0adf15b412dbdc8569333 100644 (file)
@@ -1988,7 +1988,7 @@ void CInode::finish_scatter_gather_update(int type)
       assert(is_auth());
       inode_t *pi = get_projected_inode();
 
-      bool touched_mtime = false;
+      bool touched_mtime = false, touched_chattr = false;
       dout(20) << "  orig dirstat " << pi->dirstat << dendl;
       pi->dirstat.version++;
       for (compact_map<frag_t,CDir*>::iterator p = dirfrags.begin();
@@ -2013,7 +2013,7 @@ void CInode::finish_scatter_gather_update(int type)
        if (pf->accounted_fragstat.version == pi->dirstat.version - 1) {
          dout(20) << fg << "           fragstat " << pf->fragstat << dendl;
          dout(20) << fg << " accounted_fragstat " << pf->accounted_fragstat << dendl;
-         pi->dirstat.add_delta(pf->fragstat, pf->accounted_fragstat, &touched_mtime);
+         pi->dirstat.add_delta(pf->fragstat, pf->accounted_fragstat, &touched_mtime, &touched_chattr);
        } else {
          dout(20) << fg << " skipping STALE accounted_fragstat " << pf->accounted_fragstat << dendl;
        }
@@ -2041,6 +2041,8 @@ void CInode::finish_scatter_gather_update(int type)
       }
       if (touched_mtime)
        pi->mtime = pi->ctime = pi->dirstat.mtime;
+      if (touched_chattr)
+       pi->change_attr = pi->dirstat.change_attr;
       dout(20) << " final dirstat " << pi->dirstat << dendl;
 
       if (dirstat_valid && !dirstat.same_sums(pi->dirstat)) {
@@ -2063,6 +2065,8 @@ void CInode::finish_scatter_gather_update(int type)
          version_t v = pi->dirstat.version;
          if (pi->dirstat.mtime > dirstat.mtime)
            dirstat.mtime = pi->dirstat.mtime;
+         if (pi->dirstat.change_attr > dirstat.change_attr)
+           dirstat.change_attr = pi->dirstat.change_attr;
          pi->dirstat = dirstat;
          pi->dirstat.version = v;
        }
index 574e505a4ef567ba8f0dc714dcb339732727ffe8..5953ed66963e67bd476cda24fbd65dc2a805338a 100644 (file)
@@ -2153,6 +2153,8 @@ void MDCache::predirty_journal_parents(MutationRef mut, EMetaBlob *blob,
 
       if (do_parent_mtime) {
        pf->fragstat.mtime = mut->get_op_stamp();
+       pf->fragstat.change_attr++;
+       dout(10) << "predirty_journal_parents bumping change_attr to " << pf->fragstat.change_attr << " on " << parent << dendl;
        if (pf->fragstat.mtime > pf->rstat.rctime) {
          dout(10) << "predirty_journal_parents updating mtime on " << *parent << dendl;
          pf->rstat.rctime = pf->fragstat.mtime;
@@ -2277,11 +2279,13 @@ void MDCache::predirty_journal_parents(MutationRef mut, EMetaBlob *blob,
     if (do_parent_mtime || linkunlink) {
       dout(20) << "predirty_journal_parents add_delta " << pf->fragstat << dendl;
       dout(20) << "predirty_journal_parents         - " << pf->accounted_fragstat << dendl;
-      bool touched_mtime = false;
-      pi->dirstat.add_delta(pf->fragstat, pf->accounted_fragstat, &touched_mtime);
+      bool touched_mtime = false, touched_chattr = false;
+      pi->dirstat.add_delta(pf->fragstat, pf->accounted_fragstat, &touched_mtime, &touched_chattr);
       pf->accounted_fragstat = pf->fragstat;
       if (touched_mtime)
        pi->mtime = pi->ctime = pi->dirstat.mtime;
+      if (touched_chattr)
+       pi->change_attr = pi->dirstat.change_attr;
       dout(20) << "predirty_journal_parents     gives " << pi->dirstat << " on " << *pin << dendl;
 
       if (parent->get_frag() == frag_t()) { // i.e., we are the only frag
@@ -11997,6 +12001,8 @@ void MDCache::repair_dirfrag_stats_work(MDRequestRef& mdr)
   if (!good_fragstat) {
     if (pf->fragstat.mtime > frag_info.mtime)
       frag_info.mtime = pf->fragstat.mtime;
+    if (pf->fragstat.change_attr > frag_info.change_attr)
+      frag_info.change_attr = pf->fragstat.change_attr;
     pf->fragstat = frag_info;
     mds->locker->mark_updated_scatterlock(&diri->filelock);
     mdr->ls->dirty_dirfrag_dir.push_back(&diri->item_dirty_dirfrag_dir);
index 20aa36fa156f84587e1cbfdbabbb96d7c9a6b6c3..0edb545d3364b8c1121143696ba94009472c58b0 100644 (file)
@@ -14,21 +14,26 @@ const mds_rank_t MDS_RANK_NONE = mds_rank_t(-1);
 
 void frag_info_t::encode(bufferlist &bl) const
 {
-  ENCODE_START(2, 2, bl);
+  ENCODE_START(3, 2, bl);
   ::encode(version, bl);
   ::encode(mtime, bl);
   ::encode(nfiles, bl);
   ::encode(nsubdirs, bl);
+  ::encode(change_attr, bl);
   ENCODE_FINISH(bl);
 }
 
 void frag_info_t::decode(bufferlist::iterator &bl)
 {
-  DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl);
+  DECODE_START_LEGACY_COMPAT_LEN(3, 2, 2, bl);
   ::decode(version, bl);
   ::decode(mtime, bl);
   ::decode(nfiles, bl);
   ::decode(nsubdirs, bl);
+  if (struct_v >= 3)
+    ::decode(change_attr, bl);
+  else
+    change_attr = 0;
   DECODE_FINISH(bl);
 }
 
index 5c900300489bcbebd87ac1ff006123568cb11229..8c249169a1943188594faff68627a4907e063f66 100644 (file)
@@ -169,10 +169,11 @@ struct scatter_info_t {
 struct frag_info_t : public scatter_info_t {
   // this frag
   utime_t mtime;
+  uint64_t change_attr;
   int64_t nfiles;        // files
   int64_t nsubdirs;      // subdirs
 
-  frag_info_t() : nfiles(0), nsubdirs(0) {}
+  frag_info_t() : change_attr(0), nfiles(0), nsubdirs(0) {}
 
   int64_t size() const { return nfiles + nsubdirs; }
 
@@ -181,12 +182,17 @@ struct frag_info_t : public scatter_info_t {
   }
 
   // *this += cur - acc;
-  void add_delta(const frag_info_t &cur, frag_info_t &acc, bool *touched_mtime=0) {
+  void add_delta(const frag_info_t &cur, frag_info_t &acc, bool *touched_mtime=0, bool *touched_chattr=0) {
     if (cur.mtime > mtime) {
       mtime = cur.mtime;
       if (touched_mtime)
        *touched_mtime = true;
     }
+    if (cur.change_attr > change_attr) {
+      change_attr = cur.change_attr;
+      if (touched_chattr)
+       *touched_chattr = true;
+    }
     nfiles += cur.nfiles - acc.nfiles;
     nsubdirs += cur.nsubdirs - acc.nsubdirs;
   }
@@ -194,6 +200,8 @@ struct frag_info_t : public scatter_info_t {
   void add(const frag_info_t& other) {
     if (other.mtime > mtime)
       mtime = other.mtime;
+    if (other.change_attr > change_attr)
+      change_attr = other.change_attr;
     nfiles += other.nfiles;
     nsubdirs += other.nsubdirs;
   }