fs/btrfs/tests/raid-stripe-tree-tests.c
Source file repositories/reference/linux-study-clean/fs/btrfs/tests/raid-stripe-tree-tests.c
File Facts
- System
- Linux kernel
- Corpus path
fs/btrfs/tests/raid-stripe-tree-tests.c- Extension
.c- Size
- 29013 bytes
- Lines
- 1162
- 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/sizes.h../fs.h../disk-io.h../transaction.h../volumes.h../raid-stripe-tree.hbtrfs-tests.h
Detected Declarations
function list_for_each_entryfunction test_punch_hole_3extentsfunction test_delete_two_extentsfunction test_punch_holefunction test_front_delete_prev_itemfunction test_front_deletefunction test_tail_deletefunction btrfs_insert_one_raid_extentfunction test_simple_create_deletefunction run_testfunction btrfs_test_raid_stripe_tree
Annotated Snippet
if (!stripe->dev) {
test_err("cannot find device with devid %d", i);
ret = -EINVAL;
goto out;
}
stripe->physical = logical1 + i * SZ_1G;
}
ret = btrfs_insert_one_raid_extent(trans, bioc);
if (ret) {
test_err("inserting RAID extent failed: %d", ret);
goto out;
}
bioc->logical = logical2;
bioc->size = len2;
for (int i = 0; i < RST_TEST_NUM_DEVICES; i++) {
struct btrfs_io_stripe *stripe = &bioc->stripes[i];
stripe->dev = btrfs_device_by_devid(fs_info->fs_devices, i);
if (!stripe->dev) {
test_err("cannot find device with devid %d", i);
ret = -EINVAL;
goto out;
}
stripe->physical = logical2 + i * SZ_1G;
}
ret = btrfs_insert_one_raid_extent(trans, bioc);
if (ret) {
test_err("inserting RAID extent failed: %d", ret);
goto out;
}
bioc->logical = logical3;
bioc->size = len3;
for (int i = 0; i < RST_TEST_NUM_DEVICES; i++) {
struct btrfs_io_stripe *stripe = &bioc->stripes[i];
stripe->dev = btrfs_device_by_devid(fs_info->fs_devices, i);
if (!stripe->dev) {
test_err("cannot find device with devid %d", i);
ret = -EINVAL;
goto out;
}
stripe->physical = logical3 + i * SZ_1G;
}
ret = btrfs_insert_one_raid_extent(trans, bioc);
if (ret) {
test_err("inserting RAID extent failed: %d", ret);
goto out;
}
/*
* Delete a range starting at logical1 + 256K and 2M in length. Extent
* 1 is truncated to 256k length, extent 2 is completely dropped and
* extent 3 is moved 256K to the right.
*/
ret = btrfs_delete_raid_extent(trans, hole_start, hole_len);
if (ret) {
test_err("deleting RAID extent [%llu, %llu] failed",
hole_start, hole_start + hole_len);
goto out;
}
/* Get the first extent and check its size. */
ret = btrfs_get_raid_extent_offset(fs_info, logical1, &len1, map_type,
0, &io_stripe);
if (ret) {
test_err("lookup of RAID extent [%llu, %llu] failed",
logical1, logical1 + len1);
goto out;
}
if (io_stripe.physical != logical1) {
test_err("invalid physical address, expected %llu, got %llu",
logical1, io_stripe.physical);
ret = -EINVAL;
goto out;
}
if (len1 != SZ_256K) {
test_err("invalid stripe length, expected %llu, got %llu",
(u64)SZ_256K, len1);
ret = -EINVAL;
goto out;
Annotation
- Immediate include surface: `linux/sizes.h`, `../fs.h`, `../disk-io.h`, `../transaction.h`, `../volumes.h`, `../raid-stripe-tree.h`, `btrfs-tests.h`.
- Detected declarations: `function list_for_each_entry`, `function test_punch_hole_3extents`, `function test_delete_two_extents`, `function test_punch_hole`, `function test_front_delete_prev_item`, `function test_front_delete`, `function test_tail_delete`, `function btrfs_insert_one_raid_extent`, `function test_simple_create_delete`, `function run_test`.
- 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.