fs/btrfs/raid-stripe-tree.c
Source file repositories/reference/linux-study-clean/fs/btrfs/raid-stripe-tree.c
File Facts
- System
- Linux kernel
- Corpus path
fs/btrfs/raid-stripe-tree.c- Extension
.c- Size
- 13102 bytes
- Lines
- 506
- 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/btrfs_tree.hctree.hfs.haccessors.htransaction.hdisk-io.hraid-stripe-tree.hvolumes.hprint-tree.h
Detected Declarations
function Copyrightfunction btrfs_delete_raid_extentfunction update_raid_extent_itemfunction btrfs_insert_one_raid_extentfunction btrfs_insert_raid_extentfunction list_for_each_entryfunction btrfs_get_raid_extent_offset
Annotated Snippet
if (path->slots[0] == 0) {
/* No entry with objectid <= start exists. */
ret = 0;
break;
}
path->slots[0]--;
leaf = path->nodes[0];
slot = path->slots[0];
btrfs_item_key_to_cpu(leaf, &key, slot);
found_start = key.objectid;
found_end = found_start + key.offset;
ret = 0;
/*
* The stripe extent starts before the range we want to delete,
* but the range spans more than one stripe extent:
*
* |--- RAID Stripe Extent ---||--- RAID Stripe Extent ---|
* |--- keep ---|--- drop ---|
*
* This means we have to get the previous item, truncate its
* length and then restart the search.
*/
if (found_start > start) {
if (slot == 0) {
ret = btrfs_previous_item(stripe_root, path, 0,
BTRFS_RAID_STRIPE_KEY);
if (ret) {
if (ret > 0)
ret = -ENOENT;
break;
}
} else {
path->slots[0]--;
}
leaf = path->nodes[0];
slot = path->slots[0];
btrfs_item_key_to_cpu(leaf, &key, slot);
found_start = key.objectid;
found_end = found_start + key.offset;
if (found_start > start || found_end <= start) {
ret = -ENOENT;
break;
}
}
if (key.type != BTRFS_RAID_STRIPE_KEY)
break;
/* That stripe ends before we start, we're done. */
if (found_end <= start)
break;
trace_btrfs_raid_extent_delete(fs_info, start, end,
found_start, found_end);
/*
* The stripe extent starts before the range we want to delete
* and ends after the range we want to delete, i.e. we're
* punching a hole in the stripe extent:
*
* |--- RAID Stripe Extent ---|
* | keep |--- drop ---| keep |
*
* This means we need to a) truncate the existing item and b)
* create a second item for the remaining range.
*/
if (found_start < start && found_end > end) {
size_t item_size;
u64 diff_start = start - found_start;
u64 diff_end = found_end - end;
struct btrfs_stripe_extent *extent;
struct btrfs_key newkey = {
.objectid = end,
.type = BTRFS_RAID_STRIPE_KEY,
.offset = diff_end,
};
/* The "right" item. */
ret = btrfs_duplicate_item(trans, stripe_root, path, &newkey);
if (ret == -EAGAIN) {
btrfs_release_path(path);
continue;
}
if (ret)
break;
/*
Annotation
- Immediate include surface: `linux/btrfs_tree.h`, `ctree.h`, `fs.h`, `accessors.h`, `transaction.h`, `disk-io.h`, `raid-stripe-tree.h`, `volumes.h`.
- Detected declarations: `function Copyright`, `function btrfs_delete_raid_extent`, `function update_raid_extent_item`, `function btrfs_insert_one_raid_extent`, `function btrfs_insert_raid_extent`, `function list_for_each_entry`, `function btrfs_get_raid_extent_offset`.
- 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.