]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-fuse: warn and shut down when there is no MDS present 5416/head
authorYuan Zhou <yuan.zhou@intel.com>
Tue, 25 Aug 2015 08:27:58 +0000 (16:27 +0800)
committerYuan Zhou <yuan.zhou@intel.com>
Sat, 29 Aug 2015 09:24:21 +0000 (17:24 +0800)
This patch checks the up MDS servers when mounting. If there's
no MDS server up, report in the log then force quit.

Fixes: #12204
Signed-off-by: Yuan Zhou <yuan.zhou@intel.com>
src/ceph_fuse.cc
src/client/Client.cc
src/client/Client.h

index 4dde41772ff76ad602f46cd3d6357f4f8cbeca63..40bbd0a112dfabfea7bbb2a0254a3b8711eef7eb 100644 (file)
@@ -206,8 +206,10 @@ int main(int argc, const char **argv, const char *envp[]) {
 
     // start up fuse
     // use my argc, argv (make sure you pass a mount point!)
-    r = client->mount(g_conf->client_mountpoint.c_str());
+    r = client->mount(g_conf->client_mountpoint.c_str(), g_ceph_context->_conf->fuse_require_active_mds);
     if (r < 0) {
+      if (r == CEPH_FUSE_NO_MDS_UP)
+        cerr << "ceph-fuse[" << getpid() << "]: probably no MDS server is up?" << std::endl;
       cerr << "ceph-fuse[" << getpid() << "]: ceph mount failed with " << cpp_strerror(-r) << std::endl;
       goto out_shutdown;
     }
index 4259c6ecdf605cd244f776c26fc1a67f18a7739e..486e8a5651292d181267339dd2aec42faff3e83b 100644 (file)
@@ -4834,7 +4834,7 @@ void Client::handle_command_reply(MCommandReply *m)
 // -------------------
 // MOUNT
 
-int Client::mount(const std::string &mount_root)
+int Client::mount(const std::string &mount_root, bool require_mds)
 {
   Mutex::Locker lock(client_lock);
 
@@ -4851,6 +4851,20 @@ int Client::mount(const std::string &mount_root)
   tick(); // start tick
   
   ldout(cct, 2) << "mounted: have mdsmap " << mdsmap->get_epoch() << dendl;
+  if (require_mds) {
+    while (1) {
+      if (mdsmap->get_epoch() > 0) {
+        if (mdsmap->get_num_mds(CEPH_MDS_STATE_ACTIVE) == 0) {
+          ldout(cct, 10) << "no mds up: epoch=" << mdsmap->get_epoch() << dendl;
+          return CEPH_FUSE_NO_MDS_UP;
+        } else {
+          break;
+        }
+      } else {
+        wait_on_list(waiting_for_mdsmap);
+      }
+    }
+  }
 
   // hack: get+pin root inode.
   //  fuse assumes it's always there.
index d8f2dc1d269b430cbc35d1bc89b1d5c7cb24d598..add195d5f31d9f607a8b1535a5ad4e6564d6e594 100644 (file)
@@ -765,7 +765,7 @@ private:
   void _release_filelocks(Fh *fh);
   void _update_lock_state(struct flock *fl, uint64_t owner, ceph_lock_state_t *lock_state);
 public:
-  int mount(const std::string &mount_root);
+  int mount(const std::string &mount_root, bool require_mds=false);
   void unmount();
 
   int mds_command(