| 594 | } |
| 595 | |
| 596 | void Server::handle_client_session(const cref_t<MClientSession> &m) |
| 597 | { |
| 598 | version_t pv; |
| 599 | Session *session = mds->get_session(m); |
| 600 | |
| 601 | dout(3) << "handle_client_session " << *m << " from " << m->get_source() << dendl; |
| 602 | ceph_assert(m->is_a_client()); // should _not_ come from an mds! |
| 603 | |
| 604 | if (!session) { |
| 605 | dout(0) << " ignoring sessionless msg " << *m << dendl; |
| 606 | auto reply = make_message<MClientSession>(CEPH_SESSION_REJECT); |
| 607 | reply->metadata["error_string"] = "sessionless"; |
| 608 | mds->send_message(reply, m->get_connection()); |
| 609 | return; |
| 610 | } |
| 611 | |
| 612 | std::string_view fs_name = mds->mdsmap->get_fs_name(); |
| 613 | if (!fs_name.empty() && !session->fs_name_capable(fs_name, MAY_READ)) { |
| 614 | dout(0) << " dropping message not allowed for this fs_name: " << *m << dendl; |
| 615 | auto reply = make_message<MClientSession>(CEPH_SESSION_REJECT); |
| 616 | reply->metadata["error_string"] = "client doesn't have caps for FS \"" + |
| 617 | std::string(fs_name) + "\""; |
| 618 | mds->send_message(std::move(reply), m->get_connection()); |
| 619 | return; |
| 620 | } |
| 621 | |
| 622 | if (m->get_op() == CEPH_SESSION_REQUEST_RENEWCAPS) { |
| 623 | // always handle renewcaps (state >= MDSMap::STATE_RECONNECT) |
| 624 | } else if (m->get_op() == CEPH_SESSION_REQUEST_CLOSE) { |
| 625 | // close requests need to be handled when mds is active |
| 626 | if (mds->get_state() < MDSMap::STATE_ACTIVE) { |
| 627 | mds->wait_for_active(new C_MDS_RetryMessage(mds, m)); |
| 628 | return; |
| 629 | } |
| 630 | } else { |
| 631 | if (mds->get_state() < MDSMap::STATE_CLIENTREPLAY) { |
| 632 | mds->wait_for_replay(new C_MDS_RetryMessage(mds, m)); |
| 633 | return; |
| 634 | } |
| 635 | } |
| 636 | |
| 637 | if (logger) |
| 638 | logger->inc(l_mdss_handle_client_session); |
| 639 | |
| 640 | uint64_t sseq = 0; |
| 641 | switch (m->get_op()) { |
| 642 | case CEPH_SESSION_REQUEST_OPEN: |
| 643 | if(mds->mdsmap->test_flag(CEPH_MDSMAP_REFUSE_CLIENT_SESSION)) { |
| 644 | dout(0) << "new sessions are not permitted, enable again via" |
| 645 | "`ceph fs set <fs_name> refuse_client_session false`" << dendl; |
| 646 | auto reply = make_message<MClientSession>(CEPH_SESSION_REJECT); |
| 647 | reply->metadata["error_string"] = "new sessions are not permitted," |
| 648 | " enable again via `ceph fs set" |
| 649 | " <fs_name> refuse_client_session false`"; |
| 650 | mds->send_message(reply, m->get_connection()); |
| 651 | return; |
| 652 | } |
| 653 | if (!session->client_opened) { |
nothing calls this directly
no test coverage detected