Btree Items

From btrfs Wiki
Jump to: navigation, search

This table shows the mapping from the btree key type to the type of data stored against that key. In general, the btrfs_item_ptr() macro can be used to retrieve a properly-typed offset value for the data. The btrfs_datatype_membername() and btrfs_datatype_set_membername() functions can then be used to retrieve any data from the leaf/slot (which are themselves obtained from the struct path data returned from btrfs_search_slot()).

The "Tree(s)" column indicates which trees items of that type can appear in, and the objectid and offset columns document what the values in the objectid and offset fields should be for the key for this type of object.

Note: The information in this table is incomplete and has not yet been checked by someone who knows what they're doing.

Type name Value Data type Tree(s) objectid offset Notes
BTRFS_INODE_ITEM_KEY 1

struct btrfs_inode_item

root, fs, reloc, file inode number 0 Use btrfs_iget() and btrfs_iget_locked() to read the inode data as a struct inode.
BTRFS_INODE_REF_KEY 12

struct btrfs_inode_ref

root, fs, reloc, file inode number inode number of parent
BTRFS_INODE_EXTREF_KEY 13 struct btrfs_inode_extref inode number crc32c hash of filename, using inode number of parent as seed Used if the regarding inode_ref array ran out of space. Requires the EXTENDED_IREF feature.
BTRFS_XATTR_ITEM_KEY 24

struct btrfs_dir_item

file inode number of object crc32c hash of xattr name Embedded data in btrfs_dir_item is xattr value
BTRFS_ORPHAN_ITEM_KEY 48 - Doesn't map to a struct type.
BTRFS_DIR_LOG_ITEM_KEY 60 struct btrfs_dir_log_item
BTRFS_DIR_LOG_INDEX_KEY 72 (?)
BTRFS_DIR_ITEM_KEY 84

struct btrfs_dir_item

root, fs, file

inode number of directory crc32c hash of filename References an item in this directory
BTRFS_DIR_INDEX_KEY 96

struct btrfs_dir_item

fs, file

inode number of directory index of item References an item in this directory
BTRFS_EXTENT_DATA_KEY 108

struct btrfs_file_extent_item

file inode number offset within file
BTRFS_EXTENT_CSUM_KEY 128

struct btrfs_csum_item

checksum BTRFS_EXTENT_CSUM_OBJECTID == -10ULL address of start of data
BTRFS_ROOT_ITEM_KEY 132

struct btrfs_root_item (?)

root BTRFS_EXTENT_TREE_OBJECTID 0
BTRFS_DEV_TREE_OBJECTID 0
BTRFS_FS_TREE_OBJECTID 0 References the base fs tree
BTRFS_CSUM_TREE_OBJECTID 0
id number of subvolume generation of parent when created, or 0 if not a snapshot References a file tree
BTRFS_ROOT_BACKREF_KEY 144

struct btrfs_root_ref

root child subvolume id parent subvolume id
BTRFS_ROOT_REF_KEY 156

struct btrfs_root_ref

root parent subvolume id child subvolume id
BTRFS_EXTENT_ITEM_KEY 168

struct btrfs_extent_item

extent virtual address of extent size of extent
BTRFS_EXTENT_REF_V0_KEY 180 struct btrfs_extent_ref_v0
BTRFS_TREE_BLOCK_REF_KEY 176 - extent Not directly indexed

See struct btrfs_extent_item and struct btrfs_extent_inline_ref

BTRFS_EXTENT_DATA_REF_KEY 178
BTRFS_SHARED_BLOCK_REF_KEY 182
BTRFS_SHARED_DATA_REF_KEY 184
BTRFS_BLOCK_GROUP_ITEM_KEY 192

struct btrfs_block_group_item

extent address of start of group length of block group
BTRFS_DEV_EXTENT_KEY 204

struct btrfs_dev_extent

device device id location on device
BTRFS_DEV_ITEM_KEY 216

struct btrfs_dev_item

chunk BTRFS_DEV_ITEMS_OBJECTID == 1ULL device id
BTRFS_CHUNK_ITEM_KEY 228

struct btrfs_chunk

chunk tree id (currently always BTRFS_FIRST_CHUNK_TREE_OBJECTID == 256ULL) virtual address of chunk
BTRFS_STRING_ITEM_KEY 253 char[] (?) Any? string items are for debugging. They just store a short string of data in the FS
Personal tools