diff options
author | Gao Xiang <hsiangkao@redhat.com> | 2021-05-12 07:32:26 +0800 |
---|---|---|
committer | Eryu Guan <guaneryu@gmail.com> | 2021-05-16 23:03:36 +0800 |
commit | 8a44508c507a2a04ea84f34b09e34aa45de20b56 (patch) | |
tree | cb0027a8408968a847105709f4dd4398c9cc7756 /common | |
parent | c4fa3c07679790ecafdb3cd0d6d05122ac52a090 (diff) |
common/xfs: add _require_scratch_xfs_shrink helper
In order to detect whether the current kernel supports XFS shrinking.
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Diffstat (limited to 'common')
-rw-r--r-- | common/xfs | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -786,6 +786,26 @@ _require_xfs_mkfs_without_validation() fi } +_require_scratch_xfs_shrink() +{ + _require_scratch + _require_command "$XFS_GROWFS_PROG" xfs_growfs + + _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs >/dev/null + . $tmp.mkfs + _scratch_mount + # here just to check if kernel supports, no need do more extra work + local errmsg=$($XFS_GROWFS_PROG -D$((dblocks-1)) "$SCRATCH_MNT" 2>&1) + if [ "$?" -ne 0 ]; then + echo "$errmsg" | grep 'XFS_IOC_FSGROWFSDATA xfsctl failed: Invalid argument' > /dev/null && \ + _notrun "kernel does not support shrinking" + echo "$errmsg" | grep 'data size .* too small, old size is ' > /dev/null && \ + _notrun "xfsprogs does not support shrinking" + _fail "$XFS_GROWFS_PROG failed unexpectedly: $errmsg" + fi + _scratch_unmount +} + # XFS ability to change UUIDs on V5/CRC filesystems # _require_meta_uuid() |