From patchwork Tue Mar 25 08:34:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 14028229 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 BB8D3C35FFC for ; Tue, 25 Mar 2025 08:34:56 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1twzkO-0005LW-4D; Tue, 25 Mar 2025 08:34:55 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1twzkM-0005LN-Bf for linux-f2fs-devel@lists.sourceforge.net; Tue, 25 Mar 2025 08:34:53 +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=ODyywFDy2HhP1vzb1LlS60vyckEo6n5FGeNiJp3rQ0o=; b=McHrQkX8U6JL/IOMDZ+Be1ID3B qW0k5Bk9GgLfl0QThbaqrjRw45In6AfwMccdepu2wZw6nSWcMYQjcECi+suDWJnF1pVIeE4MelteV 30YSjgi0yhlaRrNYTobS0f58OJyPALUzsiYI4StXBAjr/e1Dv+wih3U4JdYSFpYXJRk4=; 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=ODyywFDy2HhP1vzb1LlS60vyckEo6n5FGeNiJp3rQ0o=; b=m r43IQA9b0OiEO4us6dG/EPC/Izkm8FH2/UoqZpnIu6kPRWGbOGeyXirtdMKN8B/BGzRebobkQJsie SCO9n5KcdNfO+IGdVy64Ur13BZ+MuYIMd9a7SBmRGc3RW4QLtrjDZ6xsE+bt3Ini4EYmwsRdWrsoC OuMzBZb7JWixUb1g=; Received: from tor.source.kernel.org ([172.105.4.254]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1twzkA-00052t-UE for linux-f2fs-devel@lists.sourceforge.net; Tue, 25 Mar 2025 08:34:53 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 2395B6111E; Tue, 25 Mar 2025 08:34:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87848C4CEE8; Tue, 25 Mar 2025 08:34:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1742891676; bh=nRM4bXUyptdAglnpX3FP5KP7iBLUkiyRSBRlxNjz6Ck=; h=From:To:Cc:Subject:Date:From; b=IVCQqPYBdTKoKizVykV6g9EoNfQgIZw1OlMj+UoUSHEMysSVK/3CkxFqMp1Cz0HIm FXAP+36gSghKQFLUy1XKN/jc9lTiwmqjCdCcmklwVUnZkPG8flyq1IoO3cgMzKe+bH VFMlb70pe/Lln8shaKUGF7FuqZqyYGrGywRYk+2zndeqCC75SV2qsYIG/wm2rYuzAV pMe23W2FrscUZxpgzv20fzM0aAZoKWr21ASExCJVOFgYXgu/f1ZNBgwfAk+hC2+t+0 XqYYTYWL0O2vOnJM9oxV6yNENu0+JkbXkHqsuUUqAFepriPFpbTV0IVZjtHKwqQemz YOdv4AgdDydQA== To: Zorro Lang , fstests@vger.kernel.org Date: Tue, 25 Mar 2025 16:34:28 +0800 Message-ID: <20250325083428.3301950-1-chao@kernel.org> X-Mailer: git-send-email 2.49.0.395.g12beb8f557-goog MIME-Version: 1.0 X-Headers-End: 1twzkA-00052t-UE Subject: [f2fs-dev] [PATCH v2] f2fs/010: test dirty status handling on database file 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@kernel.org, Daeho Jeong , linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net This is a regression testcase to check whether we will handle database inode dirty status correctly: 1. create a regular file, and write data into the file 2. start transaction on the file (via F2FS_IOC_START_ATOMIC_WRITE) 3. write transaction data to the file 4. rename the file 5. commit and end the transaction (via F2FS_IOC_COMMIT_ATOMIC_WRITE) 6. drop caches in order to call f2fs_evict_inode() It expects kernel panic will gone after we apply commit 03511e936916 ("f2fs: fix inconsistent dirty state of atomic file"). Cc: Jaegeuk Kim Cc: Daeho Jeong Cc: Jianan Huang Signed-off-by: Chao Yu Reviewed-by: Zorro Lang --- v2: - fix to unset atomic_write_pid to avoid killing process w/ dummy pid value tests/f2fs/010 | 69 ++++++++++++++++++++++++++++++++++++++++++++++ tests/f2fs/010.out | 2 ++ 2 files changed, 71 insertions(+) create mode 100755 tests/f2fs/010 create mode 100644 tests/f2fs/010.out diff --git a/tests/f2fs/010 b/tests/f2fs/010 new file mode 100755 index 00000000..50e37817 --- /dev/null +++ b/tests/f2fs/010 @@ -0,0 +1,69 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 Chao Yu. All Rights Reserved. +# +# FS QA Test No. f2fs/010 +# +# This is a regression testcase to check whether we will handle database +# inode dirty status correctly: +# 1. create a regular file, and write data into the file +# 2. start transaction on the file (via F2FS_IOC_START_ATOMIC_WRITE) +# 3. write transaction data to the file +# 4. rename the file +# 5. commit and end the transaction (via F2FS_IOC_COMMIT_ATOMIC_WRITE) +# 6. drop caches in order to call f2fs_evict_inode() +# It expects kernel panic will gone after we apply commit 03511e936916 +# ("f2fs: fix inconsistent dirty state of atomic file"). +# +. ./common/preamble +_begin_fstest auto quick + +_cleanup() +{ + [ -n "$atomic_write_pid" ] && kill -9 $atomic_write_pid + wait + cd / + rm -r -f $tmp.* +} + +_fixed_by_kernel_commit 03511e936916 \ + "f2fs: fix inconsistent dirty state of atomic file" + +_require_scratch +_require_command "$F2FS_IO_PROG" f2fs_io + +_scratch_mkfs >> $seqres.full +_scratch_mount >> $seqres.full + +src_db=$SCRATCH_MNT/src.db +dst_db=$SCRATCH_MNT/dst.db + +# initialize database file +$XFS_IO_PROG -c "pwrite 0 4k" -c "fsync" -f $src_db >> $seqres.full + +# sync filesystem to clear dirty inode +sync + +# start atomic_write on src.db database file and commit transaction after 3000ms +$F2FS_IO_PROG write 1 0 0 zero atomic_commit $src_db 3000 >> $seqres.full & +atomic_write_pid=$! + +# wait a moment to let atomic write starts +sleep 1 + +# it will dirty inode when updating i_pino +mv $src_db $dst_db + +# wait for atomic_write commit completion +sleep 4 + +# drop caches in order to call f2fs_evict_inode() +echo 3 > /proc/sys/vm/drop_caches + +wait $atomic_write_pid +unset atomic_write_pid + +echo "Silence is golden" + +status=0 +exit diff --git a/tests/f2fs/010.out b/tests/f2fs/010.out new file mode 100644 index 00000000..1d83a8d6 --- /dev/null +++ b/tests/f2fs/010.out @@ -0,0 +1,2 @@ +QA output created by 010 +Silence is golden