mirror of
git://sourceware.org/git/lvm2.git
synced 2025-06-24 19:16:58 +03:00
This commit adds lvresize/lvextend/lvreduce support for btrfs. 'btrfs filesystem resize [devid:][+/-]<newsize>[kKmMgGtTpPeE]|[devid:]max <path>' is used to resize one device only when it's mounted. The code pattern is like xfs but it supports shrink. For multi-devices btrfs, There is one difficulty to be handled: If `lvreduce --fs resize` is given, lvm2 will check newsize vs current fs size to judge if it's need to shrink fs or not. 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. There is no other way without relying btrfs superblock parse. It's too complicated and inproper to implemnt the logic in lvm2. So here just sets fs_last_byte to 0 for btrfs and skips boundary check in _fs_reduce_allow(). It's safe as btrfs will handle it well. The another complicated part is how to get mount point info if multi-devices. There is only one mnt entry per mounted fs in /etc/mtab even it's a multi-devices btrfs. So we first get uuid from lv device then traverse devices under /sys/fs/btrfs/$uuid/devices and compare them to the mnt entry to get the mount point. Signed-off-by: Su Yue <glass.su@suse.com>