fs/btrfs/tests/delayed-refs-tests.c
Source file repositories/reference/linux-study-clean/fs/btrfs/tests/delayed-refs-tests.c
File Facts
- System
- Linux kernel
- Corpus path
fs/btrfs/tests/delayed-refs-tests.c- Extension
.c- Size
- 25124 bytes
- Lines
- 1017
- 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.
- 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/sizes.hbtrfs-tests.h../transaction.h../delayed-ref.h../extent-tree.h
Detected Declarations
struct ref_head_checkstruct ref_node_checkfunction ref_type_from_disk_ref_typefunction delete_delayed_ref_headfunction delete_delayed_ref_nodefunction validate_ref_headfunction validate_ref_nodefunction simple_testfunction simple_testsfunction merge_testsfunction select_delayed_refs_testfunction btrfs_test_delayed_refs
Annotated Snippet
struct ref_head_check {
u64 bytenr;
u64 num_bytes;
int ref_mod;
int total_ref_mod;
int must_insert;
};
struct ref_node_check {
u64 bytenr;
u64 num_bytes;
int ref_mod;
enum btrfs_delayed_ref_action action;
u8 type;
u64 parent;
u64 root;
u64 owner;
u64 offset;
};
static enum btrfs_ref_type ref_type_from_disk_ref_type(u8 type)
{
if ((type == BTRFS_TREE_BLOCK_REF_KEY) ||
(type == BTRFS_SHARED_BLOCK_REF_KEY))
return BTRFS_REF_METADATA;
return BTRFS_REF_DATA;
}
static void delete_delayed_ref_head(struct btrfs_trans_handle *trans,
struct btrfs_delayed_ref_head *head)
{
struct btrfs_fs_info *fs_info = trans->fs_info;
struct btrfs_delayed_ref_root *delayed_refs =
&trans->transaction->delayed_refs;
spin_lock(&delayed_refs->lock);
spin_lock(&head->lock);
btrfs_delete_ref_head(fs_info, delayed_refs, head);
spin_unlock(&head->lock);
spin_unlock(&delayed_refs->lock);
btrfs_delayed_ref_unlock(head);
btrfs_put_delayed_ref_head(head);
}
static void delete_delayed_ref_node(struct btrfs_delayed_ref_head *head,
struct btrfs_delayed_ref_node *node)
{
rb_erase_cached(&node->ref_node, &head->ref_tree);
RB_CLEAR_NODE(&node->ref_node);
if (!list_empty(&node->add_list))
list_del_init(&node->add_list);
btrfs_put_delayed_ref(node);
}
static int validate_ref_head(struct btrfs_delayed_ref_head *head,
struct ref_head_check *check)
{
if (head->bytenr != check->bytenr) {
test_err("invalid bytenr have: %llu want: %llu", head->bytenr,
check->bytenr);
return -EINVAL;
}
if (head->num_bytes != check->num_bytes) {
test_err("invalid num_bytes have: %llu want: %llu",
head->num_bytes, check->num_bytes);
return -EINVAL;
}
if (head->ref_mod != check->ref_mod) {
test_err("invalid ref_mod have: %d want: %d", head->ref_mod,
check->ref_mod);
return -EINVAL;
}
if (head->total_ref_mod != check->total_ref_mod) {
test_err("invalid total_ref_mod have: %d want: %d",
head->total_ref_mod, check->total_ref_mod);
return -EINVAL;
}
if (head->must_insert_reserved != check->must_insert) {
test_err("invalid must_insert have: %d want: %d",
head->must_insert_reserved, check->must_insert);
return -EINVAL;
}
return 0;
}
Annotation
- Immediate include surface: `linux/sizes.h`, `btrfs-tests.h`, `../transaction.h`, `../delayed-ref.h`, `../extent-tree.h`.
- Detected declarations: `struct ref_head_check`, `struct ref_node_check`, `function ref_type_from_disk_ref_type`, `function delete_delayed_ref_head`, `function delete_delayed_ref_node`, `function validate_ref_head`, `function validate_ref_node`, `function simple_test`, `function simple_tests`, `function merge_tests`.
- 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.