From c1a28a6e3a9492d8e19f51e3d65e66acfcc8c9ad Mon Sep 17 00:00:00 2001 From: Xiao Yang Date: Thu, 6 Aug 2020 10:13:35 +0800 Subject: [PATCH] common/rc: Introduce helpers for new dax mount options and FS_XFLAG_DAX 1) _check_scratch_dax_mountopt() checks old/new dax mount option and returns a value. 2) _require_scratch_dax_mountopt() throws notrun if _check_scratch_dax_mountopt() returns a non-zero value. 3) _require_dax_iflag() checks FS_XFLAG_DAX. Signed-off-by: Xiao Yang Reviewed-by: Darrick J. Wong Signed-off-by: Eryu Guan --- common/rc | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/common/rc b/common/rc index 1b7b2575..fa70453d 100644 --- a/common/rc +++ b/common/rc @@ -3188,6 +3188,58 @@ _require_scratch_dax() _scratch_unmount } +# Check if dax mount options are supported +# +# $1 can be either 'dax=always' or 'dax' +# +# dax=always +# Check for the new dax options (dax=inode, dax=always or dax=never) +# by passing "dax=always". +# dax +# Check for the old dax or new dax=always by passing "dax". +# +# This only accepts 'dax=always' because dax=always, dax=inode and +# dax=never are always supported together. So if the other options are +# required checking for 'dax=always' indicates support for the other 2. +# +# Return 0 if filesystem/device supports the specified dax option. +# Return 1 if mount fails with the specified dax option. +# Return 2 if /proc/mounts shows wrong dax option. +_check_scratch_dax_mountopt() +{ + local option=$1 + + _require_scratch + _scratch_mkfs > /dev/null 2>&1 + + _try_scratch_mount "-o $option" > /dev/null 2>&1 || return 1 + + if _fs_options $SCRATCH_DEV | egrep -q "dax(=always|,|$)"; then + _scratch_unmount + return 0 + else + _scratch_unmount + return 2 + fi +} + +# Throw notrun if _check_scratch_dax_mountopt() returns a non-zero value. +_require_scratch_dax_mountopt() +{ + local mountopt=$1 + + _check_scratch_dax_mountopt "$mountopt" + local res=$? + + [ $res -eq 1 ] && _notrun "mount $SCRATCH_DEV with $mountopt failed" + [ $res -eq 2 ] && _notrun "$SCRATCH_DEV $FSTYP does not support -o $mountopt" +} + +_require_dax_iflag() +{ + _require_xfs_io_command "chattr" "x" +} + # Does norecovery support by this fs? _require_norecovery() { -- 2.30.2