mds: treat flushing as dirty when rejoining scattered locks

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: rollback slave request after slave prepare is journalled

Resolve ack message can abort slave requests that are being journalled.
The slave rollback does not handle this case properly. The fix is mark
slave request aborted in this case. The slave rollback code is executed
after slave prepare is safely journalled.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: fix stack overflow caused by nested dispatch

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: drop auth pins before waiting for dir unfreeze

Otherwise deadlock can happen

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: avoid issuing zero caps to client

make sure CEPH_CAP_PIN exists in stale caps.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: properly initialize MDCache::fragment_info_t

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: fix open remote dirfrag deadlock

During subtree migration, the importer may need to open subtree
bound dirfrags. Opening subtree bound dirfrags happens after the
exporter freeze the exporting subtee. So the discover message for
opening subtree bound dirfrags should not wait for any freezing
tree/directory, otherwise deadlock can happen.

In MDCache::handle_discover(), there are two cases can cause
discover messages wait for freezing tree/directory. One case is
fetching bare-bone dirfrags. Another case is, when merging dirfrags,
some of the dirfrags are frozen, some are freezing.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: re-issue caps after importing caps (rename)

After importing inode, the issued caps can be less than the caps
client wants. So re-issue caps after importing inode.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: export file locks together with inode

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: cleanup CInode::decode_import()

We have bumped protocol version several times, no need to maintain
compatibility for ancient message.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: improve success rate of subtree exporting

When exporting a subtree, the migrator acquires the required locks,
then freezes the subtree and releases the locks. After subtree is
frozen, it try acquiring the same locks again.

This patch make scatter locks keep in their old states if inode has
exporting dirfrag. It improves the chance that migrator acquires all
required locks when subtree is frozen.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
fragtree_t: fix get_leaves_under()

If fragtree is (*^1) and the caller wants leaves under frag 00*.
get_leaves_under() should return empty list.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: remove wrong assertion

when handling resolve message, it's possible that bound dirfrags
are missing.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: trim other MDS' mdsdir during recovery

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: don't mark scatter locks dirty when dirfrag is dirty

The journal reply code has check that decides which scatter locks
should be marked as dirty. So don't unconditionally mark scatter
locks dirty when dirfrag is dirty

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: rdlock dirfragtree lock when renaming directory

This make sure inode importer and inode exporter have consistent
view of dirfrags.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: fix potential invalid pointer dereference

pin importing inode until subtree importing finishes

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: avoid infinite loop in MDLog::submit_entry()

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: fix NULL pointer dereference in Server::handle_client_rename

Inode's parent dentry can be NULL, which causes segment fault in
Locker::acquire_locks

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: fix typo in MDCache::handle_cache_rejoin_strong

It should invent dirfrags according to the dirfragtree

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>