MCPcopy Create free account
hub / github.com/ceph/ceph / handle_client_session

Method handle_client_session

src/mds/Server.cc:596–892  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

594}
595
596void 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) {

Callers

nothing calls this directly

Calls 15

client_metadata_tClass · 0.85
ceph_clock_nowFunction · 0.85
is_a_clientMethod · 0.80
get_fs_nameMethod · 0.80
wait_for_replayMethod · 0.80
is_closingMethod · 0.80
is_killingMethod · 0.80
get_cap_authsMethod · 0.80
send_message_clientMethod · 0.80
root_squash_in_capsMethod · 0.80
path_capableMethod · 0.80

Tested by

no test coverage detected