common/rc: not run swapfile test for DAX
authorXiaoli Feng <xifeng@redhat.com>
Sat, 24 Apr 2021 16:15:23 +0000 (00:15 +0800)
committerEryu Guan <guaneryu@gmail.com>
Sun, 9 May 2021 15:10:48 +0000 (23:10 +0800)
DAX doesn't support swapfile. Without this patch,
_require_scratch_swapfile always returns fail for fsdax. Now
change to notrun.

Fixes: 725feeff ("common/rc: swapon should not fail for given FS in _require_scratch_swapfile()")
Signed-off-by: Xiaoli Feng <xifeng@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
common/rc

index 8e20749e45077a64293e76d24addd6a5cfb9a6da..e53d1569eef732d8db9f0b45e0a3c636e1a253d7 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -2539,8 +2539,13 @@ _require_scratch_swapfile()
        case "$FSTYP" in
        ext2|ext3|ext4)
                if ! swapon "$SCRATCH_MNT/swap" >/dev/null 2>&1; then
        case "$FSTYP" in
        ext2|ext3|ext4)
                if ! swapon "$SCRATCH_MNT/swap" >/dev/null 2>&1; then
-                       _scratch_unmount
-                       _fail "swapon failed for $FSTYP"
+                       if _check_s_dax "$SCRATCH_MNT/swap" 1 >/dev/null; then
+                               _scratch_unmount
+                               _notrun "swapfiles are not supported"
+                       else
+                               _scratch_unmount
+                               _fail "swapon failed for $FSTYP"
+                       fi
                fi
                ;;
        *)
                fi
                ;;
        *)
@@ -3404,6 +3409,7 @@ _check_s_dax()
 {
        local target=$1
        local exp_s_dax=$2
 {
        local target=$1
        local exp_s_dax=$2
+       local ret=0
 
        local attributes=$($XFS_IO_PROG -c 'statx -r' $target | awk '/stat.attributes / { print $3 }')
 
 
        local attributes=$($XFS_IO_PROG -c 'statx -r' $target | awk '/stat.attributes / { print $3 }')
 
@@ -3424,10 +3430,17 @@ _check_s_dax()
        fi
 
        if [ $exp_s_dax -eq 0 ]; then
        fi
 
        if [ $exp_s_dax -eq 0 ]; then
-               (( attributes & 0x00200000 )) && echo "$target has unexpected S_DAX flag"
+               if (( attributes & 0x00200000 )); then
+                       echo "$target has unexpected S_DAX flag"
+                       ret=1
+               fi
        else
        else
-               (( attributes & 0x00200000 )) || echo "$target doesn't have expected S_DAX flag"
+               if ! (( attributes & 0x00200000 )); then
+                       echo "$target doesn't have expected S_DAX flag"
+                       ret=2
+               fi
        fi
        fi
+       return $ret
 }
 
 _check_xflag()
 }
 
 _check_xflag()