From: Yan, Zheng Date: Fri, 28 Nov 2014 13:09:08 +0000 (+0800) Subject: mds: add helper to force MDS readonly X-Git-Tag: v0.91~52^2~14^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e0637b47c702fd6b4bcfff0a653791c2fd9ec495;p=ceph.git mds: add helper to force MDS readonly the helper function marks MDS readonly, then revokes write caps from clients. Signed-off-by: Yan, Zheng --- diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 568e1eb1095..6488870bf85 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 2d20ced367d..9366cb41367 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;