| 6941 | } |
| 6942 | |
| 6943 | int Client::mount(const std::string &mount_root, const UserPerm& perms, |
| 6944 | bool require_mds, const std::string &fs_name) |
| 6945 | { |
| 6946 | ceph_assert(is_initialized()); |
| 6947 | |
| 6948 | /* |
| 6949 | * To make sure that the _unmount() must wait until the mount() |
| 6950 | * is done. |
| 6951 | */ |
| 6952 | RWRef_t mref_writer(mount_state, CLIENT_MOUNTING, false); |
| 6953 | if (!mref_writer.is_first_writer()) // already mounting or mounted |
| 6954 | return 0; |
| 6955 | |
| 6956 | ldout(cct, 1) << __func__ << ": " << mount_root << " " << perms |
| 6957 | << " required_mds=" << require_mds << " fs_name=" << fs_name << dendl; |
| 6958 | |
| 6959 | std::unique_lock cl(client_lock); |
| 6960 | |
| 6961 | int r = subscribe_mdsmap(fs_name); |
| 6962 | if (r < 0) { |
| 6963 | lderr(cct) << "mdsmap subscription failed: " << cpp_strerror(r) << dendl; |
| 6964 | return r; |
| 6965 | } |
| 6966 | |
| 6967 | start_tick_thread(); // start tick thread |
| 6968 | |
| 6969 | if (require_mds) { |
| 6970 | while (1) { |
| 6971 | auto availability = mdsmap->is_cluster_available(); |
| 6972 | if (availability == MDSMap::STUCK_UNAVAILABLE) { |
| 6973 | // Error out |
| 6974 | ldout(cct, 10) << "mds cluster unavailable: epoch=" << mdsmap->get_epoch() << dendl; |
| 6975 | return CEPH_FUSE_NO_MDS_UP; |
| 6976 | } else if (availability == MDSMap::AVAILABLE) { |
| 6977 | // Continue to mount |
| 6978 | break; |
| 6979 | } else if (availability == MDSMap::TRANSIENT_UNAVAILABLE) { |
| 6980 | // Else, wait. MDSMonitor will update the map to bring |
| 6981 | // us to a conclusion eventually. |
| 6982 | wait_on_list(waiting_for_mdsmap); |
| 6983 | } else { |
| 6984 | // Unexpected value! |
| 6985 | ceph_abort(); |
| 6986 | } |
| 6987 | } |
| 6988 | } |
| 6989 | |
| 6990 | if(mdsmap->test_flag(CEPH_MDSMAP_REFUSE_CLIENT_SESSION)) { |
| 6991 | lderr(cct) << "connections cannot be made while" |
| 6992 | " the flag refuse_client_session is set" << dendl; |
| 6993 | return -EACCES; |
| 6994 | } |
| 6995 | |
| 6996 | populate_metadata(mount_root.empty() ? "/" : mount_root); |
| 6997 | |
| 6998 | filepath fp(CEPH_INO_ROOT); |
| 6999 | if (!mount_root.empty()) { |
| 7000 | fp = filepath(mount_root.c_str()); |
no test coverage detected