mds: disallow write operations when MDS is readonly

Signed-off-by: Yan, Zheng <zyan@redhat.com>
mds: don't trim log when MDS is readonly

When MDS is readonly, keep metadata objects (not include the journal) of
cephfs unchanged. This allows us to submit new entries to the log while
MDS is readonly. (Log entries submitted after MDS becomes readonly can
be safely dropped)

Signed-off-by: Yan, Zheng <zyan@redhat.com>
mds: keep locks in sync state when MDS is readonly

when transit locks to sync state, we may submit new entries to the log.
This should be safe as long as we don't trim old log segments.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
mds: disallow slave requests when MDS is readonly

Signed-off-by: Yan, Zheng <zyan@redhat.com>
mds: disable misc internal activitiles when MDS is readonly

Signed-off-by: Yan, Zheng <zyan@redhat.com>
mds: disallow reconnectiong to readonly MDS

this force reconnecting clients to drop any write caps.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
mds: add helper to force MDS readonly

the helper function marks MDS readonly, then revokes write caps from
clients.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
mds: notify clients when MDS goes to readonly

notice clients that MDS goes to readonly and MDS won't issue write
caps any more.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
client: handle MDS 'force readonly' message

make client return -EROFS for write when MDS is readonly, instead of
waiting forever.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
mds: add asok command to force MDS readonly

Signed-off-by: Yan, Zheng <zyan@redhat.com>
mds: allow choosing action for wirte error

Signed-off-by: Yan, Zheng <zyan@redhat.com>
mds: don't blindly create empty object when dirfrag is missing

mark the corresponding CDir as bad instead.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
mds: drop dirty dentries in deleted directory

opened dirfrags and null dirty dentries in deleted directory inode
prevent MDCache::eval_stray() from purging the delete inode.

It's safe to not commit null dirty dentries in deleted directory to
corresponding dirfrag objects, because these dirfrag objects will be
deleted soon.

Fixes: #10164
Signed-off-by: Yan, Zheng <zyan@redhat.com>
mds: properly unregister asok commands

Signed-off-by: Yan, Zheng <zyan@redhat.com>
mds: disallow flush dentry/journal when MDS is readonly

Signed-off-by: Yan, Zheng <zyan@redhat.com>
mds: drop dentry leases in deleted directory

we will never link dentry in deleted directory to inode, so it's
OK to remove client leases prematurely. This optimization allows
us to purge deleted directory inode earlier.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
gf-complete: update submodule to newest upstream

Keep the tree cleaner!

Signed-off-by: Greg Farnum <gfarnum@redhat.com>
ceph-osd: remove extra close of stderr

Otherwise, one loses log messages when running with -f or -d.  When
daemonizing, stderr is already closed in global_init_postfork_finish.

Fixes: #10010, #10113, #9810

Signed-off-by: Dan Mick <dan.mick@redhat.com>
mds: set dirfrag version when fetching dirfrag is skipped

Signed-off-by: Yan, Zheng <zyan@redhat.com>
Merge pull request #3120 from ceph/wip-10010

ceph-osd: don't close stderr if not daemonizing

Reviewed-by: Sage Weil <sage@redhat.com>
Reviewed-by: Loic Dachary <ldachary@redhat.com>