All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Theodore Ts'o" <tytso@mit.edu>
To: fstests@vger.kernel.org
Cc: guaneryu@gmail.com, "Theodore Ts'o" <tytso@mit.edu>
Subject: [PATCH] common/rc: teach _require_scratch_swapfile() that swap does not work with DAX
Date: Sun, 18 Apr 2021 12:19:25 -0400	[thread overview]
Message-ID: <20210418161925.240995-1-tytso@mit.edu> (raw)

The statement, "ext* and xfs have supported all variants of swap files
since their introduction, so swapon should not fail," is not quite
completely true.  In particular, swapon does not work if the DAX is
active on a swapfile, and that would be true if the file system is
mounted with -o dax.

So if swapon fails, check to see if the swapfile has the
STATX_ATTR_DAX attribute set, and if so, issue a _notrun instead of a
_fail.

Fixes: 725feeff94cc ("common/rc: swapon should not fail for given FS in _require_scratch_swapfile()")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
 common/rc | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/common/rc b/common/rc
index 0f91340f..d2fd5c5c 100644
--- a/common/rc
+++ b/common/rc
@@ -2495,8 +2495,17 @@ _require_scratch_swapfile()
 	case "$FSTYP" in
 	ext2|ext3|ext4|xfs)
 		if ! swapon "$SCRATCH_MNT/swap" >/dev/null 2>&1; then
+			local attributes=$($XFS_IO_PROG -c 'statx -r' \
+					"$SCRATCH_MNT/swap" 2>/dev/null | \
+					awk '/stat.attributes / { print $3 }')
 			_scratch_unmount
-			_fail "swapon failed for $FSTYP"
+			if test -n "$attributes" -a \
+				$((attributes & 0x00200000)) -eq $((0x00200000)) ;
+			then
+			    _notrun "DAX swapfiles are not supported"
+			else
+			    _fail "swapon failed for $FSTYP"
+			fi
 		fi
 		;;
 	*)
-- 
2.31.0


             reply	other threads:[~2021-04-18 16:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-18 16:19 Theodore Ts'o [this message]
2021-04-20  6:25 ` [PATCH] common/rc: teach _require_scratch_swapfile() that swap does not work with DAX Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210418161925.240995-1-tytso@mit.edu \
    --to=tytso@mit.edu \
    --cc=fstests@vger.kernel.org \
    --cc=guaneryu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.