Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2302182pxm; Thu, 24 Feb 2022 22:15:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJxHmlfpCg0VfipnTQz5TGK1tPjjMWR5fsu67eviBJjtDSIYuHUkyjEdt1boToYdcS6MVVA+ X-Received: by 2002:a65:63d6:0:b0:375:7cc6:2b63 with SMTP id n22-20020a6563d6000000b003757cc62b63mr4946787pgv.598.1645769711046; Thu, 24 Feb 2022 22:15:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645769711; cv=none; d=google.com; s=arc-20160816; b=TTkJFRBOFQ8QeCGTzSYJDP7QkLIMa1JiMoadlEc3qUXcCumJt6FAvAfgnlf+Tw87tk MvsqG7Ac3ZDKT8VXKuUgWghGueMSPRJ/PdKmeNoW0p2+3OpzJKNFuWDa0Hg5V+gijY1v BAjXJqgnZwJO7Ng3Hmz73EIJdVrP2r5PaMxALM/hlvKhsk3QyW+THUCF3cbSy2r18k4H X/zXJGo7GxMCMDfB8KJB0i8BboiA+jm/498RwgEBBjzW0DPEQqlv8b3iw+XGxko5W2ej u5G7IXZaGhKD5jM0YVkQL4HGG7h7icaHMpslvMNt5fZD8YWLawXiTGpgAkP5fT31OCP1 LnhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=3WmfM2pUlnt7188Ub69UI1QgA0eOvVvpA57LCJfAhKg=; b=BvKDSQabqrb4F0Go8p8rIytyVeuVmc1wfjLu5VYxa2kCZDD99m90XPJuWjZQ43FpFM y9s5k46crNb1pWblgPS3wCrTPOp6NvQjmtXz4RW7eIM7lJP2Y0yN5pVy/zA/y9Xjec8f NvX7xR2egtJOwJO2JgTT4BH7Mh1CIrUVcXl1rGZ9Ue6E8D94YGrt9a4im1vCFOd90BRe triee/Wg+bgSl7uLvC+5ARJV6BIJQ54nP9k7/U3O4E6iAwhaTi9i73etQSUlmZnUlKar +4govnLBUz4F65P5KlivZXQXKvlo0kDMafbJQBA2PkSE+UFH14KaGtXyCLY2Kqvhxr/0 cTcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=St8PhKgw; 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 h7-20020a056a00170700b004f1282aea39si1226729pfc.372.2022.02.24.22.14.54; Thu, 24 Feb 2022 22:15:11 -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=St8PhKgw; 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 S236660AbiBYCHn (ORCPT + 99 others); Thu, 24 Feb 2022 21:07:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236585AbiBYCHl (ORCPT ); Thu, 24 Feb 2022 21:07:41 -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 E34CBAF1FD for ; Thu, 24 Feb 2022 18:07:10 -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 4A58D614E7 for ; Fri, 25 Feb 2022 02:07:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1558C340E9; Fri, 25 Feb 2022 02:07:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645754829; bh=/rNQ7PbKEORHE5W8GJIvYASYkIGdvtgnf4kTnIWSLT8=; h=Date:Subject:To:References:From:In-Reply-To:From; b=St8PhKgwZ/GyOhZlZ3X5+XNwAIEq6ci5VE5YkA6vSDe36hxMbhS9vERuLk5tTqJ/C i7J+1mvJedSea1EFwpe2hQ0sAn6VVmFi7rGfr3APAcPmdi0juTVOx7wGxIKCTacZQW T83t3zQUqsI6rB7eei+1rdZu6IGLMKOYwdjTJirggVxDan1X8eWHA4ZJ9N2hKmSKnr A4P0QWomTjsXZRKxu6ANRhFqt1PmqMFGUJma33okFcOSmhsgl1u78+1B2afPuFwJ6o TmEa2w7PPsFqzaN2EfJncc90YXBfKRp7p5jmYL3aO4UhLvOc7fpVovx/XkmIy2AQnr 8HMbWsInYoOQA== Message-ID: <119d1f9e-7f2f-019f-6fdd-2bdb59d97bc6@kernel.org> Date: Fri, 25 Feb 2022 10:07:05 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.0 Subject: Re: [f2fs-dev] [PATCH 2/2 v2] f2fs: avoid an infinite loop in f2fs_sync_dirty_inodes Content-Language: en-US To: Jaegeuk Kim , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net References: <20220212142023.2508247-1-jaegeuk@kernel.org> <20220212142023.2508247-2-jaegeuk@kernel.org> From: Chao Yu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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,NICE_REPLY_A, 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 On 2022/2/15 7:27, Jaegeuk Kim wrote: > If one read IO is always failing, we can fall into an infinite loop in > f2fs_sync_dirty_inodes. This happens during xfstests/generic/475. > > [ 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 > --- > Change log from v1: > - fix a regression to report EIO too early > > fs/f2fs/checkpoint.c | 13 ++++++++----- > fs/f2fs/f2fs.h | 3 +++ > 2 files changed, 11 insertions(+), 5 deletions(-) > > diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c > index 203a1577942d..56c81c68ef71 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_SYNC_DIR_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) || (is_dir && !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,13 @@ 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) > - cond_resched(); > - else > + if (ino == cur_ino) { > + retry_count--; > + io_schedule_timeout(DEFAULT_IO_TIMEOUT); > + } else { > + retry_count = DEFAULT_RETRY_SYNC_DIR_COUNT; > ino = cur_ino; > + } > } else { > /* > * We should submit bio, since it exists several > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h > index c9515c3c54fd..f40ef7b61965 100644 > --- a/fs/f2fs/f2fs.h > +++ b/fs/f2fs/f2fs.h > @@ -577,6 +577,9 @@ enum { > /* maximum retry quota flush count */ > #define DEFAULT_RETRY_QUOTA_FLUSH_COUNT 8 > > +/* maximum retry sync dirty inodes */ > +#define DEFAULT_RETRY_SYNC_DIR_COUNT 3000 3000 * 20ms/round = 60sec How about just trying 5 or 10 sec? Thanks, > + > #define F2FS_LINK_MAX 0xffffffff /* maximum link count per file */ > > #define MAX_DIR_RA_PAGES 4 /* maximum ra pages of dir */