From: Brian Foster <bfoster@redhat.com>
To: Ritesh Harjani <riteshh@linux.ibm.com>
Cc: fstests@vger.kernel.org, anju@linux.vnet.ibm.com,
Eryu Guan <guan@eryu.me>,
linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org,
linux-xfs@vger.kernel.org
Subject: Re: [PATCH 1/3] common/rc: Make swapon check in _require_scratch_swapfile() specific to btrfs
Date: Fri, 30 Oct 2020 09:18:29 -0400 [thread overview]
Message-ID: <20201030131829.GB1794672@bfoster> (raw)
In-Reply-To: <6070d16aab6a61bbbc988fc68cc727c21ec7baef.1604000570.git.riteshh@linux.ibm.com>
On Fri, Oct 30, 2020 at 01:22:51AM +0530, Ritesh Harjani wrote:
> swapon/off check in _require_scratch_swapfile() was specifically added
> for btrfs[1]/[2] since in previous kernels, swapfile was not supported on btrfs.
> This rather masks the issue sometimes with swapon system call in
> case if it fails.
> for e.g. in latest ext4 upstream tree when "-g quick" (which ran swap tests too)
> was tested, all swap tests resulted into "_notrun" since swapon failed
> inside _require_scratch_swapfile() itself.
> Whereas this failure on ext4 was actually due to a regression with latest
> fast-commit patch, which went un-noticed.
> Hence make this swapon/off check only specific to btrfs.
> Tested default config of xfs/btrfs/ext4/f2fs with this patch.
>
> With this change on buggy kernel, we could clearly catch the swap failures.
> e.g.
> generic/472 17s ...
> <...>
> @@ -1,4 +1,7 @@
> QA output created by 472
> regular swap
> +swapon: Invalid argument
> too long swap
> +swapon: Invalid argument
> tiny swap
> +swapon: Invalid argument
> ...
> (Run 'diff -u /home/qemu/src/tools-work/xfstests-dev/tests/generic/472.out \
> /home/qemu/src/tools-work/xfstests-dev/results//ext4/generic/472.out.bad' \
> to see the entire diff)
>
> [1]: 8c96cfbfe530 ("generic/35[67]: disable swapfile tests on Btrfs")
> [2]: bd6d67ee598e ("generic: enable swapfile tests on Btrfs")
>
> Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
> ---
> common/rc | 18 ++++++++++--------
> 1 file changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/common/rc b/common/rc
> index b0c353c4c107..4c59968a6bd3 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -2358,18 +2358,20 @@ _require_scratch_swapfile()
> [ -n "$SELINUX_MOUNT_OPTIONS" ] && export \
> SELINUX_MOUNT_OPTIONS="-o context=system_u:object_r:swapfile_t:s0"
>
> - _scratch_mount
> + if [ "$FSTYP" = "btrfs" ]; then
> + _scratch_mount
> +
> + # Minimum size for mkswap is 10 pages
> + _format_swapfile "$SCRATCH_MNT/swap" $(($(get_page_size) * 10))
>
> - # 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
>
> - if ! swapon "$SCRATCH_MNT/swap" >/dev/null 2>&1; then
> + swapoff "$SCRATCH_MNT/swap" >/dev/null 2>&1
> _scratch_unmount
> - _notrun "swapfiles are not supported"
> fi
> -
> - swapoff "$SCRATCH_MNT/swap" >/dev/null 2>&1
> - _scratch_unmount
> }
This factors out the majority of this function for !btrfs cases to the
point where it doesn't do anything swap related. Perhaps it would be
more clear to do something like '[ $FSTYP = "btrfs" ] &&
_require_scratch_swapfile()' in the actual tests that require filtering
out on btrfs..?
Brian
>
> # Check that a fs has enough free space (in 1024b blocks)
> --
> 2.26.2
>
next prev parent reply other threads:[~2020-10-30 13:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-29 19:52 [PATCH 0/3] fstests: Fix tests which checks for swapfile support Ritesh Harjani
2020-10-29 19:52 ` [PATCH 1/3] common/rc: Make swapon check in _require_scratch_swapfile() specific to btrfs Ritesh Harjani
2020-10-30 13:18 ` Brian Foster [this message]
2020-10-29 19:52 ` [PATCH 2/3] shared/001: Verify swapon on fallocated files for supported FS Ritesh Harjani
2020-10-30 13:19 ` Brian Foster
2020-10-29 19:52 ` [PATCH 3/3] common/rc: source common/xfs and common/btrfs Ritesh Harjani
2020-10-29 21:04 ` Darrick J. Wong
2020-11-01 16:03 ` [PATCH 0/3] fstests: Fix tests which checks for swapfile support Eryu Guan
2020-11-26 3:51 ` Ritesh Harjani
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=20201030131829.GB1794672@bfoster \
--to=bfoster@redhat.com \
--cc=anju@linux.vnet.ibm.com \
--cc=fstests@vger.kernel.org \
--cc=guan@eryu.me \
--cc=linux-btrfs@vger.kernel.org \
--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).