From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3DCF31039893 for ; Fri, 27 Feb 2026 20:32:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type:Cc: Reply-To:From:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Subject:In-Reply-To:MIME-Version:References: Message-ID:To:Date:Sender:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=D95hk9bS5yIkpx6RYGOrHZxZHqOKrKI0FulMytkWj18=; b=B5PSaD3VNTj7mKkv3lH37uxtG/ ZJPEPvIusEOc6xrBhbgkrzXLPfNuUc3j50A2hQKsANjQkbzS/OjWEuTU7VC6UYJ3QBqHpfxHUpYn7 ozwboDWQpgRoY3vzNMPIxio+qC47kxSCn0RgbMiRU1ycOSMObRanigp3KRK8pT0bb/5c=; Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1vw4Vp-0005im-US; Fri, 27 Feb 2026 20:32:37 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1vw4Vo-0005if-ML for linux-f2fs-devel@lists.sourceforge.net; Fri, 27 Feb 2026 20:32:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=zN1u4+j1+4RHB54nMrdB8nZW8HUZjUsoDJNtIwumL/M=; b=jLxbmmx09CDAGOtUBH0lpGMBi2 Sd3tIYJB7ogAtZ7UeBooJhAzIuju4ZLWKWI7HjxfFTmxw9B3zGxUwlBfGfM2AO0nDiqU2fbT4ct5y orLw20O0mx66UFpN1Q3lEDyLKXrjdyzEe6M5um78+rDRTah6lBfcjguoulmBspAabawg=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To :From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=zN1u4+j1+4RHB54nMrdB8nZW8HUZjUsoDJNtIwumL/M=; b=BT5ujn2Yx1X2LA0e/uHXM3nftj AMlaHaQlTXiJOZ4VorfhJ3CBD/U4W+cZ/BjPXhKck9gNAKWn4rrQXOvDisfn9Je8mwZ7FDyv9Qy2Q a7CId2SxeLEV6yVIxI0R+ibgldIPaRrK8qw9ckoMUBmBE2JEi7iUCRqhF3xkc8K2O2nY=; Received: from tor.source.kernel.org ([172.105.4.254]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1vw4Vo-00037E-3L for linux-f2fs-devel@lists.sourceforge.net; Fri, 27 Feb 2026 20:32:36 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 61D086013A; Fri, 27 Feb 2026 20:32:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D34B1C116C6; Fri, 27 Feb 2026 20:32:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772224350; bh=inwOH8T5GSnKsELujL5pgwxjtDBSEsYXCrq0ZJp4lTs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YJiW3A6wySrWj1E0TtUBFV6MY2ZzJKVuaCENCa9hQzlmY4XYRmhLFKijHNb+Rn4Kt CMKkGgUD8gdRG7SLkdQCTm0HmflTAZm4nQfvPgsD9MbBK+NLTEhORyCCqUmlZCxWsX BMj8ZpwOV57pcH4rGOvyts3SzclT3yLjvO58Fq78D4ffLr9kMjJ+vX88DI4HuaV5h6 RMrq7VudhHmfjuMz2viFpr/b3T7eOAB0C+J4TDX5JpHpMr4I38agv2Yx/MTMW/5X8u R+mh9/6iUXerZrj7c9xy7mH0Or224cVH1whUZlCHq2HGY1ezfNDGe3XqoZe6tr2Lr6 nWpTxBtgv+55w== Date: Fri, 27 Feb 2026 20:32:28 +0000 To: Shinichiro Kawasaki Message-ID: References: <20260218125237.3340441-1-shinichiro.kawasaki@wdc.com> <20260218125237.3340441-2-shinichiro.kawasaki@wdc.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Headers-End: 1vw4Vo-00037E-3L Subject: Re: [f2fs-dev] [PATCH v2 1/1] f2fs: fix lockdep WARN of sbi->cp_global_sem and q->q_usage_counter X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Jaegeuk Kim via Linux-f2fs-devel Reply-To: Jaegeuk Kim Cc: Damien Le Moal , "linux-f2fs-devel@lists.sourceforge.net" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On 02/24, Shinichiro Kawasaki wrote: > On Feb 24, 2026 / 03:26, Jaegeuk Kim wrote: > > On 02/18, Shin'ichiro Kawasaki wrote: > > > From: Shin'ichiro Kawasaki via Linux-f2fs-devel > > > > > > A lockdep WARN is observed recently under the following steps: > > > > > > 1) Create a zoned TCMU device > > > 2) Create a f2fs filesystem on the zoned TCMU device and mount it > > > 3) Fill the filesystem with files and trigger GC > > > 4) Unmout the filesystem > > > 5) Remove the zoned TCMU device > > > > > > The lockdep WARN indicates that a circular lock depedency formed by four > > > contexts, as described below. > > > > > > a) TCMU device removal context: > > > - call del_gendisk() to get q->q_usage_counter > > > - call start_flush_work() to get work_completion of wb->dwork > > > b) f2fs writeback context: > > > - in wb_workfn(), which holds work_completion of wb->dwork > > > - call f2fs_balance_fs() to get sbi->gc_lock > > > c) f2fs vfs_write context: > > > - call f2fs_gc() to get sbi->gc_lock > > > - call f2fs_write_checkpoint() to get sbi->cp_global_sem > > > d) f2fs mount context: > > > - call recover_fsync_data() to get sbi->cp_global_sem > > > - call f2fs_check_and_fix_write_pointer() to call blkdev_report_zones() > > > that goes down to blk_mq_alloc_request and get q->q_usage_counter > > > > > > To suppress the WARN, cut the dependency d) between sbi->cp_global_sem > > > and q->q_usage_counter. For that purpose, move the > > > f2fs_check_and_fix_write_pointer() call outside of the critical section > > > of sbi->cp_global_sem in f2fs_recovery_fsync_data(). This change is fine > > > because the write pointer fix operation only affects the main segments > > > and does not interact with the check point metadata. Furthermore, > > > conflicts between the write pointer fix operation and data/node flush > > > operations remain protected by SBI_POR_DOING. > > > > > > Fixes: c426d99127b1 ("f2fs: Check write pointer consistency of open zones") > > > Reviewed-by: Damien Le Moal > > > Signed-off-by: Shin'ichiro Kawasaki > > > --- > > > fs/f2fs/recovery.c | 4 ++-- > > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > > diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c > > > index a26071f2b0bc..87fd6cd436fe 100644 > > > --- a/fs/f2fs/recovery.c > > > +++ b/fs/f2fs/recovery.c > > > @@ -922,6 +922,8 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only) > > > truncate_inode_pages_final(META_MAPPING(sbi)); > > > } > > > > > > + f2fs_up_write_trace(&sbi->cp_global_sem, &lc); > > > + > > > /* > > > * If fsync data succeeds or there is no fsync data to recover, > > > * and the f2fs is not read only, check and fix zoned block devices' > > > @@ -933,8 +935,6 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only) > > > if (!err) > > > clear_sbi_flag(sbi, SBI_POR_DOING); > > > > > > - f2fs_up_write_trace(&sbi->cp_global_sem, &lc); > > > - > > > > This was a guard to prevent checkpoint during f2fs_check_and_fix_write_pointer() > > where it changes the checkpoint as well? > > I checked f2fs_check_and_fix_write_pointer() again, and it does not look > changing the checkpoint to me. FYI, here I show the rough function call chain > from f2fs_check_and_fix_write_pointer() as below. I guess this call chain does > not change the checkpoint, but if I misunderstand anything, please let me know. > > f2fs_check_and_fix_write_pointer() > fix_curseg_write_pointer() > do_fix_curseg_write_pointer() > blkdev_report_zones() > report_one_zone_cb() > f2fs_allocate_new_section() > __allocate_new_segment() > new_curseg() E.g., curseg. > locate_dirty_segment() > __locate_dirty_segment() > __remove_dirty_segment() > check_zone_write_pointer() > __f2fs_issue_discard_zone() > blkdev_zone_mgmt() > blkdev_issue_zeroout() > __f2fs_issue_discard_zone() > check_write_pointer(sbi) > blkdev_report_zones() > check_zone_writer_pointer_cb() > check_zone_write_pointer() > __f2fs_issue_discard_zone() > blkdev_zone_mgmt() > blkdev_issue_zeroout() > > > > > > /* let's drop all the directory inodes for clean checkpoint */ > > > destroy_fsync_dnodes(&dir_list, err); > > > > > > -- > > > 2.49.0 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel