From: Dhairya Parmar Date: Wed, 20 May 2026 21:18:15 +0000 (+0530) Subject: mds: persist session auth_name in ESession journal event X-Git-Tag: v21.0.1~87^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4b059084d33023d7b220739509551c830926b05d;p=ceph.git mds: persist session auth_name in ESession journal event So that it can be applied to the freshly creation session which happens while recreating session in ESession::replay when the OMAP version fell behind the ESession cmapv and the newly creation session would be rejected as target when a client tries to reclaim this session. Fixes: https://tracker.ceph.com/issues/76728 Signed-off-by: Dhairya Parmar --- diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 8a36adf7c53..688c21d3364 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -816,7 +816,8 @@ void Server::handle_client_session(const cref_t &m) ceph_assert(r == 0); log_session_status("ACCEPTED", ""); }); - mdlog->submit_entry(new ESession(m->get_source_inst(), true, pv, client_metadata), + mdlog->submit_entry(new ESession(m->get_source_inst(), true, pv, + client_metadata, session->info.auth_name), new C_MDS_session_finish(this, session, sseq, true, pv, fin)); mdlog->flush(); } @@ -1536,7 +1537,8 @@ void Server::journal_close_session(Session *session, int state, Context *on_safe } else piv = 0; - auto le = new ESession(session->info.inst, false, pv, inos_to_free, piv, session->delegated_inos); + auto le = new ESession(session->info.inst, false, pv, inos_to_free, piv, + session->delegated_inos, session->info.auth_name); auto fin = new C_MDS_session_finish(this, session, sseq, false, pv, inos_to_free, piv, session->delegated_inos, mdlog->get_current_segment(), on_safe); mdlog->submit_entry(le, fin); diff --git a/src/mds/events/ESession.h b/src/mds/events/ESession.h index ae9e7747148..58f6decb870 100644 --- a/src/mds/events/ESession.h +++ b/src/mds/events/ESession.h @@ -35,18 +35,22 @@ class ESession : public LogEvent { // Client metadata stored during open client_metadata_t client_metadata; + // persist auth_name to allow journal recreated session to be reclaimed + EntityName auth_name; + public: ESession() : LogEvent(EVENT_SESSION), open(false) { } ESession(const entity_inst_t& inst, bool o, version_t v, - const client_metadata_t& cm) : + const client_metadata_t& cm, EntityName auth_name_) : LogEvent(EVENT_SESSION), client_inst(inst), open(o), cmapv(v), inotablev(0), - client_metadata(cm) { } + client_metadata(cm), auth_name(auth_name_) { } ESession(const entity_inst_t& inst, bool o, version_t v, const interval_set& to_free, version_t iv, - const interval_set& to_purge) : + const interval_set& to_purge, EntityName auth_name_) : LogEvent(EVENT_SESSION), client_inst(inst), open(o), cmapv(v), - inos_to_free(to_free), inotablev(iv), inos_to_purge(to_purge) {} + inos_to_free(to_free), inotablev(iv), inos_to_purge(to_purge), + auth_name(auth_name_) {} void encode(bufferlist& bl, uint64_t features) const override; void decode(bufferlist::const_iterator& bl) override; diff --git a/src/mds/journal.cc b/src/mds/journal.cc index 3b82337f00d..5891f37e5ad 100644 --- a/src/mds/journal.cc +++ b/src/mds/journal.cc @@ -1894,6 +1894,9 @@ void ESession::replay(MDSRank *mds) session = mds->sessionmap.get_or_add_session(client_inst); mds->sessionmap.set_state(session, Session::STATE_OPEN); session->set_client_metadata(client_metadata); + if (session->info.auth_name.to_str().empty()) { + session->info.auth_name = auth_name; + } dout(10) << " opened session " << session->info.inst << dendl; } else { session = mds->sessionmap.get_session(client_inst.name); @@ -1943,7 +1946,7 @@ void ESession::replay(MDSRank *mds) void ESession::encode(bufferlist &bl, uint64_t features) const { - ENCODE_START(6, 5, bl); + ENCODE_START(7, 5, bl); encode(stamp, bl); encode(client_inst, bl, features); encode(open, bl); @@ -1952,12 +1955,13 @@ void ESession::encode(bufferlist &bl, uint64_t features) const encode(inotablev, bl); encode(client_metadata, bl); encode(inos_to_purge, bl); + encode(auth_name, bl); ENCODE_FINISH(bl); } void ESession::decode(bufferlist::const_iterator &bl) { - DECODE_START_LEGACY_COMPAT_LEN(6, 3, 3, bl); + DECODE_START_LEGACY_COMPAT_LEN(7, 3, 3, bl); if (struct_v >= 2) decode(stamp, bl); decode(client_inst, bl); @@ -1973,6 +1977,9 @@ void ESession::decode(bufferlist::const_iterator &bl) if (struct_v >= 6){ decode(inos_to_purge, bl); } + if (struct_v >= 7) { + decode(auth_name, bl); + } DECODE_FINISH(bl); }