net/ceph/messenger_v2.c
Source file repositories/reference/linux-study-clean/net/ceph/messenger_v2.c
File Facts
- System
- Linux kernel
- Corpus path
net/ceph/messenger_v2.c- Extension
.c- Size
- 99753 bytes
- Lines
- 3815
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source 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.
- 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.hcrypto/aead.hcrypto/sha2.hcrypto/utils.hlinux/bvec.hlinux/crc32c.hlinux/net.hlinux/scatterlist.hlinux/socket.hlinux/sched/mm.hnet/sock.hnet/tcp.hlinux/ceph/ceph_features.hlinux/ceph/decode.hlinux/ceph/libceph.hlinux/ceph/messenger.hcrypto.h
Detected Declarations
function Copyrightfunction ceph_tcp_recvfunction do_sendmsgfunction do_try_sendpagefunction ceph_tcp_sendfunction add_in_kvecfunction reset_in_kvecsfunction set_in_bvecfunction set_in_skipfunction add_out_kvecfunction reset_out_kvecsfunction set_out_bvecfunction set_out_bvec_zerofunction out_zero_addfunction free_conn_bufsfunction add_in_sign_kvecfunction clear_in_sign_kvecsfunction add_out_sign_kvecfunction clear_out_sign_kvecsfunction con_securefunction front_lenfunction middle_lenfunction data_lenfunction need_paddingfunction padded_lenfunction padding_lenfunction head_onwire_lenfunction __tail_onwire_lenfunction tail_onwire_lenfunction onefunction init_frame_descfunction itselffunction decode_preamblefunction FRAME_TAG_WAITfunction encode_epilogue_plainfunction encode_epilogue_securefunction decode_epiloguefunction fill_headerfunction fill_header2function verify_control_crcfunction verify_epilogue_crcsfunction setup_cryptofunction con_hmac_sha256function gcm_inc_noncefunction gcm_cryptfunction get_bvec_atfunction calc_sg_cntfunction calc_sg_cnt_cursor
Annotated Snippet
if (ret <= 0) {
if (ret == -EAGAIN)
ret = 0;
return ret;
}
iov_iter_advance(it, ret);
}
WARN_ON(msg_data_left(&msg));
return 1;
}
/*
* Read as much as possible.
*
* Return:
* 1 - done, nothing (else) to read
* 0 - socket is empty, need to wait
* <0 - error
*/
static int ceph_tcp_recv(struct ceph_connection *con)
{
int ret;
dout("%s con %p %s %zu\n", __func__, con,
iov_iter_is_discard(&con->v2.in_iter) ? "discard" : "need",
iov_iter_count(&con->v2.in_iter));
ret = do_recvmsg(con->sock, &con->v2.in_iter);
dout("%s con %p ret %d left %zu\n", __func__, con, ret,
iov_iter_count(&con->v2.in_iter));
return ret;
}
static int do_sendmsg(struct socket *sock, struct iov_iter *it)
{
struct msghdr msg = { .msg_flags = CEPH_MSG_FLAGS };
int ret;
msg.msg_iter = *it;
while (iov_iter_count(it)) {
ret = sock_sendmsg(sock, &msg);
if (ret <= 0) {
if (ret == -EAGAIN)
ret = 0;
return ret;
}
iov_iter_advance(it, ret);
}
WARN_ON(msg_data_left(&msg));
return 1;
}
static int do_try_sendpage(struct socket *sock, struct iov_iter *it)
{
struct msghdr msg = { .msg_flags = CEPH_MSG_FLAGS };
struct bio_vec bv;
int ret;
if (WARN_ON(!iov_iter_is_bvec(it)))
return -EINVAL;
while (iov_iter_count(it)) {
/* iov_iter_iovec() for ITER_BVEC */
bvec_set_page(&bv, it->bvec->bv_page,
min(iov_iter_count(it),
it->bvec->bv_len - it->iov_offset),
it->bvec->bv_offset + it->iov_offset);
/*
* MSG_SPLICE_PAGES cannot properly handle pages with
* page_count == 0, we need to fall back to sendmsg if
* that's the case.
*
* Same goes for slab pages: skb_can_coalesce() allows
* coalescing neighboring slab objects into a single frag
* which triggers one of hardened usercopy checks.
*/
if (sendpage_ok(bv.bv_page))
msg.msg_flags |= MSG_SPLICE_PAGES;
else
msg.msg_flags &= ~MSG_SPLICE_PAGES;
iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bv, 1, bv.bv_len);
ret = sock_sendmsg(sock, &msg);
if (ret <= 0) {
if (ret == -EAGAIN)
ret = 0;
Annotation
- Immediate include surface: `linux/ceph/ceph_debug.h`, `crypto/aead.h`, `crypto/sha2.h`, `crypto/utils.h`, `linux/bvec.h`, `linux/crc32c.h`, `linux/net.h`, `linux/scatterlist.h`.
- Detected declarations: `function Copyright`, `function ceph_tcp_recv`, `function do_sendmsg`, `function do_try_sendpage`, `function ceph_tcp_send`, `function add_in_kvec`, `function reset_in_kvecs`, `function set_in_bvec`, `function set_in_skip`, `function add_out_kvec`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source 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.