diff mbox series

[2/3] common/xfs: Add helpers to obtain reflink/rmapbt status of a filesystem

Message ID 20210726064313.19153-2-chandanrlinux@gmail.com (mailing list archive)
State New, archived
Headers show
Series [1/3] xfs/530: Do not pass block size argument to _scratch_mkfs | expand

Commit Message

Chandan Babu R July 26, 2021, 6:43 a.m. UTC
This commit adds helpers to obtain status of reflink and rmapbt features of a
filesystem. The status of these features are obtained by invoking
$XFS_INFO_PROG program.

Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
---
 common/xfs | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
diff mbox series

Patch

diff --git a/common/xfs b/common/xfs
index c5e39427..e9f84b56 100644
--- a/common/xfs
+++ b/common/xfs
@@ -1099,6 +1099,40 @@  _xfs_mount_agcount()
 	$XFS_INFO_PROG "$1" | grep agcount= | sed -e 's/^.*agcount=\([0-9]*\),.*$/\1/g'
 }
 
+# Get reflink status of a filesystem
+_xfs_is_reflink_enabled()
+{
+	local status
+
+	$XFS_INFO_PROG "$1" | grep -q reflink >> $seqres.full
+	[[ $? != 0 ]] && return 1
+
+	status=$($XFS_INFO_PROG "$1" | grep reflink= | \
+			 sed -e 's/^.*reflink=\([0-1]\).*$/\1/g')
+	if [[ $status == 1 ]]; then
+		return 0
+	else
+		return 1
+	fi
+}
+
+# Get rmapbt status of a filesystem
+_xfs_is_rmapbt_enabled()
+{
+	local status
+
+	$XFS_INFO_PROG "$1" | grep -q rmapbt >> $seqres.full
+	[[ $? != 0 ]] && return 1
+
+	status=$($XFS_INFO_PROG "$1" | grep rmapbt= | \
+			 sed -e 's/^.*rmapbt=\([0-1]\).*$/\1/g')
+	if [[ $status == 1 ]]; then
+		return 0
+	else
+		return 1
+	fi
+}
+
 # Wipe the superblock of each XFS AGs
 _try_wipe_scratch_xfs()
 {