net/ceph/mon_client.c
Source file repositories/reference/linux-study-clean/net/ceph/mon_client.c
File Facts
- System
- Linux kernel
- Corpus path
net/ceph/mon_client.c- Extension
.c- Size
- 39310 bytes
- Lines
- 1598
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/ceph/ceph_debug.hlinux/module.hlinux/types.hlinux/slab.hlinux/random.hlinux/sched.hlinux/ceph/ceph_features.hlinux/ceph/mon_client.hlinux/ceph/libceph.hlinux/ceph/debugfs.hlinux/ceph/decode.hlinux/ceph/auth.h
Detected Declarations
function decode_mon_infofunction blobfunction ceph_monmap_containsfunction __send_prepared_auth_requestfunction __close_sessionfunction pick_new_monfunction __open_sessionfunction reopen_sessionfunction ceph_monc_reopen_sessionfunction un_backofffunction __schedule_delayedfunction __send_subscribefunction handle_subscribe_ackfunction __ceph_monc_want_mapfunction ceph_monc_want_mapfunction __ceph_monc_got_mapfunction ceph_monc_got_mapfunction ceph_monc_renew_subsfunction ceph_monc_wait_osdmapfunction __ceph_open_sessionfunction ceph_monc_handle_mapfunction requestsfunction put_generic_requestfunction get_generic_requestfunction alloc_generic_requestfunction register_generic_requestfunction send_generic_requestfunction __finish_generic_requestfunction finish_generic_requestfunction complete_generic_requestfunction cancel_generic_requestfunction wait_generic_requestfunction handle_statfs_replyfunction statfsfunction handle_get_version_replyfunction __ceph_monc_get_versionfunction ceph_monc_get_versionfunction ceph_monc_get_version_asyncfunction handle_command_ackfunction __printffunction __printffunction ceph_monc_blocklist_addfunction __resend_generic_requestfunction delayed_workfunction mountfunction ceph_monc_initfunction ceph_monc_stopfunction finish_hunting
Annotated Snippet
if (monc->cur_mon >= 0) {
if (monc->cur_mon < monc->monmap->num_mon)
o = monc->cur_mon;
if (o >= 0)
max--;
}
n = get_random_u32_below(max);
if (o >= 0 && n >= o)
n++;
monc->cur_mon = n;
}
dout("%s mon%d -> mon%d out of %d mons\n", __func__, old_mon,
monc->cur_mon, monc->monmap->num_mon);
}
/*
* Open a session with a new monitor.
*/
static void __open_session(struct ceph_mon_client *monc)
{
int ret;
pick_new_mon(monc);
monc->hunting = true;
if (monc->had_a_connection) {
monc->hunt_mult *= CEPH_MONC_HUNT_BACKOFF;
if (monc->hunt_mult > CEPH_MONC_HUNT_MAX_MULT)
monc->hunt_mult = CEPH_MONC_HUNT_MAX_MULT;
}
monc->sub_renew_after = jiffies; /* i.e., expired */
monc->sub_renew_sent = 0;
dout("%s opening mon%d\n", __func__, monc->cur_mon);
ceph_con_open(&monc->con, CEPH_ENTITY_TYPE_MON, monc->cur_mon,
&monc->monmap->mon_inst[monc->cur_mon].addr);
/*
* Queue a keepalive to ensure that in case of an early fault
* the messenger doesn't put us into STANDBY state and instead
* retries. This also ensures that our timestamp is valid by
* the time we finish hunting and delayed_work() checks it.
*/
ceph_con_keepalive(&monc->con);
if (ceph_msgr2(monc->client)) {
monc->pending_auth = 1;
return;
}
/* initiate authentication handshake */
ret = ceph_auth_build_hello(monc->auth,
monc->m_auth->front.iov_base,
monc->m_auth->front_alloc_len);
BUG_ON(ret <= 0);
__send_prepared_auth_request(monc, ret);
}
static void reopen_session(struct ceph_mon_client *monc)
{
if (!monc->hunting)
pr_info("mon%d %s session lost, hunting for new mon\n",
monc->cur_mon, ceph_pr_addr(&monc->con.peer_addr));
__close_session(monc);
__open_session(monc);
}
void ceph_monc_reopen_session(struct ceph_mon_client *monc)
{
mutex_lock(&monc->mutex);
reopen_session(monc);
mutex_unlock(&monc->mutex);
}
static void un_backoff(struct ceph_mon_client *monc)
{
monc->hunt_mult /= 2; /* reduce by 50% */
if (monc->hunt_mult < 1)
monc->hunt_mult = 1;
dout("%s hunt_mult now %d\n", __func__, monc->hunt_mult);
}
/*
* Reschedule delayed work timer.
*/
static void __schedule_delayed(struct ceph_mon_client *monc)
Annotation
- Immediate include surface: `linux/ceph/ceph_debug.h`, `linux/module.h`, `linux/types.h`, `linux/slab.h`, `linux/random.h`, `linux/sched.h`, `linux/ceph/ceph_features.h`, `linux/ceph/mon_client.h`.
- Detected declarations: `function decode_mon_info`, `function blob`, `function ceph_monmap_contains`, `function __send_prepared_auth_request`, `function __close_session`, `function pick_new_mon`, `function __open_session`, `function reopen_session`, `function ceph_monc_reopen_session`, `function un_backoff`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.