From: Yuan Zhou Date: Tue, 25 Aug 2015 08:27:58 +0000 (+0800) Subject: ceph-fuse: warn and shut down when there is no MDS present X-Git-Tag: v9.1.0~98^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d8970f7e37ba8e9b3d5b6991219563fc994bb6b1;p=ceph.git ceph-fuse: warn and shut down when there is no MDS present 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 --- diff --git a/src/ceph_fuse.cc b/src/ceph_fuse.cc index 4dde41772ff..40bbd0a112d 100644 --- a/src/ceph_fuse.cc +++ b/src/ceph_fuse.cc @@ -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; } diff --git a/src/client/Client.cc b/src/client/Client.cc index 4259c6ecdf6..486e8a56512 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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. diff --git a/src/client/Client.h b/src/client/Client.h index d8f2dc1d269..add195d5f31 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -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(