]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
MDS: CInode: create a flush() function
authorGreg Farnum <greg@inktank.com>
Fri, 11 Jul 2014 21:20:05 +0000 (14:20 -0700)
committerGreg Farnum <gfarnum@redhat.com>
Fri, 7 Nov 2014 20:53:03 +0000 (12:53 -0800)
Signed-off-by: Greg Farnum <greg@inktank.com>
src/mds/CDir.cc
src/mds/CInode.cc
src/mds/CInode.h

index e5a1f5109c1f3b8d5b1b15880d52dff9587ae72c..19065a3c33f11c173b279155548d7960918e34e7 100644 (file)
@@ -2072,7 +2072,6 @@ void CDir::_committed(version_t v)
 
 
 
-
 // IMPORT/EXPORT
 
 void CDir::encode_export(bufferlist& bl)
index 7ed7553830521079ca41e3f948154729ed3fb501..62d54e4009476ab2bba7dc68362d8eb4d383d5df 100644 (file)
@@ -952,6 +952,32 @@ void CInode::_stored(version_t v, Context *fin)
   fin->complete(0);
 }
 
+void CInode::flush(MDSInternalContextBase *fin)
+{
+  dout(10) << "flush " << *this << dendl;
+  assert(is_auth() && can_auth_pin());
+
+  MDSGatherBuilder gather(g_ceph_context);
+
+  if (is_dirty_parent()) {
+    store_backtrace(gather.new_sub());
+  }
+  if (is_dirty()) {
+    if (is_base()) {
+      store(gather.new_sub());
+    } else {
+      parent->dir->commit(0, gather.new_sub());
+    }
+  }
+
+  if (gather.has_subs()) {
+    gather.set_finisher(fin);
+    gather.activate();
+  } else {
+    fin->complete(0);
+  }
+}
+
 struct C_IO_Inode_Fetched : public CInodeIOContext {
   bufferlist bl, bl2;
   Context *fin;
index 5b7ace3c0d7c1d1b7f76816c6355df8a06de3c60..d014d2859706ea5178b33f30cede6ad954ab5d93 100644 (file)
@@ -541,9 +541,18 @@ public:
 
   void store(MDSInternalContextBase *fin);
   void _stored(version_t cv, Context *fin);
+  /**
+   * Flush a CInode to disk. This includes the backtrace, the parent
+   * directory's link, and the Inode object itself (if a base directory).
+   * @pre is_auth() on both the inode and its containing directory
+   * @pre can_auth_pin()
+   * @param fin The Context to call when the flush is completed.
+   */
+  void flush(MDSInternalContextBase *fin);
   void fetch(MDSInternalContextBase *fin);
   void _fetched(bufferlist& bl, bufferlist& bl2, Context *fin);  
 
+
   void build_backtrace(int64_t pool, inode_backtrace_t& bt);
   void store_backtrace(MDSInternalContextBase *fin, int op_prio=-1);
   void _stored_backtrace(version_t v, Context *fin);