mds: fix-up inode's fragstat/rstat according its dirfrags

Extend the code that fixup inode's fragstat/rstat to handle multiple
dirfrags

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: encode dirfrag base in cache rejoin ack

Makes sure recovering MDS get uptodate fragstat/rstat for subtree root
dirfrags. it's required the codes that fix-up inode's fragstat/rstat.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: ignore stale rstat/fragstat when splitting dirfrag

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: fix root and mdsdir inodes' rsubdirs

inode rstat accounts inode itself.

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

_rollback_repair_dir() may increase dirfrag's rfiles/rsubdirs twice.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: cancel fragmenting dirfrags when cluster is degraded

when cluster is degraded, acquiring locking can take long time.
It is not good to keep dirfrags in frozen state for a long time.

To allow cancelling fragment operation at any time, this commit
also reorganizes the codes that freeze/fetch dirfrags.

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

When splitting dirfrag, delta rstat is always added to the first new
dirfrag. Ancestors of the dirfrag may have nagtive rstat before the
delta rstat has been propagated to them. For example:

inode 100 n(v1 b-4096)
|- dir 100 n(v1 b-4096)
   |- dentry
      |- inode 101 n(v1 b-4096)
         |- dir 101.0* n(v1)/n(v1 b-4096)
         |- dir 101.1* n(v1)

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: handle export freezen race

handle following sequence of events:
- subtree becomes frozen, C_MDC_ExportFreeze is queued.
- export is cancelled
- C_MDC_ExportFreeze is executed.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: handle linkage mismatch when finding mdsdir's bounds

If a MDS crashed after journaling a rmdir operation, but before sending
MDentryUnlink messages, survivor MDS may have incorrect linkage for the
removed directory. Later when the MDS recovers, the incorrect linkage
causes the survivor MDS crash (in MDCache::adjust_bounded_subtree_auth)

The fix is, when adjusting authority of recovering MDS's mdsdir, trim
any bound difrags that are linked to incorrect places.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: switch flushing ScatterLock to dirty ScatterLock after cache rejoin

Otherwise the flushing flag may confuse Locker::eval_gather() if MDS later
imports lock's parent inode.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: choose MIX state if replica of scatterlock is in MIX state

After ScatterLock::infer_state_from_strong_rejoin() set scatterlock
to LOCK_MIX state, don't change the scatterlock to other state.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: properly wake up dentry waiters after fragmenting dirfrag

When active MDS wants to fragment a replica dirfrag, it should set
the 'replay' parameter of MDCache::adjust_dir_fragments() to false.
It makes sure that CDir::merge/split wake up any dentry waiter.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: remove unused MMDSCacheRejoin::{MISSING,FULL}

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