fs/btrfs/tests/extent-io-tests.c
Source file repositories/reference/linux-study-clean/fs/btrfs/tests/extent-io-tests.c
File Facts
- System
- Linux kernel
- Corpus path
fs/btrfs/tests/extent-io-tests.c- Extension
.c- Size
- 21947 bytes
- Lines
- 831
- 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.
- 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/pagemap.hlinux/folio_batch.hlinux/sched.hlinux/slab.hlinux/sizes.hbtrfs-tests.h../ctree.h../extent_io.h../disk-io.h../btrfs_inode.h
Detected Declarations
function Copyrightfunction extent_flag_to_strfunction dump_extent_io_treefunction test_find_delallocfunction check_eb_bitmapfunction test_bitmap_setfunction test_bitmap_clearfunction __test_eb_bitmapsfunction test_eb_bitmapsfunction test_find_first_clear_extent_bitfunction dump_eb_and_memory_contentsfunction verify_eb_and_memoryfunction init_eb_and_memoryfunction test_eb_mem_opsfunction btrfs_test_extent_io
Annotated Snippet
if (loops > 100000) {
printk(KERN_ERR
"stuck in a loop, start %llu, end %llu, ret %d\n",
start, end, ret);
break;
}
}
return count;
}
#define STATE_FLAG_STR_LEN 256
#define PRINT_ONE_FLAG(state, dest, cur, name) \
({ \
if (state->state & EXTENT_##name) \
cur += scnprintf(dest + cur, STATE_FLAG_STR_LEN - cur, \
"%s" #name, cur == 0 ? "" : "|"); \
})
static void extent_flag_to_str(const struct extent_state *state, char *dest)
{
int cur = 0;
dest[0] = 0;
PRINT_ONE_FLAG(state, dest, cur, DIRTY);
PRINT_ONE_FLAG(state, dest, cur, LOCKED);
PRINT_ONE_FLAG(state, dest, cur, DIRTY_LOG1);
PRINT_ONE_FLAG(state, dest, cur, DIRTY_LOG2);
PRINT_ONE_FLAG(state, dest, cur, DELALLOC);
PRINT_ONE_FLAG(state, dest, cur, DEFRAG);
PRINT_ONE_FLAG(state, dest, cur, BOUNDARY);
PRINT_ONE_FLAG(state, dest, cur, NODATASUM);
PRINT_ONE_FLAG(state, dest, cur, CLEAR_META_RESV);
PRINT_ONE_FLAG(state, dest, cur, NEED_WAIT);
PRINT_ONE_FLAG(state, dest, cur, NORESERVE);
PRINT_ONE_FLAG(state, dest, cur, QGROUP_RESERVED);
PRINT_ONE_FLAG(state, dest, cur, CLEAR_DATA_RESV);
}
static void dump_extent_io_tree(const struct extent_io_tree *tree)
{
struct rb_node *node;
char flags_str[STATE_FLAG_STR_LEN];
node = rb_first(&tree->state);
test_msg("io tree content:");
while (node) {
struct extent_state *state;
state = rb_entry(node, struct extent_state, rb_node);
extent_flag_to_str(state, flags_str);
test_msg(" start=%llu len=%llu flags=%s", state->start,
state->end + 1 - state->start, flags_str);
node = rb_next(node);
}
}
static int test_find_delalloc(u32 sectorsize, u32 nodesize)
{
struct btrfs_fs_info *fs_info;
struct btrfs_root *root = NULL;
struct inode *inode = NULL;
struct extent_io_tree *tmp;
struct page *page;
struct page *locked_page = NULL;
/* In this test we need at least 2 file extents at its maximum size */
u64 max_bytes = BTRFS_MAX_EXTENT_SIZE;
u64 total_dirty = 2 * max_bytes;
u64 start, end, test_start;
bool found;
int ret = -EINVAL;
test_msg("running find delalloc tests");
fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize);
if (!fs_info) {
test_std_err(TEST_ALLOC_FS_INFO);
return -ENOMEM;
}
root = btrfs_alloc_dummy_root(fs_info);
if (IS_ERR(root)) {
test_std_err(TEST_ALLOC_ROOT);
ret = PTR_ERR(root);
goto out;
}
inode = btrfs_new_test_inode();
if (!inode) {
Annotation
- Immediate include surface: `linux/pagemap.h`, `linux/folio_batch.h`, `linux/sched.h`, `linux/slab.h`, `linux/sizes.h`, `btrfs-tests.h`, `../ctree.h`, `../extent_io.h`.
- Detected declarations: `function Copyright`, `function extent_flag_to_str`, `function dump_extent_io_tree`, `function test_find_delalloc`, `function check_eb_bitmap`, `function test_bitmap_set`, `function test_bitmap_clear`, `function __test_eb_bitmaps`, `function test_eb_bitmaps`, `function test_find_first_clear_extent_bit`.
- 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.