net/ceph/osdmap.c
Source file repositories/reference/linux-study-clean/net/ceph/osdmap.c
File Facts
- System
- Linux kernel
- Corpus path
net/ceph/osdmap.c- Extension
.c- Size
- 72503 bytes
- Lines
- 3111
- 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/slab.hlinux/ceph/libceph.hlinux/ceph/osdmap.hlinux/ceph/decode.hlinux/crush/hash.hlinux/crush/mapper.h
Detected Declarations
struct crush_name_nodefunction __printffunction calc_bits_offunction calc_pg_masksfunction crush_decode_uniform_bucketfunction crush_decode_list_bucketfunction crush_decode_tree_bucketfunction crush_decode_straw_bucketfunction crush_decode_straw2_bucketfunction free_crush_namefunction decode_crush_namesfunction clear_crush_namesfunction free_choose_arg_mapfunction clear_choose_argsfunction decode_choose_argfunction decode_choose_argsfunction crush_finalizefunction ceph_pg_comparefunction ceph_spg_comparefunction free_pg_mappingfunction pg_tempfunction ceph_pg_poolid_by_namefunction ceph_pg_pool_flagsfunction __remove_pg_poolfunction decode_poolfunction decode_pool_namesfunction free_workspacefunction init_workspace_managerfunction add_initial_workspacefunction cleanup_workspace_managerfunction put_workspacefunction ceph_osdmap_destroyfunction osdmap_set_max_osdfunction osdmap_set_crushfunction newfunction __decode_poolsfunction decode_poolsfunction decode_new_poolsfunction decode_pg_mappingfunction decode_pg_tempfunction decode_new_pg_tempfunction decode_primary_tempfunction decode_new_primary_tempfunction ceph_get_primary_affinityfunction set_primary_affinityfunction decode_primary_affinityfunction decode_new_primary_affinityfunction decode_pg_upmap
Annotated Snippet
struct crush_name_node {
struct rb_node cn_node;
int cn_id;
char cn_name[];
};
static struct crush_name_node *alloc_crush_name(size_t name_len)
{
struct crush_name_node *cn;
cn = kmalloc(sizeof(*cn) + name_len + 1, GFP_NOIO);
if (!cn)
return NULL;
RB_CLEAR_NODE(&cn->cn_node);
return cn;
}
static void free_crush_name(struct crush_name_node *cn)
{
WARN_ON(!RB_EMPTY_NODE(&cn->cn_node));
kfree(cn);
}
DEFINE_RB_FUNCS(crush_name, struct crush_name_node, cn_id, cn_node)
static int decode_crush_names(void **p, void *end, struct rb_root *root)
{
u32 n;
ceph_decode_32_safe(p, end, n, e_inval);
while (n--) {
struct crush_name_node *cn;
int id;
u32 name_len;
ceph_decode_32_safe(p, end, id, e_inval);
ceph_decode_32_safe(p, end, name_len, e_inval);
ceph_decode_need(p, end, name_len, e_inval);
cn = alloc_crush_name(name_len);
if (!cn)
return -ENOMEM;
cn->cn_id = id;
memcpy(cn->cn_name, *p, name_len);
cn->cn_name[name_len] = '\0';
*p += name_len;
if (!__insert_crush_name(root, cn)) {
free_crush_name(cn);
return -EEXIST;
}
}
return 0;
e_inval:
return -EINVAL;
}
void clear_crush_names(struct rb_root *root)
{
while (!RB_EMPTY_ROOT(root)) {
struct crush_name_node *cn =
rb_entry(rb_first(root), struct crush_name_node, cn_node);
erase_crush_name(root, cn);
free_crush_name(cn);
}
}
static struct crush_choose_arg_map *alloc_choose_arg_map(void)
{
struct crush_choose_arg_map *arg_map;
arg_map = kzalloc_obj(*arg_map, GFP_NOIO);
if (!arg_map)
return NULL;
RB_CLEAR_NODE(&arg_map->node);
return arg_map;
}
static void free_choose_arg_map(struct crush_choose_arg_map *arg_map)
{
int i, j;
if (!arg_map)
Annotation
- Immediate include surface: `linux/ceph/ceph_debug.h`, `linux/module.h`, `linux/slab.h`, `linux/ceph/libceph.h`, `linux/ceph/osdmap.h`, `linux/ceph/decode.h`, `linux/crush/hash.h`, `linux/crush/mapper.h`.
- Detected declarations: `struct crush_name_node`, `function __printf`, `function calc_bits_of`, `function calc_pg_masks`, `function crush_decode_uniform_bucket`, `function crush_decode_list_bucket`, `function crush_decode_tree_bucket`, `function crush_decode_straw_bucket`, `function crush_decode_straw2_bucket`, `function free_crush_name`.
- 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.