From patchwork Tue Oct 15 02:51:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13835678 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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1C77FD18140 for ; Tue, 15 Oct 2024 02:51:38 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1t0Xer-0001LT-1s; Tue, 15 Oct 2024 02:51:37 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1t0Xeq-0001LN-KA for linux-f2fs-devel@lists.sourceforge.net; Tue, 15 Oct 2024 02:51:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=F9vvfiRhFIKosxiwU/M/GsNupjwEdFIKnkbfgTGBwC4=; b=Guo4R3Goce6Aq8UQxfjSfDqksu uuPANbRvtYmg3tYQxU/BMEwRHVkfO1AXumiGg94ZG1g9DPfgK8ViQyeMJhRLsC36z2OUoSQE4dYTe MebvkL+6mWdkHU/3nMzVF7rSY/j+EnfRGg0wfObMKEKWQjte+Zw5y4L8ZbaqHZ+VitrQ=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=F9vvfiRhFIKosxiwU/M/GsNupjwEdFIKnkbfgTGBwC4=; b=h ioZWU/j7BtpKhYaaKwpv/lIVdZ1G4HSEfjPSQ2zTsUQxFWoOedvEm+w/cOtc0WKdbpDV1mngS0DYY MIfSxOIpY6qaEvbLdnjdHhwGag1N51A4nJneqqHz42Wk2tKIjmXh+MgLxL8FSHgmieJIT8ZzYuSMf ZFsPEgfQaKkgcP3Y=; Received: from nyc.source.kernel.org ([147.75.193.91]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1t0Xep-0005Xe-Ss for linux-f2fs-devel@lists.sourceforge.net; Tue, 15 Oct 2024 02:51:36 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 49A9DA401B5; Tue, 15 Oct 2024 02:51:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7875AC4CEC3; Tue, 15 Oct 2024 02:51:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728960689; bh=Tk/AWN8N3hXZ7c5itZX1115sbx+Ry+VXv7ESB2Mj4wc=; h=From:To:Cc:Subject:Date:From; b=NuIsZsQiZCXwAyDb3AbPU44TCnAKmuX3wW86P4efeHQpjgjV9o6LAKfzNuUjE4F7z /EO9uSYMD2ux0xpQmNv1QmMiMsFJlX9pvtoVRiVXriler7UlH8WYUnW5IPycUnTb+q sgjehBdMNK4qoejxuNi/UvNTraagbbzsPxqviKtp4L+hELS08nEa4HNSEKlYIDnLtp BMrgUgMftgUccpBlWkA8ejjzLxDQJ2UMo1L0uDI5D3ynEsFXpk9408bR/axSPY45R7 n9kZAd/Ff6FbUPlweBBgytjejQRN/rrSk5W+NYgEksLVbcLxgxRZjJUYGvfxmTpmRY tN7HOOqxUqvnQ== To: Zorro Lang Date: Tue, 15 Oct 2024 10:51:05 +0800 Message-Id: <20241015025106.3203676-1-chao@kernel.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Headers-End: 1t0Xep-0005Xe-Ss Subject: [f2fs-dev] [PATCH 1/2] f2fs/006: add testcase to check out-of-space case X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Chao Yu via Linux-f2fs-devel From: Chao Yu Reply-To: Chao Yu Cc: Jaegeuk Kim , fstests@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net This is a regression test to check whether f2fs handles dirty data correctly when checkpoint is disabled, if lfs mode is on, it will trigger OPU for all overwritten data, this will cost free segments, so f2fs must account overwritten data as OPU data when calculating free space, otherwise, it may run out of free segments in f2fs' allocation function, resulting in panic. Cc: Jaegeuk Kim Signed-off-by: Chao Yu --- tests/f2fs/006 | 52 ++++++++++++++++++++++++++++++++++++++++++++++ tests/f2fs/006.out | 6 ++++++ 2 files changed, 58 insertions(+) create mode 100755 tests/f2fs/006 create mode 100644 tests/f2fs/006.out diff --git a/tests/f2fs/006 b/tests/f2fs/006 new file mode 100755 index 00000000..b359ef8f --- /dev/null +++ b/tests/f2fs/006 @@ -0,0 +1,52 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024 Oppo. All Rights Reserved. +# +# FS QA Test No. f2fs/006 +# +# This is a regression test to check whether f2fs handles dirty +# data correctly when checkpoint is disabled, if lfs mode is on, +# it will trigger OPU for all overwritten data, this will cost +# free segments, so f2fs must account overwritten data as OPU +# data when calculating free space, otherwise, it may run out +# of free segments in f2fs' allocation function, resulting in +# panic. +# +. ./common/preamble +_begin_fstest auto quick + +_cleanup() +{ + rm -f $img + _scratch_unmount >> $seqres.full + cd / + rm -r -f $tmp.* +} + +_require_scratch +_scratch_mkfs >> $seqres.full +_scratch_mount >> $seqres.full + +img=$SCRATCH_MNT/f2fs.img +mnt=$SCRATCH_MNT/f2fs.mnt +testfile=$mnt/testfile + +mkdir $mnt +dd if=/dev/zero of=$img bs=1M count=100 2>/dev/null +$MKFS_F2FS_PROG -f $img >/dev/null 2>&1 +sync + +# use mode=lfs to let f2fs always triggers OPU +mount -t $FSTYP -o loop,mode=lfs,checkpoint=disable:10%,noinline_dentry $img $mnt + +dd if=/dev/zero of=$testfile bs=1M count=50 2>/dev/null + +# it may run out of free space of f2fs and hang kernel +dd if=/dev/zero of=$testfile bs=1M count=50 conv=notrunc conv=fsync +dd if=/dev/zero of=$testfile bs=1M count=50 conv=notrunc conv=fsync + +mount -o remount,checkpoint=enable $mnt +umount $mnt + +status=0 +exit diff --git a/tests/f2fs/006.out b/tests/f2fs/006.out new file mode 100644 index 00000000..a2c7ba48 --- /dev/null +++ b/tests/f2fs/006.out @@ -0,0 +1,6 @@ +QA output created by 006 +50+0 records in +50+0 records out +dd: error writing '/mnt/scratch_f2fs/f2fs.mnt/testfile': No space left on device +3+0 records in +2+0 records out From patchwork Tue Oct 15 02:51:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13835679 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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 62967CFC501 for ; Tue, 15 Oct 2024 02:51:46 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1t0Xez-0001Ey-7b; Tue, 15 Oct 2024 02:51:45 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1t0Xew-0001Ep-Uo for linux-f2fs-devel@lists.sourceforge.net; Tue, 15 Oct 2024 02:51:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=pxiCCsuULI1JZG2LQOHaVzXh1g2r8v2g2qYcx6Ge6nM=; b=a/ue2XOyN2CI62bii7Zz5E21Rk Ienv5xeu9ClJRt7KjmkUkS9j00b0ezsNup63pOKi4JpgalQjmrkp4ThxIf2ySkY2kA0qsgcBA/URp Z/rxL8uy9nryFZV1WQHYoLw6Bm1YtIddEF8/g/1mAFfnAym6h9g0manQ9hNp1jFULM4s=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=pxiCCsuULI1JZG2LQOHaVzXh1g2r8v2g2qYcx6Ge6nM=; b=Cy+nZrOV1jJSs4yW5h/dQ+t4tA zCLb8ztm1DpnOh9Ge97IeOYOXJr2gpeYmjezN00ZrJ66X/iPMkTeE1X1JvyeSi8Jqt47B1M0Zs7+Y +4aSDQBVrUKNi72b7KzSNuibbLQF4oyeecxaDtZdNAIxjzBj7VTHTsjNUJxonFv1vLyQ=; Received: from nyc.source.kernel.org ([147.75.193.91]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1t0Xew-0005Xs-TM for linux-f2fs-devel@lists.sourceforge.net; Tue, 15 Oct 2024 02:51:43 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 50A1FA401F9; Tue, 15 Oct 2024 02:51:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F8F1C4CED0; Tue, 15 Oct 2024 02:51:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728960691; bh=Y05EfT0ASAjNhTImYRlNb+wZ7uQbgocCROAhY9S4ZAU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KWKKJK7vFQn9sRsbVTHVJFDV0KhaqMyDA65XyYsIdE6xEcXx7KE3wklyotJ7CET06 6bIvhp+iaxew4tV+3FuQnvzI2Cz82mURHKCzMd2su6As/Davr92etlVH8Xe9uLxCjG 6lhQ+Ts+YgrJmNCUhLj/8lgcZJR8p7ShTrnXW0VqRTQRrLlNN0BOPhGzGQV1Dt3km1 aS8BfKruyBeHgn8c0JDh/3YJY7T/QLWs8r3kgice8P/2ImNvHZLDr4IuWgB5V8PTey jhomZNcd/L+UrZWWjPGOxrkDdyRAKrNi+q3HpurZl6wM3p50ASaWu12Ud/75XG+KW5 ++/itwbhoM0Mg== To: Zorro Lang Date: Tue, 15 Oct 2024 10:51:06 +0800 Message-Id: <20241015025106.3203676-2-chao@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20241015025106.3203676-1-chao@kernel.org> References: <20241015025106.3203676-1-chao@kernel.org> MIME-Version: 1.0 X-Headers-End: 1t0Xew-0005Xs-TM Subject: [f2fs-dev] [PATCH 2/2] f2fs/007: add testcase to check consistency of compressed inode metadata X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Chao Yu via Linux-f2fs-devel From: Chao Yu Reply-To: Chao Yu Cc: Jaegeuk Kim , Qi Han , fstests@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net metadata of compressed inode should always be consistent after file compression, reservation, releasement and decompression, let's add a testcase to check it. Cc: Jaegeuk Kim Cc: Qi Han Signed-off-by: Chao Yu --- tests/f2fs/007 | 116 +++++++++++++++++++++++++++++++++++++++++++++ tests/f2fs/007.out | 4 ++ 2 files changed, 120 insertions(+) create mode 100755 tests/f2fs/007 create mode 100644 tests/f2fs/007.out diff --git a/tests/f2fs/007 b/tests/f2fs/007 new file mode 100755 index 00000000..274be806 --- /dev/null +++ b/tests/f2fs/007 @@ -0,0 +1,116 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024 Oppo. All Rights Reserved. +# +# FS QA Test No. f2fs/007 +# +# This is a regression test to check whether compressed metadata +# can become inconsistent after file compression, reservation +# releasement, and decompression. +# +. ./common/preamble +_begin_fstest auto quick + +_cleanup() +{ + cd / + rm -r -f tmp.* +} + +testfile_prefix=$SCRATCH_MNT/testfile +fio_config=$tmp.fio + +cat >$fio_config <> $seqres.full +_scratch_mount "-o compress_mode=user,compress_extension=*" >> $seqres.full + +echo -e "Run fio to initialize file w/ specified compress ratio" >> $seqres.full +cat $fio_config >> $seqres.full +$FIO_PROG $fio_config >> $seqres.full +_scratch_unmount + +for i in 30 60 90; do + testfile=$testfile_prefix$i + + _scratch_mount "-o compress_mode=user" >> $seqres.full + f2fs_io compress $testfile >> $seqres.full + cblocks=`f2fs_io get_cblocks $testfile` + echo "compression ratio is: "$cblocks" / 256" + + _scratch_unmount + + # 1. check after compression + fsck -t $FSTYP -f $SCRATCH_DEV >> $seqres.full + if [ $? -ne 0 ]; then + _fail "filesystem becomes corrupted after compress" + fi + + _scratch_mount >> $seqres.full + f2fs_io release_cblocks $testfile >> $seqres.full + _scratch_unmount + + # 2. check after releasement + fsck -t $FSTYP -f $SCRATCH_DEV >> $seqres.full + if [ $? -ne 0 ]; then + _fail "filesystem becomes corrupted after release_cblocks" + fi + + _scratch_mount >> $seqres.full + f2fs_io reserve_cblocks $testfile >> $seqres.full + _scratch_unmount + + # 3. check after rservation + fsck -t $FSTYP -f $SCRATCH_DEV >> $seqres.full + if [ $? -ne 0 ]; then + _fail "filesystem becomes corrupted after reserve_cblocks" + fi + + _scratch_mount "-o compress_mode=user" >> $seqres.full + f2fs_io decompress $testfile >> $seqres.full + _scratch_unmount + + # 4. check after decompression + fsck -t $FSTYP -f $SCRATCH_DEV >> $seqres.full + if [ $? -ne 0 ]; then + _fail "filesystem becomes corrupted after decompress" + fi +done + +status=0 +exit diff --git a/tests/f2fs/007.out b/tests/f2fs/007.out new file mode 100644 index 00000000..2ea71c18 --- /dev/null +++ b/tests/f2fs/007.out @@ -0,0 +1,4 @@ +QA output created by 007 +compression ratio is: 64 / 256 +compression ratio is: 128 / 256 +compression ratio is: 192 / 256