Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5564837pxb; Mon, 14 Feb 2022 02:04:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJzKFQXKwiGWXGgDqfC9gyq5U+zg3Lhn84gA6E1/qXuAKFh3XcuR8VJdZycn/eil4WN5NMGE X-Received: by 2002:a05:6402:42c1:: with SMTP id i1mr14646107edc.52.1644833092896; Mon, 14 Feb 2022 02:04:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644833092; cv=none; d=google.com; s=arc-20160816; b=Zym1aydtj0+kFeJCdGu+4ubZdhnXRB+PGe2GzaBGf/skH9MoRXu5QTmpzhzDEqNokO UHH5VApM8WMaABXhdSjY2KuUIMCDUoSjvUERU57PlR6MexUUrFeR39r62eZuwDXCQ46O GvKkv777DAtYqJFq45cniSZAN0UMplBdryltsimmQBbemILwpt+QPWTcAWmlCe5QDGsj 3mRKahIlOTxi1/KypnlD8QkaTwATe+nwBg+zn3yf5flWyA/vffIIrfTebXkmZHJj2PjC TQA07eaEr78D69XAoHvmjthrqhBwD5qHCv9iY91RQPpcViWhma3XvagbB0EQr06eUbLd 4xmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HeqdrGnm0ckecvYnB3mnM8a6s+vYyO7cfQve+Jq1/y0=; b=I5E37MmPl4Gn3P4EsLpUtiClsBhZ1ZXg2Vik9yyJELiPgHFIZ5TDajiIqyX66+/xyS mpegEedhy8fh5jpRbuh5/OUyizQMyjvfpdZ4vR8lp83qjB86wxode94tAOkiIOtlHfSC g2/i1H6ARJdhgGimrxplfFrmjsiA0fmS1Q13T+RHttkKz/U8o1zJpuTS9cf+AmKyIZzJ Q17HhHGOP+rfCBazopDbst+q3YAWC6Lfox1TqCWLZVNDDpwoStMf8mWl1VBb+OPbmBuc ba1GggKmg8UGcZOlxvzLebtPJDx576Le7E6H8MYe1QAtPBtYBg3mbBu7eXwG8O6keF9Q V89A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LCpjccFT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a13si20023534edn.508.2022.02.14.02.04.29; Mon, 14 Feb 2022 02:04:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LCpjccFT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236063AbiBLOUv (ORCPT + 99 others); Sat, 12 Feb 2022 09:20:51 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:34932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236313AbiBLOUo (ORCPT ); Sat, 12 Feb 2022 09:20:44 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA5512B194 for ; Sat, 12 Feb 2022 06:20:33 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BB8CC60F13 for ; Sat, 12 Feb 2022 14:20:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16247C340E7; Sat, 12 Feb 2022 14:20:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644675632; bh=1dgPwNRkPyDoXtU9nbHyYh+ij4besNeVgyKowSaip78=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LCpjccFTT+CBJzH1APLb+wQzYkHrAgBB7wLSdmsJrEbBqTwh5YDnurH+Ld1zfUIMD Qw5+x6OVyyxyuPo3j0PdCS8+Xuux8QD/uMpyEBRUjZ8XIISON1nvfnwDg16raKgFq1 d1FECOPbknmQMbb6GQHxZVEJn2Mey/99tGV7o1p1Yqnd5rrizmSn+c3nyvlj/NzVnW ywEptEeAZnudFleG+Me8BaY9lbcGPAfpaq6nD6ghBfXiclbHDot5PxDwCWofL6SeN6 J5MlOiexCLHb/kIDDTefbpCC8dVU4uG+Cmo2BJQYbFpeaHWhPkxJANugiReRCT3841 78iiylRzvtA8Q== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Jaegeuk Kim Subject: [PATCH 2/2] f2fs: avoid an infinite loop in f2fs_sync_dirty_inodes Date: Sat, 12 Feb 2022 06:20:23 -0800 Message-Id: <20220212142023.2508247-2-jaegeuk@kernel.org> X-Mailer: git-send-email 2.35.1.265.g69c8d7142f-goog In-Reply-To: <20220212142023.2508247-1-jaegeuk@kernel.org> References: <20220212142023.2508247-1-jaegeuk@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-kernel@vger.kernel.org If one read IO is always failing, we can fall into an infinite loop in f2fs_sync_dirty_inodes. This happens during xfstests/generic/457. [ 142.803335] Buffer I/O error on dev dm-1, logical block 8388592, async page read ... [ 382.887210] submit_bio_noacct+0xdd/0x2a0 [ 382.887213] submit_bio+0x80/0x110 [ 382.887223] __submit_bio+0x4d/0x300 [f2fs] [ 382.887282] f2fs_submit_page_bio+0x125/0x200 [f2fs] [ 382.887299] __get_meta_page+0xc9/0x280 [f2fs] [ 382.887315] f2fs_get_meta_page+0x13/0x20 [f2fs] [ 382.887331] f2fs_get_node_info+0x317/0x3c0 [f2fs] [ 382.887350] f2fs_do_write_data_page+0x327/0x6f0 [f2fs] [ 382.887367] f2fs_write_single_data_page+0x5b7/0x960 [f2fs] [ 382.887386] f2fs_write_cache_pages+0x302/0x890 [f2fs] [ 382.887405] ? preempt_count_add+0x7a/0xc0 [ 382.887408] f2fs_write_data_pages+0xfd/0x320 [f2fs] [ 382.887425] ? _raw_spin_unlock+0x1a/0x30 [ 382.887428] do_writepages+0xd3/0x1d0 [ 382.887432] filemap_fdatawrite_wbc+0x69/0x90 [ 382.887434] filemap_fdatawrite+0x50/0x70 [ 382.887437] f2fs_sync_dirty_inodes+0xa4/0x270 [f2fs] [ 382.887453] f2fs_write_checkpoint+0x189/0x1640 [f2fs] [ 382.887469] ? schedule_timeout+0x114/0x150 [ 382.887471] ? ttwu_do_activate+0x6d/0xb0 [ 382.887473] ? preempt_count_add+0x7a/0xc0 [ 382.887476] kill_f2fs_super+0xca/0x100 [f2fs] [ 382.887491] deactivate_locked_super+0x35/0xa0 [ 382.887494] deactivate_super+0x40/0x50 [ 382.887497] cleanup_mnt+0x139/0x190 [ 382.887499] __cleanup_mnt+0x12/0x20 [ 382.887501] task_work_run+0x64/0xa0 [ 382.887505] exit_to_user_mode_prepare+0x1b7/0x1c0 [ 382.887508] syscall_exit_to_user_mode+0x27/0x50 [ 382.887510] do_syscall_64+0x48/0xc0 [ 382.887513] entry_SYSCALL_64_after_hwframe+0x44/0xae Signed-off-by: Jaegeuk Kim --- fs/f2fs/checkpoint.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index 203a1577942d..756abfdf3628 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -1059,13 +1059,13 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type) struct inode *inode; struct f2fs_inode_info *fi; bool is_dir = (type == DIR_INODE); - unsigned long ino = 0; + unsigned long ino = 0, retry_count = DEFAULT_RETRY_IO_COUNT; trace_f2fs_sync_dirty_inodes_enter(sbi->sb, is_dir, get_pages(sbi, is_dir ? F2FS_DIRTY_DENTS : F2FS_DIRTY_DATA)); retry: - if (unlikely(f2fs_cp_error(sbi))) { + if (unlikely(f2fs_cp_error(sbi) || !retry_count)) { trace_f2fs_sync_dirty_inodes_exit(sbi->sb, is_dir, get_pages(sbi, is_dir ? F2FS_DIRTY_DENTS : F2FS_DIRTY_DATA)); @@ -1096,10 +1096,12 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type) iput(inode); /* We need to give cpu to another writers. */ - if (ino == cur_ino) + if (ino == cur_ino) { + retry_count--; cond_resched(); - else + } else { ino = cur_ino; + } } else { /* * We should submit bio, since it exists several -- 2.35.1.265.g69c8d7142f-goog