mds: Cleanup new segment conditionals

The second conditional for adding a new segment is always
true when the first conditional is true.  Clean this up
to simply create a new segment when we've reached the end of
the current segment.

Signed-off-by: Sam Lang <sam.lang@inktank.com>
pybind/cephfs:  Add initial py wrappers for cephfs.

Signed-off-by: Sam Lang <sam.lang@inktank.com>
test/mds:  Add test to check backtraces

Signed-off-by: Sam Lang <sam.lang@inktank.com>
mds: Add kill points for backtrace testing

Signed-off-by: Sam Lang <sam.lang@inktank.com>
mds: Dump the pool field after backpointers

The pool field of the inode backtrace should
be dumped after the backpointers are closed.

Signed-off-by: Sam Lang <sam.lang@inktank.com>
mds: queue backtrace during fullbits, not roots

Add backtrace writeout to EMetaBlob::fullbits, not root inodes.
We accidentally added the logic to the wrong inode loop — whoops!

Signed-off-by: Sam Lang <sam.lang@inktank.com>
pybind/libcephfs:  Minor fixes

Signed-off-by: Sam Lang <sam.lang@inktank.com>
test/mds: Fixes to test-backtrace.py

Allow running an individual test, and other
misc. fixes.

Signed-off-by: Sam Lang <sam.lang@inktank.com>
message/mds:  Fix client reconnect decode

Flip the conditional so that snap realms are
decoded, otherwise this results in an assertion
failure of the mds when a client attempts to
reconnect.

Signed-off-by: Sam Lang <sam.lang@inktank.com>
include/elist: Fix clear() to use pop_front()

elist<T>::clear() is calling remove(), which isn't a
method defined on elist<T> (it was never defined according
to git).  Because elist is templated and no references
to clear() are ever made, the compiler matches remove(T) to the
remove(const char *) system call defined in stdio.h.

Once clear is invoked on an instance of elist<T>, we get the
compile error shown below.

The fix here is to use pop_front() instead of remove().

Compile error is:
In file included from ../../src/mds/CInode.h:22:0,
                 from ../../src/mds/CInode.cc:19:
../../src/include/elist.h: In instantiation of ‘void elist<T>::clear() [with T = cinode_backtrace_info_t*]’:
../../src/mds/CInode.cc:1129:20:   required from here
../../src/include/elist.h:101:7: error: no matching function for call to ‘remove(cinode_backtrace_info_t*)’
../../src/include/elist.h:101:7: note: candidates are:
In file included from ../../src/mds/CInode.cc:17:0:
/usr/include/stdio.h:179:12: note: int remove(const char*)
/usr/include/stdio.h:179:12: note:   no known conversion for argument 1 from ‘cinode_backtrace_info_t*’ to ‘const char*’
In file included from /usr/include/c++/4.7/algorithm:63:0,
                 from /usr/include/c++/4.7/backward/hashtable.h:65,
                 from /usr/include/c++/4.7/ext/hash_map:65,
                 from ../../src/include/encoding.h:292,
                 from ../../src/common/entity_name.h:22,
                 from ../../src/common/config.h:26,
                 from ../../src/mds/CInode.h:20,
                 from ../../src/mds/CInode.cc:19:
/usr/include/c++/4.7/bits/stl_algo.h:1117:5: note: template<class _FIter, class _Tp> _FIter std::remove(_FIter, _FIter, const _Tp&)
/usr/include/c++/4.7/bits/stl_algo.h:1117:5: note:   template argument deduction/substitution failed:
In file included from ../../src/mds/CInode.h:22:0,
                 from ../../src/mds/CInode.cc:19:
../../src/include/elist.h:101:7: note:   candidate expects 3 arguments, 1 provided

Signed-off-by: Sam Lang <sam.lang@inktank.com>
mds: Update backtrace on inode remove

If replay removes an inode from the mdcache (or
it gets removed somehow else), we need to queue an
update to the backtrace that clears it from pointing
to valid parents.  This avoids fsck spuriously finding
a orphaned inode later on.

Signed-off-by: Sam Lang <sam.lang@inktank.com>
client: Ensure inode/dentries are ref counted

The MetaRequest holds onto inodes and dentries
for retrying unsafe requests, but those objects
might be removed from the cache (unlink for example)
causing the inode/dentry to be freed.  Ensure that
the inode/dentry is never freed while the MetaRequest
holds onto it by putting/getting the refs using
set/get interfaces.

Signed-off-by: Sam Lang <sam.lang@inktank.com>
mds: Keep inode pinned while in cache

Add a pin ref for the MDCache, so that we can
properly free an inode once the ref drops to zero
outside of the cache, namely, if the inode is still
pinned by a pending backtrace write, but the inode
is being removed from the cache, we don't want to yet
free it.

Signed-off-by: Sam Lang <sam.lang@inktank.com>