Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp3573997pxb; Mon, 21 Feb 2022 00:45:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJwL9f3lrICxIKjTitbwYRHG7p+dpGBiWDedZbVyDjHXzvpfIUu/B3nljtHQHftGEzneobxY X-Received: by 2002:a63:5911:0:b0:36c:4394:5bfa with SMTP id n17-20020a635911000000b0036c43945bfamr15114434pgb.519.1645433125849; Mon, 21 Feb 2022 00:45:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645433125; cv=none; d=google.com; s=arc-20160816; b=kUOEgDHtCrLq5a7x099IEYFaVgHLVPShup3wHe02hylINOyTkTSrm6TJ0VN1V1sTuz ZMdl74f8UZr0D2uHqLymoN3LbefRepsY5evE+OHUFBfERE1LDSrUBh4SopSX43759X9n jN18898QShtJ4cOPCxwwXKCGTIfzllWRv08uPrcq3wSXoMRJXpvFJwxmTH4WmbnT/EZw dUebhZCCoUbzSOhSgjV136wcuN8PyX5LenS9Eyg8h2xAF2jJx/hOz6NtwtvPTdCMzSWY HB8mgALBSslDgJ/MNK2oUMzf+jsfat/VropKheL1Xe7W+IwRA6qG88YBVs8EbyZdn2f0 ZeWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=DkSUd8kIccOzDJ8DZ4uB2FrHQbXS74dUitlE7dmSMhs=; b=h0+5d/PmOiwhbhDZVhC4fs/bdbF0ggn1djQX5782iwK78V6y9ND6XL7LSkCUOCsUVC wog9fjEI/ZvhsYaXY6+952hrK+H1t1+KQH5sjKfzEWmiOmpo1v8+bhyEx9NbNeDWSimE ypfqNVa9Cy30w8aQmpdyzb/6oATjNcji2JGmQLY+9B72hly5mOUXuFeROkLmeW4RcoBy c31R9HtOaBIlkxbp9tJ+N15hWSJGWvIjZSnbIhV7QPfbvZayDv5nljc9EtaFOjWJ5CMt eEBoZtbTWjfL5ofhu9Lcm8/kwEzFeZjwI2L2XkUBRW1iFM8kJfeQ2ZuV0WWGrPJFluHz +HFA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i13si33593915plr.502.2022.02.21.00.45.07; Mon, 21 Feb 2022 00:45:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241203AbiBTQZW (ORCPT + 99 others); Sun, 20 Feb 2022 11:25:22 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:54308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239743AbiBTQZW (ORCPT ); Sun, 20 Feb 2022 11:25:22 -0500 Received: from out20-97.mail.aliyun.com (out20-97.mail.aliyun.com [115.124.20.97]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C1E03466C; Sun, 20 Feb 2022 08:24:59 -0800 (PST) X-Alimail-AntiSpam: AC=CONTINUE;BC=0.07436842|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_system_inform|0.0362374-0.00153733-0.962225;FP=0|0|0|0|0|-1|-1|-1;HT=ay29a033018047212;MF=guan@eryu.me;NM=1;PH=DS;RN=4;RT=4;SR=0;TI=SMTPD_---.MsqFXXe_1645374297; Received: from localhost(mailfrom:guan@eryu.me fp:SMTPD_---.MsqFXXe_1645374297) by smtp.aliyun-inc.com(10.147.44.129); Mon, 21 Feb 2022 00:24:57 +0800 Date: Mon, 21 Feb 2022 00:24:56 +0800 From: Eryu Guan To: Ojaswin Mujoo Cc: fstests@vger.kernel.org, linux-ext4@vger.kernel.org, riteshh@linux.ibm.com Subject: Re: [PATCH 2/2] ext4: Test to ensure resize with sparse_super2 is handled correctly Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon, Feb 07, 2022 at 01:55:34PM +0530, Ojaswin Mujoo wrote: > Kernel currently doesn't support resize of EXT4 mounted > with sparse_super2 option enabled. Earlier, it used to leave the resize > incomplete and the fs would be left in an inconsistent state, however commit > b1489186cc83[1] fixed this to avoid the fs corruption by clearly returning > -ENOTSUPP. > > Test to ensure that kernel handles resizing with sparse_super2 correctly. Run > resize for multiple iterations because this leads to kernel crash due to > fs corruption, which we want to detect. > > Related commit in mainline: > > [1] commit b1489186cc8391e0c1e342f9fbc3eedf6b944c61 > > ext4: add check to prevent attempting to resize an fs with sparse_super2 > > Signed-off-by: Ojaswin Mujoo > --- > tests/ext4/056 | 102 +++++++++++++++++++++++++++++++++++++++++++++ > tests/ext4/056.out | 2 + > 2 files changed, 104 insertions(+) > create mode 100755 tests/ext4/056 > create mode 100644 tests/ext4/056.out > > diff --git a/tests/ext4/056 b/tests/ext4/056 > new file mode 100755 > index 00000000..9185621d > --- /dev/null > +++ b/tests/ext4/056 > @@ -0,0 +1,102 @@ > +#! /bin/bash > +# SPDX-License-Identifier: GPL-2.0 > +# Copyright (c) 2022 IBM. All Rights Reserved. > +# > +# We don't currently support resize of EXT4 filesystems mounted > +# with sparse_super2 option enabled. Earlier, kernel used to leave the resize > +# incomplete and the fs would be left into an incomplete state, however commit > +# b1489186cc83 fixed this to avoid the fs corruption by clearly returning > +# -ENOTSUPP. > +# > +# This test ensures that kernel handles resizing with sparse_super2 correctly > +# > +# Related commit in mainline: > +# > +# commit b1489186cc8391e0c1e342f9fbc3eedf6b944c61 > +# ext4: add check to prevent attempting to resize an fs with sparse_super2 > +# > + > +. ./common/preamble > +_begin_fstest auto ioctl resize quick > + > +# real QA test starts here > + > +INITIAL_FS_SIZE=1G > +RESIZED_FS_SIZE=$((2*1024*1024*1024)) # 2G > +ONLINE_RESIZE_BLOCK_LIMIT=$((256*1024*1024)) > + > +_supported_fs ext4 > +_require_scratch_size $(($RESIZED_FS_SIZE/1024)) > +_require_test_program "ext4_resize" > + > +_log() > +{ > + echo "$seq: $*" >> $seqres.full 2>&1 > +} Leading under score is used for common functions, local functions don't need it. > + > +do_resize() > +{ > + > + $MKFS_PROG `_scratch_mkfs_options -t ext4 -E resize=$ONLINE_RESIZE_BLOCK_LIMIT \ > + -O sparse_super2` $INITIAL_FS_SIZE >> $seqres.full 2>&1 \ > + || _fail "$MKFS_PROG failed. Exiting" I think we could use _mkfs_dev here. > + > + _scratch_mount || _fail "Failed to mount scratch partition. Exiting" > + > + BS=$(_get_block_size $SCRATCH_MNT) > + NEW_BLOCKS=$(($RESIZED_FS_SIZE/$BS)) > + > + local RESIZE_RET > + local EOPNOTSUPP=95 > + > + $here/src/ext4_resize $SCRATCH_MNT $NEW_BLOCKS >> $seqres.full 2>&1 > + RESIZE_RET=$? > + > + # Use $RESIZE_RET for logging > + if [ $RESIZE_RET = 0 ] > + then > + _log "Resizing succeeded but FS might still be corrupt." I don't think _log is needed here, just echo message to stdout and this will break golden image and fail the test. > + elif [ $RESIZE_RET = $EOPNOTSUPP ] > + then > + _log "Resize operation not supported with sparse_super2" > + _log "Threw expected error $RESIZE_RET (EOPNOTSUPP)" > + > + else > + _log "Output of resize = $RESIZE_RET. Expected $EOPNOTSUPP (EOPNOTSUPP)" > + _log "You might be missing kernel patch b1489186cc83" > + fi > + > + # unount after ioctl sometimes fails with "device busy" so add a small delay > + sleep 0.1 > + > + _scratch_unmount >> $seqres.full 2>&1 || _fail "$UMOUNT_PROG failed. Exiting" > +} > + > +run_test() > +{ > + local FSCK_RET > + local ITERS=8 > + > + for i in $(seq 1 $ITERS) > + do > + _log "----------- Iteration: $i ------------" > + do_resize > + done > + > + _log "-------- Iterations Complete ---------" > + _log "Checking if FS is in consistent state" > + _check_scratch_fs > + FSCK_RET=$? > + > + return $FSCK_RET > +} > + > +run_test > +status=$? > + > +if [ "$status" -eq "0" ] > +then > + echo "Test Succeeded!" | tee -a $seqres.full > +fi This is not needed, just echo "Silence is golden" at the beginning of the test, so any additional output will fail the test. Thanks, Eryu > + > +exit > diff --git a/tests/ext4/056.out b/tests/ext4/056.out > new file mode 100644 > index 00000000..41706284 > --- /dev/null > +++ b/tests/ext4/056.out > @@ -0,0 +1,2 @@ > +QA output created by 056 > +Test Succeeded! > -- > 2.27.0