Skip to main content

Crate btrfs_transaction

Crate btrfs_transaction 

Source
Expand description

§Userspace transaction infrastructure for btrfs

This crate provides the write-path infrastructure needed to modify btrfs filesystems from userspace. It builds on btrfs-disk (the read path) and adds mutable tree blocks, B-tree search, copy-on-write, item insertion / deletion / split / balance, transaction commit, extent allocation, free-space tree maintenance, and a layer of high-level helpers (file data, inodes, dir entries, xattrs, subvolume creation, device-size patches).

§Entry points

From there, Transaction::start opens a transaction; mutations go through search::search_slot + items::insert_item / items::del_items / items::update_item for raw access, or through the Transaction helpers (create_inode, link_dir_entry, set_xattr, write_file_data, create_empty_tree, insert_root_ref, reserve_data_extent, etc.) for higher-level patterns. Transaction::commit closes out the transaction; Transaction::abort discards it.

Whole-tree conversion paths (convert::convert_to_free_space_tree, convert::convert_to_block_group_tree, plus the per-step convert::seed_free_space_tree and convert::create_block_group_tree helpers) live in the convert module.

This is a clean-room implementation based on the on-disk format specification and UAPI headers. It is licensed MIT/Apache-2.0.

§Stability

This is a pre-1.0, experimental crate. It is a clean-room reimplementation of btrfs’s read-write tree machinery and may have edge cases that testing doesn’t cover. Do not use it on filesystems you care about without taking a backup first.

Re-exports§

pub use crate::filesystem::Filesystem;
pub use crate::transaction::Transaction;

Modules§

allocation
Extent allocation and freeing
balance
Node balancing
buffer
Mutable tree block wrapper
convert
Whole-tree conversion operations
cow
Copy-on-write block duplication
delayed_ref
Batched reference count updates
extent_walk
Read-only extent-tree walker for whole-tree conversions
filesystem
In-memory filesystem state for a transaction session
free_space
Free space tree range tracking and apply
inode
Inode item construction
items
Leaf item insert, delete, and update operations
path
B-tree search path
search
B-tree search operations
split
Node and leaf splitting
transaction
Transaction lifecycle: start, commit, abort