]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: add dirty_rstat CInode elist, state, pins
authorSage Weil <sage@newdream.net>
Thu, 23 Sep 2010 20:04:00 +0000 (13:04 -0700)
committerSage Weil <sage@newdream.net>
Fri, 24 Sep 2010 18:44:22 +0000 (11:44 -0700)
We need to track inodes with unpropagated rstat data on a per-dirfrag
basis so that we can propagate it when the nestlock becomes writeable.

src/mds/CDir.cc
src/mds/CDir.h
src/mds/CInode.cc
src/mds/CInode.h

index 4d3be3c0ed97c877c189b006250e41a60266b5fb..b76746c9b4446a9be8fb41d35c15f0510ab5eb99 100644 (file)
@@ -139,6 +139,7 @@ ostream& CDir::print_db_line_prefix(ostream& out)
 // CDir
 
 CDir::CDir(CInode *in, frag_t fg, MDCache *mdcache, bool auth) :
+  dirty_rstat_inodes(member_offset(CInode, dirty_rstat_item)),
   item_dirty(this), item_new(this)
 {
   g_num_dir++;
index 6ed182749773153d4520097b2e84d2afab7b2c59..c3df6f4d0c22fefe1c413e689f163c072a41c6ac 100644 (file)
@@ -166,6 +166,9 @@ public:
   snapid_t first;
   map<snapid_t,old_rstat_t> dirty_old_rstat;  // [value.first,key]
 
+  // my inodes with dirty rstat data
+  elist<CInode*> dirty_rstat_inodes;     
+
 protected:
   version_t projected_version;
   list<fnode_t*> projected_fnode;
index 14079dffbca644543e65cbadf71970cc6e91bdfd..62821cf8e80d2a2d998e5104675422e32c0ebe1c 100644 (file)
@@ -221,6 +221,27 @@ void CInode::print(ostream& out)
 }
 
 
+
+void CInode::mark_dirty_rstat()
+{
+  if (!state_test(STATE_DIRTYRSTAT)) {
+    dout(10) << "mark_dirty_rstat" << dendl;
+    state_set(STATE_DIRTYRSTAT);
+    get(PIN_DIRTYRSTAT);
+    CDentry *dn = get_projected_parent_dn();
+    dn->dir->dirty_rstat_inodes.push_back(&dirty_rstat_item);
+  }
+}
+void CInode::clear_dirty_rstat()
+{
+  if (state_test(STATE_DIRTYRSTAT)) {
+    dout(10) << "clear_dirty_rstat" << dendl;
+    state_clear(STATE_DIRTYRSTAT);
+    put(PIN_DIRTYRSTAT);
+    dirty_rstat_item.remove_myself();
+  }
+}
+
 inode_t *CInode::project_inode(map<string,bufferptr> *px) 
 {
   if (projected_nodes.empty()) {
index 98c36748aa9e0eca23b656f2d2dc4d5193a4f8d7..c3ede95b9c6d5148599d40b1adf19424bc48b773 100644 (file)
@@ -100,6 +100,7 @@ public:
   static const int PIN_TRUNCATING =       18;
   static const int PIN_STRAY =            19;  // we pin our stray inode while active
   static const int PIN_NEEDSNAPFLUSH =    20;
+  static const int PIN_DIRTYRSTAT =       21;
 
   const char *pin_name(int p) {
     switch (p) {
@@ -122,6 +123,7 @@ public:
     case PIN_TRUNCATING: return "truncating";
     case PIN_STRAY: return "stray";
     case PIN_NEEDSNAPFLUSH: return "needsnapflush";
+    case PIN_DIRTYRSTAT: return "dirtyrstat";
     default: return generic_pin_name(p);
     }
   }
@@ -140,6 +142,7 @@ public:
   static const int STATE_RECOVERING =   (1<<12);
   static const int STATE_PURGING =     (1<<13);
   static const int STATE_DIRTYPARENT =  (1<<14);
+  static const int STATE_DIRTYRSTAT =  (1<<15);
 
   // -- waiters --
   static const uint64_t WAIT_DIR         = (1<<0);
@@ -183,6 +186,16 @@ public:
   //loff_t last_open_journaled;  // log offset for the last journaled EOpen
   utime_t last_dirstat_prop;
 
+
+  // list item node for when we have unpropagated rstat data
+  elist<CInode*>::item dirty_rstat_item;
+
+  bool is_dirty_rstat() {
+    return state_test(STATE_DIRTYRSTAT);
+  }
+  void mark_dirty_rstat();
+  void clear_dirty_rstat();
+
   //bool hack_accessed;
   //utime_t hack_load_stamp;