client: add debugging around traceless reply failures

Tracking down #5021

Signed-off-by: Sage Weil <sage@inktank.com>
client: leave NULL dentry in place on ENOENT during lookup

If we get a NULL lookup result, unlink the inode but leave the dentry
in place.

Signed-off-by: Sage Weil <sage@inktank.com>
client: avoid blindly removing dentries

MetaRequests may have references to these dentries.  Instead of removing
them and tearing down the directory, just unlink them from the inodes.

We could be a bit smarter here if we looked at the reference count, but
this works too.

Signed-off-by: Sage Weil <sage@inktank.com>
client: handle traceless rename in insert_trace, not verify_reply_trace

The insert_trace() logic is about managing local cache consistency; the
verify_reply_trace() is about retrying requests to get the results that
our callers need.

Set up stubs to handle rmdir and unlink while we are here.

Signed-off-by: Sage Weil <sage@inktank.com>
client: skip insert_trace on safe requests

Only do this for the first reply.

Signed-off-by: Sage Weil <sage@inktank.com>
Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
client: refactor _lookup; fix NULL dentry case

Return ENOENT for a valid NULL dentry in our cache.  Restructure _lookup
to avoid duplicating some code.

Signed-off-by: Sage Weil <sage@inktank.com>
client: do not manually clean up on unlink/rmdir

The reply handler will do this in a safe, ordered fashion.

Signed-off-by: Sage Weil <sage@inktank.com>
client: unlink dentry on traceless rmdir, unlink reply

This used to be handled in _unlink() and _rmdir() even when a trace was
present in the reply, but this is cleaner.

Signed-off-by: Sage Weil <sage@inktank.com>
client: audit unlink() callers

Basically, always keep the dentry and dir, unless we are pruning.

Signed-off-by: Sage Weil <sage@inktank.com>
Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
client: invalidate dentry leases when unlinking

In many case when we are unlinking inodes we also need to invalidate the
dentry lease, as we are not promised that the dentry is NULL.  Be a bit
over-conservative here for good measure.

Signed-off-by: Sage Weil <sage@inktank.com>
Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
client: make less noise when unlinking during readdir

Skip, but do not talk about, NULL dentries.

Signed-off-by: Sage Weil <sage@inktank.com>
client: use __func__ instead of incorrect function name in insert_readdir_results

Signed-off-by: Sage Weil <sage@inktank.com>
client: fix whitespace in stat relpath

Signed-off-by: Sage Weil <sage@inktank.com>
mds: cleanup usage of MDCache::predirty_journal_parent()

The sixth parameter of MDCache::predirty_journal_parent() is 'int'
with default value 0.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: avoid journaling unnecessary dir context

If base inode is reached, try clearing the 'maybe' list, then stop.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: propagate inode rstat if it has never been propagated

Otherwise the 'last_dirstat_prop' of directory inode keeps in 'never'
state.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: properly clear new flag for stale client cap

CInode::encode_inodestat() should clear the 'new' flag of client
cap even when session is stale, because the 'new' flag prevents
Locker::issue_caps() from sending cap message to client.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: revert EMetaBlob::{fullbit,remotebit,nullbit} encoding optimization

Revert commit 40d56a97 (mds: optimize EMetaBlob::fullbit, remotebit,
nullbit encoding). This optimization creates small segments in the
result bufferlist of encoding EMetaBlob. Perf shows lots of CPU time
are used for allocating list node for bufferlist.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: deny reconnect for closed session

The client that tries reconnect may have dirty caps and unsafe requests.
Allowing the reconnect attempt may compromise consistency.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
Merge pull request #1771 from ceph/wip-5021

Wip 5021

Reviewed-by: Sage Weil <sage@inktank.com>
Reviewed-by: Greg Farnum <greg@inktank.com>