Thread (6 messages) 6 messages, 3 authors, 2021-01-05

Re: [PATCHv2 1/2] common/rc: Add whitelisted FS support in _require_scratch_swapfile()

From: Ritesh Harjani <hidden>
Date: 2021-01-05 11:02:09
Also in: fstests, linux-xfs


On 1/4/21 11:55 PM, Darrick J. Wong wrote:
On Sun, Dec 20, 2020 at 11:39:06PM +0800, Eryu Guan wrote:
quoted
On Wed, Dec 16, 2020 at 10:53:45AM +0530, Ritesh Harjani wrote:
quoted

On 12/16/20 10:47 AM, Ritesh Harjani wrote:
quoted
Filesystems e.g. ext4 and XFS supports swapon by default and an error
returned with swapon should be treated as a failure. Hence
add ext4/xfs as whitelisted fstype in _require_scratch_swapfile()

Signed-off-by: Ritesh Harjani <redacted>
---
v1->v2: Addressed comments from Eryu @[1]
[1]: https://patchwork.kernel.org/project/fstests/cover/cover.1604000570.git.riteshh@linux.ibm.com/

   common/rc | 20 ++++++++++++++++----
   1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/common/rc b/common/rc
index 33b5b598a198..635b77a005c6 100644
--- a/common/rc
+++ b/common/rc
@@ -2380,6 +2380,7 @@ _format_swapfile() {
   # Check that the filesystem supports swapfiles
   _require_scratch_swapfile()
   {
+	local fstyp=$FSTYP
   	_require_scratch
   	_require_command "$MKSWAP_PROG" "mkswap"
@@ -2401,10 +2402,21 @@ _require_scratch_swapfile()
   	# Minimum size for mkswap is 10 pages
   	_format_swapfile "$SCRATCH_MNT/swap" $(($(get_page_size) * 10))

-	if ! swapon "$SCRATCH_MNT/swap" >/dev/null 2>&1; then
-		_scratch_unmount
-		_notrun "swapfiles are not supported"
-	fi
+	# For whitelisted fstyp swapon should not fail.
I would use a different phase than 'whitelisted', since that doesn't
tell us why ext4 and xfs are special:

# ext* and xfs have supported all variants of swap files since their
# introduction, so swapon should not fail.
Sounds ok to me.

quoted
quoted
quoted
+	case "$fstyp" in
$FSTYP, not $fstyp
sure I will use $FSTYP directly and remove local fstyp variable.
quoted
quoted
quoted
+	ext4|xfs)
I would also add a few more FSTYPs here, since at least ext2 and ext3
supported swap files.  Are there other old fses that do?
Sure, agreed. I will add ext2 & ext3 too.

-ritesh
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help