Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1238945ybt; Thu, 18 Jun 2020 04:04:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBTgcr8UKpADVih/326kleAam/s59Yyh3B+v/md+RqhgC1lkWcRUcCfvTaAvYGSBpEfpRb X-Received: by 2002:a05:6402:1243:: with SMTP id l3mr3692851edw.64.1592478283100; Thu, 18 Jun 2020 04:04:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592478283; cv=none; d=google.com; s=arc-20160816; b=I+lyD+QSnpTF/tnXtY4Qa4DRQIv49ltUipJ098/BEu4eTL1q2BCIY7QUWO0dMyBtvy IVumNbCTxXmc+eQj7C63/g+n7ZFYLfUlFsBz6Rd3RYT1RTyDsyO62XyYqtQ+uN9+pISS 6h3cQskEvc6td9CJx9O0+38H/VyIT19B1/H8N1AtdiVwqC18uM/7CCuiGDWyQybTLNTo 1RwtOew3sTBUbxHluVLaAAdGlnkGbdvFDCEgnEKyt9i4AB76ZywnLP0m16rtqYfD0tZs /tPvNRzIJahZwmy20uxclVzhul/s59unvsqiPriXVx5+H0uDx7/UNS/+0oVlbWdXjSHs jTZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language:thread-index :content-transfer-encoding:mime-version:message-id:date:subject :in-reply-to:references:cc:to:from; bh=waVuI+fhDL3OO1BIlX634G7i/WNiUY8x41/avPLA/38=; b=HIug+9xRU7VAqLij7F3N/A6NGp1MVIscWutYUFq4Uh9HEBC6bjiEUIrqx2pelzQvoE tZCvbM/YsxUoSrN8dS5VXgTdFPVJE/1hMWrj/Pvts0OK2aS3e4fzW4U0yPycxa9PM42T K25gvahqCYlTpvXfQtT5kTn6bDU9nETHI8LbS+AEEZL3KC/9IwKi8Zzxgi1nS/Rh+muU bYLvEs+Ob/Qy8SjwNMfyv6I1MsoR+2LsuHW5FeL7MK6gV39IiFnlFwAiL63e6bBPicl9 9KPxcf5uZnzbVFZaT3lcwSSG8/UlWlMFJ7scmFQfLQ2K/Ce/BehmRiaOOI0Ey4LzDevh jfhQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wingtech.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dr4si2312967ejc.239.2020.06.18.04.04.19; Thu, 18 Jun 2020 04:04:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wingtech.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729369AbgFRLBY (ORCPT + 99 others); Thu, 18 Jun 2020 07:01:24 -0400 Received: from mail.wingtech.com ([180.166.216.14]:51987 "EHLO mail.wingtech.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729402AbgFRLBB (ORCPT ); Thu, 18 Jun 2020 07:01:01 -0400 Received: from mx.wingtech.com ([192.168.2.43]) by mail.wingtech.com with SMTP id 05IB0rwb006502-05IB0rwc006502 for ; Thu, 18 Jun 2020 19:00:53 +0800 Received: from 192.168.51.143 (HELO ZHAOWUYUN); Thu, 18 Jun 2020 19:00:50 +0800 From: "Zac" To: "'Chao Yu'" , Cc: , References: <1592384659-20203-1-git-send-email-zhaowuyun@wingtech.com> <86069ba3-cba3-7bc9-c90b-e931abd0dde5@huawei.com> <000001d64519$b05a1180$110e3480$@wingtech.com> <86c34c66-b370-6c6d-91fe-b9235f9c5785@huawei.com> <002d01d64520$840b4750$8c21d5f0$@wingtech.com> <48ede812-ef8b-aa41-e056-3b8fed064dad@huawei.com> In-Reply-To: <48ede812-ef8b-aa41-e056-3b8fed064dad@huawei.com> Subject: =?gb2312?B?u9i4tDogu9i4tDogu9i4tDogW1BBVENIXSBmMmZzOiBmaXggYSByYQ==?= =?gb2312?B?Y2UgY29uZGl0aW9uIGJldHdlZW4gZjJmc193cml0ZV9lbmRfaW8gYQ==?= =?gb2312?B?bmQgZjJmc19kZWxfZnN5bmNfbm9kZV9lbnRyeQ==?= Date: Thu, 18 Jun 2020 19:00:52 +0800 Message-ID: <009501d6455f$bbb29160$3317b420$@wingtech.com> MIME-Version: 1.0 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQJusS8b7G89rONhvQTSKQ9/POQtRgGSiybFAmikCJoCPxgJ/AION8odA0hqpnWnUNUUoA== Content-Language: zh-cn Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On 2020/6/18 11:28, Zac wrote: > >> On 2020/6/18 10:39, Zac wrote: > >>> > >>>> On 2020/6/17 17:04, zhaowuyun@wingtech.com wrote: > >>>>> From: Wuyun Zhao > >>>>> > >>>>> Under some condition, the __write_node_page will submit a page > which > >> is > >>>> not > >>>>> f2fs_in_warm_node_list and will not call f2fs_add_fsync_node_entry. > >>>>> f2fs_gc continue to run to invoke f2fs_iget -> do_read_inode to read > > the > >>>> same node page > >>>>> and set code node, which make f2fs_in_warm_node_list become > true, > >>>>> that will cause f2fs_bug_on in f2fs_del_fsync_node_entry when > >>>> f2fs_write_end_io called. > >>>> Could you please add below race condition description into commit > >>>> message? > >>>> > >>>> - f2fs_write_end_io > >>>> - f2fs_iget > >>>> - do_read_inode > >>>> - set_cold_node > >>>> recover cold node flag > >>>> - f2fs_in_warm_node_list > >>>> - is_cold_node > >>>> if node is cold, assume we have added > >>>> node to fsync_node_list during writepages() > >>>> - f2fs_del_fsync_node_entry > >>>> - f2fs_bug_on() due to node page > >>>> is not in fsync_node_list > >>> > >>> Ok, will add the commit message. > >>> > >>>> BTW, I'm curious about why we can lose cold flag for non-dir inode? > >>>> any clue to reproduce this bug (I mean losing cold flag)? > >>> > >>> it's a f2fs image with 25600MB > >>> flash this image to device > >>> the device will resize it according to the userdata partition size which > > is > >>> about 94GB > >>> the device mount the f2fs partition > >>> then hit this f2fs_bug_on > >>> > >>> seems that the cold flag is not been set when mkfs > >> > >> Ah, I guess both mkfs/sload ignores setting cold node flag for non-dir > > inode, > >> could you please send another patch to fix this issue? > > > > Patch v2 has been sent. > > I see, it looks good to me. > > Actually, I meant we need to fix mkfs/sload bugs as well, do you have time > to > work on it? :) > > Thanks, Ok, I will try to work on it. > > > >>> > >>> I think the issue is that > >>> > >>> 1. the node page in the storage is without cold bit > >>> 2. f2fs_disable_checkpoint -> f2fs_gc -> f2fs_get_node_page, this page > >> won't > >>> be set cold flag > >>> 3. f2fs_move_node_page -> __write_node_page to write this page > >>> 4. f2fs_gc -> f2fs_iget -> do_read_inode to read this page and set cold > > flag > >> > >> Clear enough, thanks for your explanation. :) > >> > >> Thanks, > >> > >>> > >>>>> > >>>>> [ 34.966133] Call trace: > >>>>> [ 34.969902] f2fs_del_fsync_node_entry+0x100/0x108 > >>>>> [ 34.976071] f2fs_write_end_io+0x1e0/0x288 > >>>>> [ 34.981539] bio_endio+0x248/0x270 > >>>>> [ 34.986289] blk_update_request+0x2b0/0x4d8 > >>>>> [ 34.991841] scsi_end_request+0x40/0x440 > >>>>> [ 34.997126] scsi_io_completion+0xa4/0x748 > >>>>> [ 35.002593] scsi_finish_command+0xdc/0x110 > >>>>> [ 35.008143] scsi_softirq_done+0x118/0x150 > >>>>> [ 35.013610] blk_done_softirq+0x8c/0xe8 > >>>>> [ 35.018811] __do_softirq+0x2e8/0x578 > >>>>> [ 35.023828] irq_exit+0xfc/0x120 > >>>>> [ 35.028398] handle_IPI+0x1d8/0x330 > >>>>> [ 35.033233] gic_handle_irq+0x110/0x1d4 > >>>>> [ 35.038433] el1_irq+0xb4/0x130 > >>>>> [ 35.042917] kmem_cache_alloc+0x3f0/0x418 > >>>>> [ 35.048288] radix_tree_node_alloc+0x50/0xf8 > >>>>> [ 35.053933] __radix_tree_create+0xf8/0x188 > >>>>> [ 35.059484] __radix_tree_insert+0x3c/0x128 > >>>>> [ 35.065035] add_gc_inode+0x90/0x118 > >>>>> [ 35.069967] f2fs_gc+0x1b80/0x2d70 > >>>>> [ 35.074718] f2fs_disable_checkpoint+0x94/0x1d0 > >>>>> [ 35.080621] f2fs_fill_super+0x10c4/0x1b88 > >>>>> [ 35.086088] mount_bdev+0x194/0x1e0 > >>>>> [ 35.090923] f2fs_mount+0x40/0x50 > >>>>> [ 35.095589] mount_fs+0xb4/0x190 > >>>>> [ 35.100159] vfs_kern_mount+0x80/0x1d8 > >>>>> [ 35.105260] do_mount+0x478/0xf18 > >>>>> [ 35.109926] ksys_mount+0x90/0xd0 > >>>>> [ 35.114592] __arm64_sys_mount+0x24/0x38 > >>>>> > >>>>> Signed-off-by: Wuyun Zhao > >>>> > >>>> Reviewed-by: Chao Yu > >>>> > >>>> Thanks, > >>>> > >>>>> --- > >>>>> fs/f2fs/inode.c | 1 + > >>>>> 1 file changed, 1 insertion(+) > >>>>> > >>>>> diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c > >>>>> index be6ac33..0df5c8c 100644 > >>>>> --- a/fs/f2fs/inode.c > >>>>> +++ b/fs/f2fs/inode.c > >>>>> @@ -402,6 +402,7 @@ static int do_read_inode(struct inode *inode) > >>>>> > >>>>> /* try to recover cold bit for non-dir inode */ > >>>>> if (!S_ISDIR(inode->i_mode) && !is_cold_node(node_page)) { > >>>>> + f2fs_wait_on_page_writeback(node_page, NODE, true, true); > >>>>> set_cold_node(node_page, false); > >>>>> set_page_dirty(node_page); > >>>>> } > >>>>> > >>> > >>> . > >>> > > > > . > >