fs/btrfs/tests/extent-map-tests.c
Source file repositories/reference/linux-study-clean/fs/btrfs/tests/extent-map-tests.c
File Facts
- System
- Linux kernel
- Corpus path
fs/btrfs/tests/extent-map-tests.c- Extension
.c- Size
- 29998 bytes
- Lines
- 1203
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hbtrfs-tests.h../ctree.h../btrfs_inode.h../volumes.h../disk-io.h../block-group.h
Detected Declarations
struct extent_rangestruct rmap_test_vectorfunction Copyrightfunction btrfs_get_extentfunction test_case_2function __test_case_3function cow_file_rangefunction __test_case_4function btrfs_get_blocks_directfunction add_compressed_extentfunction validate_rangefunction test_case_5function test_case_6function test_case_7function test_case_8function test_rmap_blockfunction btrfs_test_extent_map
Annotated Snippet
struct extent_range {
u64 start;
u64 len;
};
/* The valid states of the tree after every drop, as described below. */
struct extent_range valid_ranges[][7] = {
{
{ .start = 0, .len = SZ_8K }, /* [0, 8K) */
{ .start = SZ_4K * 3, .len = SZ_4K * 3}, /* [12k, 24k) */
{ .start = SZ_4K * 6, .len = SZ_4K * 3}, /* [24k, 36k) */
{ .start = SZ_32K + SZ_4K, .len = SZ_4K}, /* [36k, 40k) */
{ .start = SZ_4K * 10, .len = SZ_4K * 6}, /* [40k, 64k) */
},
{
{ .start = 0, .len = SZ_8K }, /* [0, 8K) */
{ .start = SZ_4K * 5, .len = SZ_4K}, /* [20k, 24k) */
{ .start = SZ_4K * 6, .len = SZ_4K * 3}, /* [24k, 36k) */
{ .start = SZ_32K + SZ_4K, .len = SZ_4K}, /* [36k, 40k) */
{ .start = SZ_4K * 10, .len = SZ_4K * 6}, /* [40k, 64k) */
},
{
{ .start = 0, .len = SZ_8K }, /* [0, 8K) */
{ .start = SZ_4K * 5, .len = SZ_4K}, /* [20k, 24k) */
{ .start = SZ_4K * 6, .len = SZ_4K}, /* [24k, 28k) */
{ .start = SZ_32K, .len = SZ_4K}, /* [32k, 36k) */
{ .start = SZ_32K + SZ_4K, .len = SZ_4K}, /* [36k, 40k) */
{ .start = SZ_4K * 10, .len = SZ_4K * 6}, /* [40k, 64k) */
},
{
{ .start = 0, .len = SZ_8K}, /* [0, 8K) */
{ .start = SZ_4K * 5, .len = SZ_4K}, /* [20k, 24k) */
{ .start = SZ_4K * 6, .len = SZ_4K}, /* [24k, 28k) */
}
};
static int validate_range(struct extent_map_tree *em_tree, int index)
{
struct rb_node *n;
int i;
for (i = 0, n = rb_first(&em_tree->root);
valid_ranges[index][i].len && n;
i++, n = rb_next(n)) {
struct extent_map *entry = rb_entry(n, struct extent_map, rb_node);
if (entry->start != valid_ranges[index][i].start) {
test_err("mapping has start %llu expected %llu",
entry->start, valid_ranges[index][i].start);
return -EINVAL;
}
if (entry->len != valid_ranges[index][i].len) {
test_err("mapping has len %llu expected %llu",
entry->len, valid_ranges[index][i].len);
return -EINVAL;
}
}
/*
* We exited because we don't have any more entries in the extent_map
* but we still expect more valid entries.
*/
if (valid_ranges[index][i].len) {
test_err("missing an entry");
return -EINVAL;
}
/* We exited the loop but still have entries in the extent map. */
if (n) {
test_err("we have a left over entry in the extent map we didn't expect");
return -EINVAL;
}
return 0;
}
/*
* Test scenario:
*
* Test the various edge cases of btrfs_drop_extent_map_range, create the
* following ranges
*
* [0, 12k)[12k, 24k)[24k, 36k)[36k, 40k)[40k,64k)
*
* And then we'll drop:
*
* [8k, 12k) - test the single front split
* [12k, 20k) - test the single back split
* [28k, 32k) - test the double split
Annotation
- Immediate include surface: `linux/types.h`, `btrfs-tests.h`, `../ctree.h`, `../btrfs_inode.h`, `../volumes.h`, `../disk-io.h`, `../block-group.h`.
- Detected declarations: `struct extent_range`, `struct rmap_test_vector`, `function Copyright`, `function btrfs_get_extent`, `function test_case_2`, `function __test_case_3`, `function cow_file_range`, `function __test_case_4`, `function btrfs_get_blocks_direct`, `function add_compressed_extent`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source 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.