fs/btrfs/print-tree.c
Source file repositories/reference/linux-study-clean/fs/btrfs/print-tree.c
File Facts
- System
- Linux kernel
- Corpus path
fs/btrfs/print-tree.c- Extension
.c- Size
- 20665 bytes
- Lines
- 640
- 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
messages.hctree.hdisk-io.hfile-item.hprint-tree.haccessors.htree-checker.hvolumes.hraid-stripe-tree.h
Detected Declarations
struct root_name_mapfunction print_chunkfunction print_dev_itemfunction print_extent_data_reffunction print_extent_owner_reffunction print_extent_itemfunction print_uuid_itemfunction print_raid_stripe_keyfunction print_eb_refs_lockfunction print_timespecfunction print_inode_itemfunction print_dir_itemfunction print_inode_ref_itemfunction print_inode_extref_itemfunction print_dir_log_index_itemfunction print_extent_csumfunction print_file_extent_itemfunction key_type_stringfunction btrfs_print_leaffunction btrfs_print_tree
Annotated Snippet
struct root_name_map {
u64 id;
const char *name;
};
static const struct root_name_map root_map[] = {
{ BTRFS_ROOT_TREE_OBJECTID, "ROOT_TREE" },
{ BTRFS_EXTENT_TREE_OBJECTID, "EXTENT_TREE" },
{ BTRFS_CHUNK_TREE_OBJECTID, "CHUNK_TREE" },
{ BTRFS_DEV_TREE_OBJECTID, "DEV_TREE" },
{ BTRFS_FS_TREE_OBJECTID, "FS_TREE" },
{ BTRFS_CSUM_TREE_OBJECTID, "CSUM_TREE" },
{ BTRFS_TREE_LOG_OBJECTID, "TREE_LOG" },
{ BTRFS_QUOTA_TREE_OBJECTID, "QUOTA_TREE" },
{ BTRFS_UUID_TREE_OBJECTID, "UUID_TREE" },
{ BTRFS_FREE_SPACE_TREE_OBJECTID, "FREE_SPACE_TREE" },
{ BTRFS_BLOCK_GROUP_TREE_OBJECTID, "BLOCK_GROUP_TREE" },
{ BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" },
{ BTRFS_RAID_STRIPE_TREE_OBJECTID, "RAID_STRIPE_TREE" },
{ BTRFS_REMAP_TREE_OBJECTID, "REMAP_TREE" },
};
const char *btrfs_root_name(const struct btrfs_key *key, char *buf)
{
int i;
if (key->objectid == BTRFS_TREE_RELOC_OBJECTID) {
snprintf(buf, BTRFS_ROOT_NAME_BUF_LEN,
"TREE_RELOC offset=%llu", key->offset);
return buf;
}
for (i = 0; i < ARRAY_SIZE(root_map); i++) {
if (root_map[i].id == key->objectid)
return root_map[i].name;
}
snprintf(buf, BTRFS_ROOT_NAME_BUF_LEN, "%llu", key->objectid);
return buf;
}
static void print_chunk(const struct extent_buffer *eb, struct btrfs_chunk *chunk)
{
int num_stripes = btrfs_chunk_num_stripes(eb, chunk);
int i;
pr_info("\t\tchunk length %llu owner %llu type %llu num_stripes %d\n",
btrfs_chunk_length(eb, chunk), btrfs_chunk_owner(eb, chunk),
btrfs_chunk_type(eb, chunk), num_stripes);
for (i = 0 ; i < num_stripes ; i++) {
pr_info("\t\t\tstripe %d devid %llu offset %llu\n", i,
btrfs_stripe_devid_nr(eb, chunk, i),
btrfs_stripe_offset_nr(eb, chunk, i));
}
}
static void print_dev_item(const struct extent_buffer *eb,
struct btrfs_dev_item *dev_item)
{
pr_info("\t\tdev item devid %llu total_bytes %llu bytes used %llu\n",
btrfs_device_id(eb, dev_item),
btrfs_device_total_bytes(eb, dev_item),
btrfs_device_bytes_used(eb, dev_item));
}
static void print_extent_data_ref(const struct extent_buffer *eb,
struct btrfs_extent_data_ref *ref)
{
pr_cont("extent data backref root %llu objectid %llu offset %llu count %u\n",
btrfs_extent_data_ref_root(eb, ref),
btrfs_extent_data_ref_objectid(eb, ref),
btrfs_extent_data_ref_offset(eb, ref),
btrfs_extent_data_ref_count(eb, ref));
}
static void print_extent_owner_ref(const struct extent_buffer *eb,
const struct btrfs_extent_owner_ref *ref)
{
ASSERT(btrfs_fs_incompat(eb->fs_info, SIMPLE_QUOTA));
pr_cont("extent data owner root %llu\n", btrfs_extent_owner_ref_root_id(eb, ref));
}
static void print_extent_item(const struct extent_buffer *eb, int slot, int type)
{
struct btrfs_extent_item *ei;
struct btrfs_extent_inline_ref *iref;
struct btrfs_extent_data_ref *dref;
struct btrfs_shared_data_ref *sref;
struct btrfs_extent_owner_ref *oref;
struct btrfs_disk_key key;
unsigned long end;
unsigned long ptr;
u32 item_size = btrfs_item_size(eb, slot);
Annotation
- Immediate include surface: `messages.h`, `ctree.h`, `disk-io.h`, `file-item.h`, `print-tree.h`, `accessors.h`, `tree-checker.h`, `volumes.h`.
- Detected declarations: `struct root_name_map`, `function print_chunk`, `function print_dev_item`, `function print_extent_data_ref`, `function print_extent_owner_ref`, `function print_extent_item`, `function print_uuid_item`, `function print_raid_stripe_key`, `function print_eb_refs_lock`, `function print_timespec`.
- 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.