From e0637b47c702fd6b4bcfff0a653791c2fd9ec495 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Fri, 28 Nov 2014 21:09:08 +0800 Subject: [PATCH] mds: add helper to force MDS readonly the helper function marks MDS readonly, then revokes write caps from clients. Signed-off-by: Yan, Zheng --- src/mds/MDCache.cc | 21 +++++++++++++++++++++ src/mds/MDCache.h | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 568e1eb1095d2..6488870bf8577 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -11274,6 +11274,27 @@ void MDCache::rollback_uncommitted_fragments() } } +void MDCache::force_readonly() +{ + if (is_readonly()) + return; + + dout(1) << "force file system read-only" << dendl; + mds->clog->warn() << "force file system read-only\n"; + + set_readonly(); + + // revoke write caps + for (ceph::unordered_map::iterator p = inode_map.begin(); + p != inode_map.end(); + ++p) { + CInode *in = p->second; + if (in->is_head()) + mds->locker->eval(in, CEPH_CAP_LOCKS); + } + + mds->mdlog->flush(); +} // ============================================================== diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h index 2d20ced367d52..9366cb41367e3 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -107,7 +107,7 @@ public: stray_index = (stray_index+1)%NUM_STRAY; } bool is_readonly() { return readonly; } - + void force_readonly(); DecayRate decayrate; -- 2.39.5