net/ceph/striper.c
Source file repositories/reference/linux-study-clean/net/ceph/striper.c
File Facts
- System
- Linux kernel
- Corpus path
net/ceph/striper.c- Extension
.c- Size
- 7909 bytes
- Lines
- 279
- 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.
- 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/math64.hlinux/slab.hlinux/ceph/striper.hlinux/ceph/types.h
Detected Declarations
function ceph_calc_file_object_mappingfunction objnofunction list_for_each_prevfunction lookup_containingfunction list_for_each_entryfunction onefunction ceph_iterate_extentsfunction kfreefunction ceph_get_num_objectsexport ceph_calc_file_object_mappingexport ceph_file_to_extentsexport ceph_iterate_extentsexport ceph_extent_to_fileexport ceph_get_num_objects
Annotated Snippet
if (!last_ex || last_ex->oe_off + last_ex->oe_len != objoff) {
ex = alloc_fn(alloc_arg);
if (!ex)
return -ENOMEM;
ex->oe_objno = objno;
ex->oe_off = objoff;
ex->oe_len = xlen;
if (action_fn)
action_fn(ex, xlen, action_arg);
if (!last_ex)
list_add(&ex->oe_item, add_pos);
else
list_add(&ex->oe_item, &last_ex->oe_item);
} else {
last_ex->oe_len += xlen;
if (action_fn)
action_fn(last_ex, xlen, action_arg);
}
off += xlen;
len -= xlen;
}
for (last_ex = list_first_entry(object_extents, typeof(*ex), oe_item),
ex = list_next_entry(last_ex, oe_item);
&ex->oe_item != object_extents;
last_ex = ex, ex = list_next_entry(ex, oe_item)) {
if (last_ex->oe_objno > ex->oe_objno ||
(last_ex->oe_objno == ex->oe_objno &&
last_ex->oe_off + last_ex->oe_len >= ex->oe_off)) {
WARN(1, "%s: object_extents list not sorted!\n",
__func__);
return -EINVAL;
}
}
return 0;
}
EXPORT_SYMBOL(ceph_file_to_extents);
/*
* A stripped down, non-allocating version of ceph_file_to_extents(),
* for when @object_extents is already populated.
*/
int ceph_iterate_extents(struct ceph_file_layout *l, u64 off, u64 len,
struct list_head *object_extents,
ceph_object_extent_fn_t action_fn,
void *action_arg)
{
while (len) {
struct ceph_object_extent *ex;
u64 objno, objoff;
u32 xlen;
ceph_calc_file_object_mapping(l, off, len, &objno, &objoff,
&xlen);
ex = lookup_containing(object_extents, objno, objoff, xlen);
if (!ex) {
WARN(1, "%s: objno %llu %llu~%u not found!\n",
__func__, objno, objoff, xlen);
return -EINVAL;
}
action_fn(ex, xlen, action_arg);
off += xlen;
len -= xlen;
}
return 0;
}
EXPORT_SYMBOL(ceph_iterate_extents);
/*
* Reverse map an object extent to a sorted list of file extents.
*
* On success, the caller is responsible for:
*
* kfree(file_extents)
*/
int ceph_extent_to_file(struct ceph_file_layout *l,
u64 objno, u64 objoff, u64 objlen,
struct ceph_file_extent **file_extents,
u32 *num_file_extents)
{
u32 stripes_per_object = l->object_size / l->stripe_unit;
u64 blockno; /* which su */
Annotation
- Immediate include surface: `linux/ceph/ceph_debug.h`, `linux/math64.h`, `linux/slab.h`, `linux/ceph/striper.h`, `linux/ceph/types.h`.
- Detected declarations: `function ceph_calc_file_object_mapping`, `function objno`, `function list_for_each_prev`, `function lookup_containing`, `function list_for_each_entry`, `function one`, `function ceph_iterate_extents`, `function kfree`, `function ceph_get_num_objects`, `export ceph_calc_file_object_mapping`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
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.