From f55a1f87d079a3d67845ec7ea8a40e7f6b2bd1bf Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Fri, 5 Dec 2014 10:48:43 +0800 Subject: [PATCH] mds: disallow flush dentry/journal when MDS is readonly Signed-off-by: Yan, Zheng --- src/mds/MDCache.cc | 5 +++++ src/mds/MDS.cc | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 963b04fc02852..da8bf2234eeee 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -11599,6 +11599,11 @@ void MDCache::scrub_dentry_work(MDRequestRef& mdr) void MDCache::flush_dentry(const string& path, Context *fin) { + if (is_readonly()) { + dout(10) << __func__ << ": read-only FS" << dendl; + fin->complete(-EROFS); + return; + } dout(10) << "flush_dentry " << path << dendl; MDRequestRef mdr = request_start_internal(CEPH_MDS_OP_FLUSH); filepath fp(path.c_str()); diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc index 9008193a493a9..ea8d23da05562 100644 --- a/src/mds/MDS.cc +++ b/src/mds/MDS.cc @@ -365,6 +365,11 @@ int MDS::_command_flush_journal(std::stringstream *ss) Mutex::Locker l(mds_lock); + if (mdcache->is_readonly()) { + dout(5) << __func__ << ": read-only FS" << dendl; + return -EROFS; + } + // I need to seal off the current segment, and then mark all previous segments // for expiry mdlog->start_new_segment(); -- 2.39.5