]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: add helper to force MDS readonly
authorYan, Zheng <zyan@redhat.com>
Fri, 28 Nov 2014 13:09:08 +0000 (21:09 +0800)
committerYan, Zheng <zyan@redhat.com>
Tue, 2 Dec 2014 02:47:23 +0000 (10:47 +0800)
the helper function marks MDS readonly, then revokes write caps from
clients.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/mds/MDCache.cc
src/mds/MDCache.h

index 568e1eb1095d29c69cb065869bd0d4bfb17984e8..6488870bf8577218725323e8d060cabd33898da2 100644 (file)
@@ -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<vinodeno_t,CInode*>::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();
+}
 
 
 // ==============================================================
index 2d20ced367d5257cc6ce3b55049271cd0396b3cb..9366cb41367e3ab0f949ee09728b6f69653c56c2 100644 (file)
@@ -107,7 +107,7 @@ public:
     stray_index = (stray_index+1)%NUM_STRAY;
   }
   bool is_readonly() { return readonly; }
-
+  void force_readonly();
 
   DecayRate decayrate;