drivers/md/persistent-data/dm-btree-remove.c
Source file repositories/reference/linux-study-clean/drivers/md/persistent-data/dm-btree-remove.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/persistent-data/dm-btree-remove.c- Extension
.c- Size
- 19134 bytes
- Lines
- 774
- Domain
- Driver Families
- Bucket
- drivers/md
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
dm-btree.hdm-btree-internal.hdm-transaction-manager.hlinux/export.hlinux/device-mapper.h
Detected Declarations
struct childfunction Copyrightfunction node_copyfunction delete_atfunction merge_thresholdfunction init_childfunction exit_childfunction shiftfunction __rebalance2function rebalance2function delete_center_nodefunction redistribute3function __rebalance3function rebalance3function rebalance_childrenfunction do_leaffunction delete_atfunction dm_btree_removefunction remove_nearestfunction remove_onefunction dm_btree_remove_leavesexport dm_btree_removeexport dm_btree_remove_leaves
Annotated Snippet
struct child {
unsigned int index;
struct dm_block *block;
struct btree_node *n;
};
static int init_child(struct dm_btree_info *info, struct dm_btree_value_type *vt,
struct btree_node *parent,
unsigned int index, struct child *result)
{
int r, inc;
dm_block_t root;
result->index = index;
root = value64(parent, index);
r = dm_tm_shadow_block(info->tm, root, &btree_node_validator,
&result->block, &inc);
if (r)
return r;
result->n = dm_block_data(result->block);
if (inc)
inc_children(info->tm, result->n, vt);
*((__le64 *) value_ptr(parent, index)) =
cpu_to_le64(dm_block_location(result->block));
return 0;
}
static void exit_child(struct dm_btree_info *info, struct child *c)
{
dm_tm_unlock(info->tm, c->block);
}
static int shift(struct btree_node *left, struct btree_node *right, int count)
{
int r;
uint32_t nr_left = le32_to_cpu(left->header.nr_entries);
uint32_t nr_right = le32_to_cpu(right->header.nr_entries);
uint32_t max_entries = le32_to_cpu(left->header.max_entries);
uint32_t r_max_entries = le32_to_cpu(right->header.max_entries);
if (max_entries != r_max_entries) {
DMERR("node max_entries mismatch");
return -EILSEQ;
}
if (nr_left - count > max_entries) {
DMERR("node shift out of bounds");
return -EINVAL;
}
if (nr_right + count > max_entries) {
DMERR("node shift out of bounds");
return -EINVAL;
}
if (!count)
return 0;
if (count > 0) {
node_shift(right, count);
r = node_copy(left, right, count);
if (r)
return r;
} else {
r = node_copy(left, right, count);
if (r)
return r;
node_shift(right, count);
}
left->header.nr_entries = cpu_to_le32(nr_left - count);
right->header.nr_entries = cpu_to_le32(nr_right + count);
return 0;
}
static int __rebalance2(struct dm_btree_info *info, struct btree_node *parent,
struct child *l, struct child *r)
{
int ret;
struct btree_node *left = l->n;
struct btree_node *right = r->n;
uint32_t nr_left = le32_to_cpu(left->header.nr_entries);
uint32_t nr_right = le32_to_cpu(right->header.nr_entries);
/*
Annotation
- Immediate include surface: `dm-btree.h`, `dm-btree-internal.h`, `dm-transaction-manager.h`, `linux/export.h`, `linux/device-mapper.h`.
- Detected declarations: `struct child`, `function Copyright`, `function node_copy`, `function delete_at`, `function merge_threshold`, `function init_child`, `function exit_child`, `function shift`, `function __rebalance2`, `function rebalance2`.
- Atlas domain: Driver Families / drivers/md.
- 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.