fs/btrfs/tests/extent-buffer-tests.c
Source file repositories/reference/linux-study-clean/fs/btrfs/tests/extent-buffer-tests.c
File Facts
- System
- Linux kernel
- Corpus path
fs/btrfs/tests/extent-buffer-tests.c- Extension
.c- Size
- 5424 bytes
- Lines
- 224
- 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/slab.hbtrfs-tests.h../ctree.h../extent_io.h../disk-io.h../accessors.h
Detected Declarations
function Copyrightfunction btrfs_test_extent_buffer_operations
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2013 Fusion IO. All rights reserved.
*/
#include <linux/slab.h>
#include "btrfs-tests.h"
#include "../ctree.h"
#include "../extent_io.h"
#include "../disk-io.h"
#include "../accessors.h"
static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
{
struct btrfs_fs_info *fs_info;
struct btrfs_path *path = NULL;
struct btrfs_root *root = NULL;
struct extent_buffer *eb;
char *value = "mary had a little lamb";
char *split1 = "mary had a little";
char *split2 = " lamb";
char *split3 = "mary";
char *split4 = " had a little";
char buf[32];
struct btrfs_key key;
u32 value_len = strlen(value);
int ret = 0;
test_msg("running btrfs_split_item 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;
}
path = btrfs_alloc_path();
if (!path) {
test_std_err(TEST_ALLOC_PATH);
ret = -ENOMEM;
goto out;
}
eb = alloc_dummy_extent_buffer(fs_info, nodesize);
path->nodes[0] = eb;
if (!eb) {
test_std_err(TEST_ALLOC_EXTENT_BUFFER);
ret = -ENOMEM;
goto out;
}
path->slots[0] = 0;
key.objectid = 0;
key.type = BTRFS_EXTENT_CSUM_KEY;
key.offset = 0;
/*
* Passing a NULL trans handle is fine here, we have a dummy root eb
* and the tree is a single node (level 0).
*/
btrfs_setup_item_for_insert(NULL, root, path, &key, value_len);
write_extent_buffer(eb, value, btrfs_item_ptr_offset(eb, 0),
value_len);
key.offset = 3;
/*
* Passing NULL trans here should be safe because we have plenty of
* space in this leaf to split the item without having to split the
* leaf.
*/
ret = btrfs_split_item(NULL, root, path, &key, 17);
if (ret) {
test_err("split item failed %d", ret);
goto out;
}
/*
* Read the first slot, it should have the original key and contain only
* 'mary had a little'
*/
btrfs_item_key_to_cpu(eb, &key, 0);
if (key.objectid != 0 || key.type != BTRFS_EXTENT_CSUM_KEY ||
Annotation
- Immediate include surface: `linux/slab.h`, `btrfs-tests.h`, `../ctree.h`, `../extent_io.h`, `../disk-io.h`, `../accessors.h`.
- Detected declarations: `function Copyright`, `function btrfs_test_extent_buffer_operations`.
- 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.