diff mbox series

[2/3] rc: check dax mode in _require_scratch_swapfile

Message ID 161958298115.3452499.907986597475080875.stgit@magnolia (mailing list archive)
State New, archived
Headers show
Series fstests: fix swapfile tests | expand

Commit Message

Darrick J. Wong April 28, 2021, 4:09 a.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

It turns out that the mm refuses to swapon() files that don't have a
a_ops->readpage function, because it wants to be able to read the swap
header.  S_DAX files don't have a readpage function (though oddly both
ext4 and xfs link to a swapfile activation function in their aops) so
they fail.  The recent commit 725feeff changed this from a _notrun to
_fail on xfs and ext4, so amend this not to fail on pmem test setups.

Fixes: 725feeff ("common/rc: swapon should not fail for given FS in _require_scratch_swapfile()")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 common/rc |    4 ++++
 1 file changed, 4 insertions(+)

Comments

Darrick J. Wong April 28, 2021, 4:11 a.m. UTC | #1
On Tue, Apr 27, 2021 at 09:09:41PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> It turns out that the mm refuses to swapon() files that don't have a
> a_ops->readpage function, because it wants to be able to read the swap
> header.  S_DAX files don't have a readpage function (though oddly both
> ext4 and xfs link to a swapfile activation function in their aops) so
> they fail.  The recent commit 725feeff changed this from a _notrun to
> _fail on xfs and ext4, so amend this not to fail on pmem test setups.
> 
> Fixes: 725feeff ("common/rc: swapon should not fail for given FS in _require_scratch_swapfile()")
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>

Note that XiaoLi Feng's patch "common/rc: not run swapfile test for
DAX" is perfectly adequate too, and that patch was sent first.

--D

> ---
>  common/rc |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> 
> diff --git a/common/rc b/common/rc
> index 6752c92d..429cc24d 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -2490,6 +2490,10 @@ _require_scratch_swapfile()
>  	# Minimum size for mkswap is 10 pages
>  	_format_swapfile "$SCRATCH_MNT/swap" $(($(get_page_size) * 10))
>  
> +	# swapfiles cannot use cpu direct access mode (STATX_ATTR_DAX) for now
> +	statx_attr="$($XFS_IO_PROG -c 'statx -r' $SCRATCH_MNT/swap 2>/dev/null | grep 'stat.attributes = ' | awk '{print $3}')"
> +	test "$((statx_attr & 0x200000))" -gt 0 && _notrun "swapfiles not supported on DAX"
> +
>  	# ext* and xfs have supported all variants of swap files since their
>  	# introduction, so swapon should not fail.
>  	case "$FSTYP" in
>
Brian Foster April 28, 2021, 6:04 p.m. UTC | #2
On Tue, Apr 27, 2021 at 09:09:41PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> It turns out that the mm refuses to swapon() files that don't have a
> a_ops->readpage function, because it wants to be able to read the swap
> header.  S_DAX files don't have a readpage function (though oddly both
> ext4 and xfs link to a swapfile activation function in their aops) so
> they fail.  The recent commit 725feeff changed this from a _notrun to
> _fail on xfs and ext4, so amend this not to fail on pmem test setups.
> 
> Fixes: 725feeff ("common/rc: swapon should not fail for given FS in _require_scratch_swapfile()")
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  common/rc |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> 
> diff --git a/common/rc b/common/rc
> index 6752c92d..429cc24d 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -2490,6 +2490,10 @@ _require_scratch_swapfile()
>  	# Minimum size for mkswap is 10 pages
>  	_format_swapfile "$SCRATCH_MNT/swap" $(($(get_page_size) * 10))
>  
> +	# swapfiles cannot use cpu direct access mode (STATX_ATTR_DAX) for now
> +	statx_attr="$($XFS_IO_PROG -c 'statx -r' $SCRATCH_MNT/swap 2>/dev/null | grep 'stat.attributes = ' | awk '{print $3}')"
> +	test "$((statx_attr & 0x200000))" -gt 0 && _notrun "swapfiles not supported on DAX"
> +
>  	# ext* and xfs have supported all variants of swap files since their
>  	# introduction, so swapon should not fail.
>  	case "$FSTYP" in
>
diff mbox series

Patch

diff --git a/common/rc b/common/rc
index 6752c92d..429cc24d 100644
--- a/common/rc
+++ b/common/rc
@@ -2490,6 +2490,10 @@  _require_scratch_swapfile()
 	# Minimum size for mkswap is 10 pages
 	_format_swapfile "$SCRATCH_MNT/swap" $(($(get_page_size) * 10))
 
+	# swapfiles cannot use cpu direct access mode (STATX_ATTR_DAX) for now
+	statx_attr="$($XFS_IO_PROG -c 'statx -r' $SCRATCH_MNT/swap 2>/dev/null | grep 'stat.attributes = ' | awk '{print $3}')"
+	test "$((statx_attr & 0x200000))" -gt 0 && _notrun "swapfiles not supported on DAX"
+
 	# ext* and xfs have supported all variants of swap files since their
 	# introduction, so swapon should not fail.
 	case "$FSTYP" in