linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Ritesh Harjani <riteshh@linux.ibm.com>
Cc: fstests@vger.kernel.org, linux-xfs@vger.kernel.org,
	linux-ext4@vger.kernel.org, anju@linux.vnet.ibm.com,
	guan@eryu.me
Subject: Re: [PATCHv3 1/2] common/rc: swapon should not fail for given FS in _require_scratch_swapfile()
Date: Tue, 5 Jan 2021 11:04:53 -0800	[thread overview]
Message-ID: <20210105190453.GA6918@magnolia> (raw)
In-Reply-To: <aad3aeb9c717c76fc4e5fd124037da2510f51054.1609848797.git.riteshh@linux.ibm.com>

On Tue, Jan 05, 2021 at 08:01:42PM +0530, Ritesh Harjani wrote:
> Filesystems e.g. ext* and XFS supports swapon by default and an error
> returned with swapon should be treated as a failure.
> 
> Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
> v2 -> v3:
> 1. Removed whitelisted naming convention.
> 2. Added ext2/ext3 as well as supported FS for swapon.
> 3. Removed local variable $fstyp, instead used $FSTYP directly in switch case.
> 
>  common/rc | 20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/common/rc b/common/rc
> index 33b5b598a198..649b1cfd884a 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -2401,10 +2401,22 @@ _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
> +	# ext* and xfs have supported all variants of swap files since their
> +	# introduction, so swapon should not fail.
> +	case "$FSTYP" in
> +	ext2|ext3|ext4|xfs)
> +		if ! swapon "$SCRATCH_MNT/swap" >/dev/null 2>&1; then
> +			_scratch_unmount
> +			_fail "swapon failed for $FSTYP"
> +		fi
> +		;;
> +	*)
> +		if ! swapon "$SCRATCH_MNT/swap" >/dev/null 2>&1; then
> +			_scratch_unmount
> +			_notrun "swapfiles are not supported"
> +		fi
> +		;;
> +	esac
> 
>  	swapoff "$SCRATCH_MNT/swap" >/dev/null 2>&1
>  	_scratch_unmount
> --
> 2.26.2
> 

      parent reply	other threads:[~2021-01-05 19:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-05 14:31 [PATCHv3 1/2] common/rc: swapon should not fail for given FS in _require_scratch_swapfile() Ritesh Harjani
2021-01-05 14:31 ` [PATCHv3 2/2] generic/496: ext4 and xfs supports swapon on fallocated file Ritesh Harjani
2021-01-05 19:05   ` Darrick J. Wong
2021-01-05 19:04 ` Darrick J. Wong [this message]

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=20210105190453.GA6918@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=anju@linux.vnet.ibm.com \
    --cc=fstests@vger.kernel.org \
    --cc=guan@eryu.me \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=riteshh@linux.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).