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

Method _get_session

src/osdc/Objecter.cc:1921–1956  ·  view source on GitHub ↗

* Look up OSDSession by OSD id. * * @returns 0 on success, or -EAGAIN if the lock context requires * promotion to write. */

Source from the content-addressed store, hash-verified

1919 * promotion to write.
1920 */
1921int Objecter::_get_session(int osd, OSDSession **session,
1922 shunique_lock<ceph::shared_mutex>& sul)
1923{
1924 ceph_assert(sul && sul.mutex() == &rwlock);
1925
1926 if (osd < 0) {
1927 *session = homeless_session;
1928 ldout(cct, 20) << __func__ << " osd=" << osd << " returning homeless"
1929 << dendl;
1930 return 0;
1931 }
1932
1933 auto p = osd_sessions.find(osd);
1934 if (p != osd_sessions.end()) {
1935 auto s = p->second;
1936 s->get();
1937 *session = s;
1938 ldout(cct, 20) << __func__ << " s=" << s << " osd=" << osd << " "
1939 << s->get_nref() << dendl;
1940 return 0;
1941 }
1942 if (!sul.owns_lock()) {
1943 return -EAGAIN;
1944 }
1945 auto s = new OSDSession(cct, osd);
1946 osd_sessions[osd] = s;
1947 s->con = messenger->connect_to_osd(osdmap->get_addrs(osd));
1948 s->con->set_priv(RefCountedPtr{s});
1949 logger->inc(l_osdc_osd_session_open);
1950 logger->set(l_osdc_osd_sessions, osd_sessions.size());
1951 s->get();
1952 *session = s;
1953 ldout(cct, 20) << __func__ << " s=" << s << " osd=" << osd << " "
1954 << s->get_nref() << dendl;
1955 return 0;
1956}
1957
1958void Objecter::put_session(Objecter::OSDSession *s)
1959{

Callers

nothing calls this directly

Calls 12

get_nrefMethod · 0.80
connect_to_osdMethod · 0.80
set_privMethod · 0.80
mutexMethod · 0.45
findMethod · 0.45
endMethod · 0.45
getMethod · 0.45
owns_lockMethod · 0.45
get_addrsMethod · 0.45
incMethod · 0.45
setMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected