Re: Request for comments about support btrfs in lvresize

David Teigland <[email protected]> Mon, 10 Mar 2025 11:24:54 -0500
Newsgroups dev.linux.lists.lvm-devel
Message-ID <[email protected]>
On Mon, Mar 10, 2025 at 04:35:54PM +0800, Glass Su wrote:
> Hi
>  I am drafting patches for btrfs support in lvresize command. All things went smoothly until I realized
> multi-devices btrfs handling is a little complicated.

btrfs using multiple devices sounds like an alternative to putting btrfs
on lvm, so is this actually done?

> For one device btrfs, fslastblock * fsblocksize/FSSIZE is the correct value like ext* and xfs
> But for multi-devices btrfs, the two values are whole fs size. The used size of device can be
> known by btrfs-progs or superblock read and parse.

These values are used to calculate fs_last_byte, and that is used:

- by lvextend as a sanity check after the fs resize is done.  So, it could
  be made optional for lvextend.

- by lvreduce to check if the fs has already been sufficiently shrunk, so
  the fs shrink command can be skipped.  Perhaps for btrfs, always require
  the fs shrink command to be run, and always make fs_last_byte large enough
  to do that.

Dave