fs/btrfs/tests/chunk-allocation-tests.c
Source file repositories/reference/linux-study-clean/fs/btrfs/tests/chunk-allocation-tests.c
File Facts
- System
- Linux kernel
- Corpus path
fs/btrfs/tests/chunk-allocation-tests.c- Extension
.c- Size
- 11975 bytes
- Lines
- 477
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/sizes.hbtrfs-tests.h../volumes.h../disk-io.h../extent-io-tree.h
Detected Declarations
struct pending_extent_test_casestruct first_pending_test_casefunction test_find_hole_in_pendingfunction test_first_pending_extentfunction btrfs_test_chunk_allocation
Annotated Snippet
struct pending_extent_test_case {
const char *name;
/* Input range to search. */
u64 hole_start;
u64 hole_len;
/* The size of hole we are searching for. */
u64 min_hole_size;
/*
* Pending extents to set up (up to 2 for up to 3 holes)
* If len == 0, then it is skipped.
*/
struct {
u64 start;
u64 len;
} pending_extents[2];
/* Expected outputs. */
bool expected_found;
u64 expected_start;
u64 expected_len;
};
static const struct pending_extent_test_case find_hole_tests[] = {
{
.name = "no pending extents",
.hole_start = 0,
.hole_len = 10ULL * SZ_1G,
.min_hole_size = SZ_1G,
.pending_extents = { },
.expected_found = true,
.expected_start = 0,
.expected_len = 10ULL * SZ_1G,
},
{
.name = "pending extent at start of range",
.hole_start = 0,
.hole_len = 10ULL * SZ_1G,
.min_hole_size = SZ_1G,
.pending_extents = {
{ .start = 0, .len = SZ_1G },
},
.expected_found = true,
.expected_start = SZ_1G,
.expected_len = 9ULL * SZ_1G,
},
{
.name = "pending extent overlapping start of range",
.hole_start = SZ_1G,
.hole_len = 9ULL * SZ_1G,
.min_hole_size = SZ_1G,
.pending_extents = {
{ .start = 0, .len = SZ_2G },
},
.expected_found = true,
.expected_start = SZ_2G,
.expected_len = 8ULL * SZ_1G,
},
{
.name = "two holes; first hole is exactly big enough",
.hole_start = 0,
.hole_len = 10ULL * SZ_1G,
.min_hole_size = SZ_1G,
.pending_extents = {
{ .start = SZ_1G, .len = SZ_1G },
},
.expected_found = true,
.expected_start = 0,
.expected_len = SZ_1G,
},
{
.name = "two holes; first hole is big enough",
.hole_start = 0,
.hole_len = 10ULL * SZ_1G,
.min_hole_size = SZ_1G,
.pending_extents = {
{ .start = SZ_2G, .len = SZ_1G },
},
.expected_found = true,
.expected_start = 0,
.expected_len = SZ_2G,
},
{
.name = "two holes; second hole is big enough",
.hole_start = 0,
.hole_len = 10ULL * SZ_1G,
.min_hole_size = SZ_2G,
.pending_extents = {
{ .start = SZ_1G, .len = SZ_1G },
},
.expected_found = true,
.expected_start = SZ_2G,
Annotation
- Immediate include surface: `linux/sizes.h`, `btrfs-tests.h`, `../volumes.h`, `../disk-io.h`, `../extent-io-tree.h`.
- Detected declarations: `struct pending_extent_test_case`, `struct first_pending_test_case`, `function test_find_hole_in_pending`, `function test_first_pending_extent`, `function btrfs_test_chunk_allocation`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- 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.