From 86384fe33a7ba610a0923ad82b7578fbd4a6efc1 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Fri, 11 Jul 2014 14:20:05 -0700 Subject: [PATCH] MDS: CInode: create a flush() function Signed-off-by: Greg Farnum --- src/mds/CDir.cc | 1 - src/mds/CInode.cc | 26 ++++++++++++++++++++++++++ src/mds/CInode.h | 9 +++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc index e5a1f5109c1f3..19065a3c33f11 100644 --- a/src/mds/CDir.cc +++ b/src/mds/CDir.cc @@ -2072,7 +2072,6 @@ void CDir::_committed(version_t v) - // IMPORT/EXPORT void CDir::encode_export(bufferlist& bl) diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index 7ed7553830521..62d54e4009476 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -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; diff --git a/src/mds/CInode.h b/src/mds/CInode.h index 5b7ace3c0d7c1..d014d2859706e 100644 --- a/src/mds/CInode.h +++ b/src/mds/CInode.h @@ -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); -- 2.39.5