Skip to main content

device_min_size

Function device_min_size 

Source
pub fn device_min_size(fd: BorrowedFd<'_>, devid: u64) -> Result<u64>
Expand description

Compute the minimum size to which device devid can be shrunk.

Walks the device tree for all DEV_EXTENT_KEY items belonging to devid, sums their lengths, then adjusts for extents that sit beyond the sum by checking whether they can be relocated into holes closer to the start of the device. The algorithm matches btrfs inspect-internal min-dev-size from btrfs-progs.

Requires CAP_SYS_ADMIN.

ยงErrors

Returns Err if the tree search ioctl fails.