From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E108C433F5 for ; Sun, 7 Nov 2021 13:14:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 74F4C613B1 for ; Sun, 7 Nov 2021 13:14:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232341AbhKGNRa (ORCPT ); Sun, 7 Nov 2021 08:17:30 -0500 Received: from out20-50.mail.aliyun.com ([115.124.20.50]:55931 "EHLO out20-50.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231136AbhKGNR3 (ORCPT ); Sun, 7 Nov 2021 08:17:29 -0500 X-Alimail-AntiSpam: AC=CONTINUE;BC=0.08580297|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_alarm|0.0796134-0.00282019-0.917566;FP=0|0|0|0|0|-1|-1|-1;HT=ay29a033018047188;MF=guan@eryu.me;NM=1;PH=DS;RN=2;RT=2;SR=0;TI=SMTPD_---.LosbhEQ_1636290885; Received: from localhost(mailfrom:guan@eryu.me fp:SMTPD_---.LosbhEQ_1636290885) by smtp.aliyun-inc.com(10.147.44.129); Sun, 07 Nov 2021 21:14:45 +0800 Date: Sun, 7 Nov 2021 21:14:44 +0800 From: Eryu Guan To: Carlos Maiolino Cc: fstests@vger.kernel.org Subject: Re: [PATCH 1/2] common/rc: Enable _format_swapfile to return the swap size Message-ID: References: <20211102152828.26895-1-cmaiolino@redhat.com> <20211102152828.26895-2-cmaiolino@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211102152828.26895-2-cmaiolino@redhat.com> Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org On Tue, Nov 02, 2021 at 04:28:27PM +0100, Carlos Maiolino wrote: > Once the kernel is free to not map the full swap file during a swapon call, > it can be useful to know the exact size of the swap area created during > _format_swapfile(). > > To achieve this, it is required to change _require_scratch_swapfile(), to drop > the _format_swapfile() return value, otherwise, it will also have a return value > that will end up in tests outputs causing tests to fail. > > Tests using _format_swapfile() that do not require the swap file size do not > need to be modified, as the return value will be simply ignored. > > Signed-off-by: Carlos Maiolino > --- > common/rc | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/common/rc b/common/rc > index 7f693d39..fb1f32e0 100644 > --- a/common/rc > +++ b/common/rc > @@ -2587,6 +2587,7 @@ _require_odirect() > _format_swapfile() { > local fname="$1" > local sz="$2" > + local swap_log="" > > rm -f "$fname" > touch "$fname" > @@ -2595,8 +2596,11 @@ _format_swapfile() { > $CHATTR_PROG +C "$fname" > /dev/null 2>&1 > _pwrite_byte 0x61 0 "$sz" "$fname" >> $seqres.full > # Ignore permission complaints on filesystems that don't support perms > - $MKSWAP_PROG "$fname" 2>&1 >> $seqres.full | \ > - grep -v "insecure permission" > + swap_log=$($MKSWAP_PROG "$fname" 2>&1 | grep -v "insecure permission") > + echo $swap_log >> $seqres.full > + > + # return created swap size > + echo $swap_log | grep -oP '(?<=size = )\w+' It's now returning the size of the swap space, it'd be better to add some comments before the helper to describe/explain the behavior. Thanks, Eryu > } > > _swapon_file() { > @@ -2628,7 +2632,7 @@ _require_scratch_swapfile() > _scratch_mount > > # Minimum size for mkswap is 10 pages > - _format_swapfile "$SCRATCH_MNT/swap" $(($(get_page_size) * 10)) > + _format_swapfile "$SCRATCH_MNT/swap" $(($(get_page_size) * 10)) > /dev/null > > # ext* has supported all variants of swap files since their > # introduction, so swapon should not fail. > -- > 2.31.1