From nobody Fri Nov 29 14:53:13 2024 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2086.outbound.protection.outlook.com [40.107.117.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07B3D176248 for ; Wed, 18 Sep 2024 08:28:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.117.86 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726648110; cv=fail; b=YoaoNY75093syppDsqT6l2Xf9hmJgA5+pqt+tMRiakA4ZvlT6uxbFV08UVR9WEtI9O5e/er7H5xU/NQz+T/roT0j5NuBx1TL9+f7XQkRbuNR7SIMsXkfXtin6g++cbI1UnsUcWUEjP+6DQLH9+JWVpHbC2lrGlIfmb79aZrdGss= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726648110; c=relaxed/simple; bh=FpuFUDIvv06KP/+Py/IsagTgYK9hDSHkUFV82WJuxhA=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=d7N6jf0osBcuNN80mUmdiDgNxEYnqFhT0IvFDakDq/3ugY6mDDhm/4nZzraVoQ4lUCu3UEbTylYH6+wPkqtEOlJg/N+ZPLTDiUKoWz2jf2GFqK3pxaFYH0U+LPH1Cp3T+hqAvbUS1k2MaXO82n/RuFhBkDbn2kbgLEdRAJWrZLA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com; spf=pass smtp.mailfrom=vivo.com; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b=TiKM9U5M; arc=fail smtp.client-ip=40.107.117.86 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=vivo.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="TiKM9U5M" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GKpEHB57VzrEFjE/HTgZ4nVs5AS7slOtaA7UhBT7FsuEv/h1JkWmkB04jwH+0Y2OfKEwgi99NcKadN05ClVuSD2GruaitZAH0BpLPmF7Uaj/0dp0s5eCWbgaIkfHQo3FHxEUMW4cJrCTYYW5erHiP+0nsQcScfJZ2+kyDu9cR6MWf0vh+z+gLtrdaUAjqgeaRZIWOGVJFGVUea++spYu67eox/RCPWSJQfKsYwL+8/c4PbhWKCqYTkka2La65ZLegE8oeMiOpe5dhikGlPGY0kOHe4ZQ1y76SWEktzaJnd9BGDrW6y96tUo3jcjHKIinVvaQnS0wi51R+SAwAXsbxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zryOCH+ypVg+hR+D8adaW59oCZj6H096VSN9aNr11fo=; b=IeABon6uQbR+s4of2/gml1zW8CwKqwefXPA1v+OIjrmVXImCwv2RFxXjGBGDiIb7SM9qfsmsUDVxs8rknzao15Up7EnV/hfNDqnNpajs5xrT8BeN6yAmEa/0/H33JPq+eDk47CP+68zOX21Df5EkUNHpb4DoqD4jjgfF+F3pR+fZwc9XpUGjaEKDBGvZnwjFv/llcpS7vDcZTg/M/yTkI7dI/KX8ky89OyKDRS9reC6wi6iv+yZN6mwlSItuJjmtpV0b1uDCHpC6RGCZ2fdh/ce1MA0XmCuqFLjo4P8S1bvpSUxs8kNpddGQz/fqldmyN1S37efI5TXzdme9wYSS1Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zryOCH+ypVg+hR+D8adaW59oCZj6H096VSN9aNr11fo=; b=TiKM9U5MDf1Wa+rVWY2SCHDHyoNxIn+hYNwey0gYPZLctBAG4Qt1lqdaF9IX1NGR55wzF1GYj8E7E+Iu1giQQ9F28ehsQBROM/bplKe56oe0Q/AEXTUALZEpTwBgQRgAjA+LmMkabEy3Hw87nk61GhSQWMRcGKWzWgj2e2QKBU3bBiq1ukImhn7D+gDP3k3rUa9wuXYVlUPPrQ1cJ3UJO+aM6nYxqcBI6XRbCmMzWxC6zzzEX0/F3sMQkSq9N2ZQ7G+i21/iLZ2K+Twi1FmrgtEact/HMK891jRT5qJFZaEfed39QBMNBJMZEiuFF2VZgV4oCLrwlbNhISNtNmjTTg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB7140.apcprd06.prod.outlook.com (2603:1096:101:228::14) by TYZPR06MB5999.apcprd06.prod.outlook.com (2603:1096:400:33d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.24; Wed, 18 Sep 2024 08:28:26 +0000 Received: from SEZPR06MB7140.apcprd06.prod.outlook.com ([fe80::9eaf:17a9:78b4:67c0]) by SEZPR06MB7140.apcprd06.prod.outlook.com ([fe80::9eaf:17a9:78b4:67c0%5]) with mapi id 15.20.7982.012; Wed, 18 Sep 2024 08:28:26 +0000 From: Qi Han To: jaegeuk@kernel.org, chao@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Qi Han Subject: [PATCH] f2fs: fix f2fs_bug_on when uninstalling filesystem call f2fs_evict_inode. Date: Wed, 18 Sep 2024 02:44:00 -0600 Message-Id: <20240918084400.1821317-1-hanqi@vivo.com> X-Mailer: git-send-email 2.25.1 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SG2PR04CA0168.apcprd04.prod.outlook.com (2603:1096:4::30) To SEZPR06MB7140.apcprd06.prod.outlook.com (2603:1096:101:228::14) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB7140:EE_|TYZPR06MB5999:EE_ X-MS-Office365-Filtering-Correlation-Id: 31c7a89c-b76b-43c6-e39c-08dcd7bbddc6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?2Ge29ORgkA3A5MVFMJRKZXj6npyAQ3Cj3SpdtqYofcHEsTraS1kYIq5CDriO?= =?us-ascii?Q?vTmQjuci1HQRqySGohL8Bsvg2RquY3h0dJSsjuSBXSrm58L7vhxBP7skEAX/?= =?us-ascii?Q?FvbcczuDab8cUNyo5FV14bGO+qtsMbJeu5Qp8uBR2HnTxKmd8L7n1UByPgQQ?= =?us-ascii?Q?i+xvoBYt36L8JEgEylH0dctiz55WCzbZUqjkB1iTFqUQPJrLuCoufFReDnGC?= =?us-ascii?Q?JacmiQFLpdbimKiXMs7z/uG2y/X/thKxccjmmZH4drfevsroM6bxR++N8kQf?= =?us-ascii?Q?DS6ICptmGCd6RxfyZZd7sIJQ7Lf2B1D6YQAryCAbStU0NtFG4kJGqkrn7KH7?= =?us-ascii?Q?DiNdWTcMigolyhP7To9ywMiyUUt0dAyKHd/OKDJy6E1cn7VqbfjIXuMch9q1?= =?us-ascii?Q?m+MZS3CwkBQ9Hb6iIhtS/t66Hu92Cy2IFSiIGxAZsH/kUIM+z55UP6wkPLs/?= =?us-ascii?Q?q3G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NFys2d69royY23d7PA6RDRD1EoUjffBd?= =?us-ascii?Q?F5luEye84nSgFgZJE1vqALWjLqxjS5Hh6wWPNxjWuTDJyk69tw=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SEZPR06MB7140.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(52116014)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?s9RTGKfYjEApCG6ZWVi/S8Ugs8gZbl526K3NN/Viqc/LsHDyN2n53Msb0o13?= =?us-ascii?Q?kn//NmCLPLYsy/wGP51nZUJA8GESmETw69n9dRgBKRSRGYj+yNv/E0L5sz1N?= =?us-ascii?Q?PYUqkphCidKzfIsqBBtA4dwhFmSaF5bdiom9iAx12sT1ZFAb1k+H+dBdgDlc?= =?us-ascii?Q?w4gfGb5Gpoik/WtePal+2vr9/dnVgUMHKPMn1O9Ezzfa06uvH4u7rDk9BVqx?= =?us-ascii?Q?dd5uSzxpLRlGJW6j6nCAM9a3ZtlEWnz9wF1CwXk2wva9AkDbbRVZJv2UsZyO?= =?us-ascii?Q?V/6a2SmumfO/k3dD9OEZgp0Me7jvnOV+LdTXS7YXc4vsZ1oT1p88S/x6Hy2c?= =?us-ascii?Q?rmb3nCos8+cRI4BRgNuktBSpTQo2FmdsgqMk12dkMQEYXLdi6OanGKO6Z15U?= =?us-ascii?Q?w/MfKXDoYjBL4uWTLQF82kK7b59II2Ctyy+Y9Py/0dEA9gRpbKqDUfM/XbuT?= =?us-ascii?Q?F6QmfPNuTudzTQHuuJcaCcE6Kg4LkcZS5TEScMt1R3XJwnKGbk3meaIPR66O?= =?us-ascii?Q?z8bR0bBBBF8xzOglgi0rmYA+2cRNfeXUYYyzxB4PdNTSUqrBMAYmPU8e5KKH?= =?us-ascii?Q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0Krs/ZDiUosVHzO?= =?us-ascii?Q?XS1duhhCUMxgCmfUXyVI0ty2U9XNcu3jyqr1fV62cBW7KSbeRuCRYnGuQMw4?= =?us-ascii?Q?fv7Zh4KcYSaVOnghiNGxNi+eopx2pWu8krDOwy3J?= X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 31c7a89c-b76b-43c6-e39c-08dcd7bbddc6 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB7140.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2024 08:28:26.1349 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3hZMl7/2800xU/dNqpBSEbXTR0juxMHBrlOpYQ04lgkINYDz9eZ0wk6yYz1kLUNZPGX9whLw1MGF5tjA11a65A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB5999 Content-Type: text/plain; charset="utf-8" creating a large files during checkpoint disable until it runs out of space and then delete it, then remount to enable checkpoint again, and then unmount the filesystem triggers the f2fs_bug_on as below: Reviewed-by: Chao Yu ------------[ cut here ]------------ kernel BUG at fs/f2fs/inode.c:896! CPU: 2 UID: 0 PID: 1286 Comm: umount Not tainted 6.11.0-rc7-dirty #360 Oops: invalid opcode: 0000 [#1] PREEMPT SMP NOPTI RIP: 0010:f2fs_evict_inode+0x58c/0x610 Call Trace: __die_body+0x15/0x60 die+0x33/0x50 do_trap+0x10a/0x120 f2fs_evict_inode+0x58c/0x610 do_error_trap+0x60/0x80 f2fs_evict_inode+0x58c/0x610 exc_invalid_op+0x53/0x60 f2fs_evict_inode+0x58c/0x610 asm_exc_invalid_op+0x16/0x20 f2fs_evict_inode+0x58c/0x610 evict+0x101/0x260 dispose_list+0x30/0x50 evict_inodes+0x140/0x190 generic_shutdown_super+0x2f/0x150 kill_block_super+0x11/0x40 kill_f2fs_super+0x7d/0x140 deactivate_locked_super+0x2a/0x70 cleanup_mnt+0xb3/0x140 task_work_run+0x61/0x90 The root cause is: creating large files during disable checkpoint period results in not enough free segments, so when writing back root inode will failed in f2fs_enable_checkpoint. When umount the file system after enabling checkpoint, the root inode is dirty in f2fs_evict_inode function, which triggers BUG_ON. The steps to reproduce are as follows: dd if=3D/dev/zero of=3Df2fs.img bs=3D1M count=3D55 mount f2fs.img f2fs_dir -o checkpoint=3Ddisable:10% dd if=3D/dev/zero of=3Dbig bs=3D1M count=3D50 sync rm big mount -o remount,checkpoint=3Denable f2fs_dir umount f2fs_dir Let's redirty inode when there is not free segments during checkpoint is disable. Signed-off-by: Qi Han --- fs/f2fs/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index aef57172014f..1ff391520cd9 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -770,8 +770,10 @@ int f2fs_write_inode(struct inode *inode, struct write= back_control *wbc) !is_inode_flag_set(inode, FI_DIRTY_INODE)) return 0; =20 - if (!f2fs_is_checkpoint_ready(sbi)) + if (!f2fs_is_checkpoint_ready(sbi)) { + f2fs_mark_inode_dirty_sync(inode, true); return -ENOSPC; + } =20 /* * We need to balance fs here to prevent from producing dirty node pages --=20 2.39.0