Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp419699pxm; Wed, 2 Mar 2022 00:53:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJyQguZ8sj4dROv/5tK9qq9Lsg68xAnkvjsYTCFMsaJLk6wzMtlxnehT9I0P7fZfLS3G/AOX X-Received: by 2002:a17:907:6d24:b0:6d9:67df:c91 with SMTP id sa36-20020a1709076d2400b006d967df0c91mr1883046ejc.396.1646211206637; Wed, 02 Mar 2022 00:53:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646211206; cv=none; d=google.com; s=arc-20160816; b=T4RonTSB5vSF+z2U0zt+LvDLqF422FZLXqInSUwV1zm2ipwKH1bHHZRs8yF0n9ne7l YIP24rnY0Wlfsh85JT8CFy7KrS9s2mZiCfCfOoEwEGhoZqvrKN0pseLpoXve+kNFNRmP 4cAxcseU7go5rtxq+EkOCA3amySep0O04ixnbVjZM9+OUrLnT5YSkdAbsMS2J44+XzE2 YKSkU8BiSpYz/vx5yKKsMZ8gTLwgBKjBJVYiEA37HbZ41rNEyb8gn/HcC9kYfaPCG6Qy 6hCC4xy/b4Alookdi7pek9EZHOEY3LJTq3o1zUZLkP9cWUx5lHJbjJn9LezCECfThzlq Mwlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Oh32bztH57hTAM54I7s25qq/0bZaomXYl7Hw1LYsv7E=; b=Bh28C1KIxWP8fHTP3dreJ33B9oHdB8rqhcrmO4CAZuPDMOrhGSAum54ekviu6kNLHz OCQUS5faAn3JkUO8OZ7pjaZuCJ6zo/NaUQ1M9JMsXRe55j3A9PwnQXmXOQ7ZVikB1ubB IBXJqbgoGtb1z0WPr8Aln3AlPL5k7q2iDP1rPdgUoMXZQ/tjISR4E0ScdO5+ywua1nRR w1Yy6uWs8Jobi+hiIAVnk5gni04PWsLeDXGYPlIbPCexCnEb5TrQho3cwF/xyR9Wy7t+ 2Vt2xlZxRMFLd7zUYTEHwdBF7nVKbJ8dGDtlIMV22XThOUcuPfm/IwDY7GskcWwDPTKd yMcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mUJYZCy+; 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 ai4-20020a1709069a0400b006b87b291fa4si8990252ejc.165.2022.03.02.00.53.03; Wed, 02 Mar 2022 00:53:26 -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=mUJYZCy+; 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 S235355AbiCBFfo (ORCPT + 99 others); Wed, 2 Mar 2022 00:35:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229727AbiCBFfn (ORCPT ); Wed, 2 Mar 2022 00:35:43 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B28FAB16D4 for ; Tue, 1 Mar 2022 21:34:57 -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 560196184A for ; Wed, 2 Mar 2022 05:34:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DD5EC004E1; Wed, 2 Mar 2022 05:34:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646199296; bh=iq6cJsutOQCdOdTLxAki733OXRWRPpeAadqi2duTCAo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mUJYZCy+zrH6cZyh++lh/RN4OMqWeJ3Dsh0S1EBSREIprtNjOfg82SIb9qS+gJQL3 h0Z5hM2tHbhEzxaQzUg7g+uKePfMM2ZJ99ud7chHLFbEaC8XgMXhDOR3VcahW80i2y RG64ZzRpsaswlmwvWoo6SeRn9XXfpZeu5163qxAAOiEoNfv3381l9YZhfM3avLDakl iu6OWnBp20gmH/MZmlUtJWB2Z8z2iMWcJOsiASn9APScxxAEZCz1hM79gOAAiwAi7m CSQgo4Rx2tGO0bGyjFa4fSyrSqdLTN7+8NQNmLv2ktfDIr/TW+prcwPK1POhrxCufb wCnKyy/ebIPDg== Date: Tue, 1 Mar 2022 21:34:55 -0800 From: Jaegeuk Kim To: Chao Yu Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: Re: [f2fs-dev] [PATCH v2] f2fs: avoid sb_start_intwrite during eviction Message-ID: References: <20220215220039.1477906-1-jaegeuk@kernel.org> <09683b83-b6c0-fe05-0dae-b93cab2f4b63@kernel.org> <4b264607-4d60-7370-eca7-8816a3f8d29f@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4b264607-4d60-7370-eca7-8816a3f8d29f@kernel.org> X-Spam-Status: No, score=-7.5 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 On 03/02, Chao Yu wrote: > On 2022/3/1 12:48, Jaegeuk Kim wrote: > > 1. waiting for f2fs_evict_inode > > [ 5560.043945] __wait_on_freeing_inode+0xac/0xf0 > > [ 5560.045540] ? var_wake_function+0x30/0x30 > > [ 5560.047036] find_inode_fast+0x6d/0xc0 > > [ 5560.048473] iget_locked+0x79/0x230 > > [ 5560.049933] f2fs_iget+0x27/0x1200 [f2fs] > > [ 5560.051496] f2fs_lookup+0x18c/0x3e0 [f2fs] > > [ 5560.053069] __lookup_slow+0x84/0x150 > > [ 5560.054503] walk_component+0x141/0x1b0 > > [ 5560.055938] link_path_walk.part.0+0x23b/0x360 > > [ 5560.057541] ? end_bio_bh_io_sync+0x37/0x50 > > [ 5560.059086] path_parentat+0x3c/0x90 > > [ 5560.060492] filename_parentat+0xd7/0x1e0 > > [ 5560.062002] ? blk_mq_free_request+0x127/0x150 > > [ 5560.063576] do_renameat2+0xc1/0x5b0 > > --> sb_start_write(m->mnt_sb); -> __sb_start_write(sb, SB_FREEZE_WRITE); > > > > [ 5560.064999] ? __check_object_size+0x13f/0x150 > > [ 5560.066559] ? strncpy_from_user+0x44/0x150 > > [ 5560.068038] ? getname_flags.part.0+0x4c/0x1b0 > > [ 5560.069617] __x64_sys_renameat2+0x51/0x60 > > > > 2. waiting for sb_start_intwrite -> __sb_start_write(sb, SB_FREEZE_FS); > > It's still not clear that why __sb_start_write(sb, SB_FREEZE_FS) will be blocked, > as SB_FREEZE_FS and SB_FREEZE_WRITE points to different locks. It seems I missed another call, thaw_super(), got SB_FREEZE_FS and then being stuck to grab SB_FREEZE_WRITE. > > Thread A Thread B Thread C > - rename > - sb_start_write > - __sb_start_write(SB_FREEZE_WRITE) > ... > - f2fs_lookup > ... > - __wait_on_freeing_inode > - drop_slab > - prune_icache_sb > - inode_lru_isolate > :inode->i_state |= I_FREEING > - Is there any flow that it has already held > SB_FREEZE_FS and try to lock SB_FREEZE_WRITE? > - f2fs_evict_inode > - __sb_start_write(SB_FREEZE_FS) > > Thanks, > > > > > [ 5560.152447] percpu_rwsem_wait+0xaf/0x160 > > [ 5560.154000] ? percpu_down_write+0xd0/0xd0 > > [ 5560.155498] __percpu_down_read+0x4e/0x60 > > [ 5560.157000] f2fs_evict_inode+0x5a3/0x610 [f2fs] > > [ 5560.158648] ? var_wake_function+0x30/0x30 > > [ 5560.160341] evict+0xd2/0x180 > > [ 5560.161728] prune_icache_sb+0x81/0xb0 > > --> inode_lru_isolate() -> inode->i_state |= I_FREEING; > > > > [ 5560.163179] super_cache_scan+0x169/0x1f0 > > [ 5560.164675] do_shrink_slab+0x145/0x2b0 > > [ 5560.166121] shrink_slab+0x186/0x2d0 > > [ 5560.167481] drop_slab_node+0x4a/0x90 > > [ 5560.168876] drop_slab+0x3e/0x80 > > [ 5560.170178] drop_caches_sysctl_handler+0x75/0x90 > > [ 5560.171761] proc_sys_call_handler+0x149/0x280 > > [ 5560.173328] proc_sys_write+0x13/0x20 > > [ 5560.174667] new_sync_write+0x117/0x1b0 > > [ 5560.176120] vfs_write+0x1d5/0x270 > > [ 5560.177409] ksys_write+0x67/0xe0 > > > > Signed-off-by: Jaegeuk Kim > > --- > > Note, I found this call stack. > > > > fs/f2fs/inode.c | 2 -- > > 1 file changed, 2 deletions(-) > > > > diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c > > index ab8e0c06c78c..882db4bd917b 100644 > > --- a/fs/f2fs/inode.c > > +++ b/fs/f2fs/inode.c > > @@ -778,7 +778,6 @@ void f2fs_evict_inode(struct inode *inode) > > f2fs_remove_ino_entry(sbi, inode->i_ino, UPDATE_INO); > > f2fs_remove_ino_entry(sbi, inode->i_ino, FLUSH_INO); > > - sb_start_intwrite(inode->i_sb); > > set_inode_flag(inode, FI_NO_ALLOC); > > i_size_write(inode, 0); > > retry: > > @@ -809,7 +808,6 @@ void f2fs_evict_inode(struct inode *inode) > > if (dquot_initialize_needed(inode)) > > set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR); > > } > > - sb_end_intwrite(inode->i_sb); > > no_delete: > > dquot_drop(inode);