From nobody Wed Sep 17 15:57:58 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 525FDC4332F for ; Sat, 17 Dec 2022 00:47:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229874AbiLQArV (ORCPT ); Fri, 16 Dec 2022 19:47:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229806AbiLQArK (ORCPT ); Fri, 16 Dec 2022 19:47:10 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A5574F674 for ; Fri, 16 Dec 2022 16:47:08 -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 ams.source.kernel.org (Postfix) with ESMTPS id 8D450B81E51 for ; Sat, 17 Dec 2022 00:47:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D2C6C433F1; Sat, 17 Dec 2022 00:47:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671238026; bh=a+6qsiRsvE8gU7rhpY2cUbwxGERZ4kE0rv1dRLXXt8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K4qZGtZTVI4OgZnBDUp8Hs73pxk2e/fRcYnWXZN1RSOFeFHlfqZ8fmo4G3X0HajZ5 4bgk0icvdnFqDgYhjvY5rCIh6BFJuMOaSEgt22qNin/pLicekF3svjYu+fMlYCz4sW bFumKilV+CdPhAw0FP3YMdyhYCZsQZExbS6b0ZFP8moAa1yXlVmUurV8fVISw1zEgx e4NBlaN6xk7f0s9e/Aw8/91uy1mNYVwwYKQz/eOgIDkmAy+2UNrLeY47PeiIwcnLCi YQpbsPzwH+BBMO980sH6iqsLt94sqK7S2hq3i2JXI25P5E0pXAB8+hTELdbFeNYmNe U41CVH2Ko84KA== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Jaegeuk Kim Subject: [PATCH 1/3] f2fs: initialize extent_cache parameter Date: Fri, 16 Dec 2022 16:46:57 -0800 Message-Id: <20221217004659.2092427-2-jaegeuk@kernel.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20221217004659.2092427-1-jaegeuk@kernel.org> References: <20221217004659.2092427-1-jaegeuk@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This can avoid confusing tracepoint values. Signed-off-by: Jaegeuk Kim --- fs/f2fs/data.c | 2 +- fs/f2fs/extent_cache.c | 2 +- fs/f2fs/file.c | 2 +- fs/f2fs/segment.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 505194c8a258..5f589b8b3b5c 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2191,7 +2191,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, st= ruct bio **bio_ret, sector_t last_block_in_file; const unsigned blocksize =3D blks_to_bytes(inode, 1); struct decompress_io_ctx *dic =3D NULL; - struct extent_info ei =3D {0, }; + struct extent_info ei =3D {}; bool from_dnode =3D true; int i; int ret =3D 0; diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c index 4721f5b0d8b3..749209005644 100644 --- a/fs/f2fs/extent_cache.c +++ b/fs/f2fs/extent_cache.c @@ -938,7 +938,7 @@ static int __get_new_block_age(struct inode *inode, str= uct extent_info *ei) =20 static void __update_extent_cache(struct dnode_of_data *dn, enum extent_ty= pe type) { - struct extent_info ei; + struct extent_info ei =3D {}; =20 if (!__may_extent_tree(dn->inode, type)) return; diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index a22677345d23..a0c0e0e9e83d 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -2560,7 +2560,7 @@ static int f2fs_defragment_range(struct f2fs_sb_info = *sbi, struct f2fs_map_blocks map =3D { .m_next_extent =3D NULL, .m_seg_type =3D NO_CHECK_TYPE, .m_may_create =3D false }; - struct extent_info ei =3D {0, }; + struct extent_info ei =3D {}; pgoff_t pg_start, pg_end, next_pgofs; unsigned int blk_per_seg =3D sbi->blocks_per_seg; unsigned int total =3D 0, sec_num; diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index e2af10d8132b..f8c76ef278df 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -3159,7 +3159,7 @@ static int __get_segment_type_4(struct f2fs_io_info *= fio) static int __get_age_segment_type(struct inode *inode, pgoff_t pgofs) { struct f2fs_sb_info *sbi =3D F2FS_I_SB(inode); - struct extent_info ei; + struct extent_info ei =3D {}; =20 if (f2fs_lookup_age_extent_cache(inode, pgofs, &ei)) { if (!ei.age) --=20 2.39.0.314.g84b9a713c41-goog From nobody Wed Sep 17 15:57:58 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C0B3C3DA6E for ; Sat, 17 Dec 2022 00:47:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229820AbiLQArX (ORCPT ); Fri, 16 Dec 2022 19:47:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229795AbiLQArK (ORCPT ); Fri, 16 Dec 2022 19:47:10 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A67B4A056 for ; Fri, 16 Dec 2022 16:47:09 -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 ams.source.kernel.org (Postfix) with ESMTPS id 3BDDDB81E50 for ; Sat, 17 Dec 2022 00:47:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5D72C433EF; Sat, 17 Dec 2022 00:47:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671238027; bh=J6kSiIexbLuWJ6COT0xoCdZpCwCFQaT/pl5/3mg1XvE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lpz+tm1Q3l+aJ0nZ1Wla3h/KYYx2TsmkCxMIB49F06gZEzeZwNLqm7EGSNAYXtPh6 Oft7043k5Wg1twT6hxG5TWkglUUB9T4mdnL5wHunomWhOzwHGWRPvW8K/LHtqoHRTN 6OCn6hHqk9mbdCF9RiKg4YChqS7nFITzsmRMFMKDCNodC/ysncynBP75QqOnrYXoYU boYVwGBzFEanx7TZeGpgHrwkb7bSdRUSCKisn60EyQ0lfglYRE6FKxwDeSfh27Ab3B wp+7R2wTMODHahUGKdvBRBSLD1Tofnqjr6lbqDMigSwUuDlA2/G56qDjeKs3JiQald XgBQ1Z8kHR9Kg== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Jaegeuk Kim Subject: [PATCH 2/3] f2fs: don't mix to use union values in extent_info Date: Fri, 16 Dec 2022 16:46:58 -0800 Message-Id: <20221217004659.2092427-3-jaegeuk@kernel.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20221217004659.2092427-1-jaegeuk@kernel.org> References: <20221217004659.2092427-1-jaegeuk@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Let's explicitly use the defined values in block_age case only. Signed-off-by: Jaegeuk Kim --- fs/f2fs/extent_cache.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c index 749209005644..7bd1e1832412 100644 --- a/fs/f2fs/extent_cache.c +++ b/fs/f2fs/extent_cache.c @@ -881,7 +881,8 @@ static unsigned long long __calculate_block_age(unsigne= d long long new, } =20 /* This returns a new age and allocated blocks in ei */ -static int __get_new_block_age(struct inode *inode, struct extent_info *ei) +static int __get_new_block_age(struct inode *inode, struct extent_info *ei, + block_t blkaddr) { struct f2fs_sb_info *sbi =3D F2FS_I_SB(inode); loff_t f_size =3D i_size_read(inode); @@ -894,7 +895,7 @@ static int __get_new_block_age(struct inode *inode, str= uct extent_info *ei) * block here. */ if ((f_size >> PAGE_SHIFT) =3D=3D ei->fofs && f_size & (PAGE_SIZE - 1) && - ei->blk =3D=3D NEW_ADDR) + blkaddr =3D=3D NEW_ADDR) return -EINVAL; =20 if (__lookup_extent_tree(inode, ei->fofs, ei, EX_BLOCK_AGE)) { @@ -915,14 +916,14 @@ static int __get_new_block_age(struct inode *inode, s= truct extent_info *ei) return 0; } =20 - f2fs_bug_on(sbi, ei->blk =3D=3D NULL_ADDR); + f2fs_bug_on(sbi, blkaddr =3D=3D NULL_ADDR); =20 /* the data block was allocated for the first time */ - if (ei->blk =3D=3D NEW_ADDR) + if (blkaddr =3D=3D NEW_ADDR) goto out; =20 - if (__is_valid_data_blkaddr(ei->blk) && - !f2fs_is_valid_blkaddr(sbi, ei->blk, DATA_GENERIC_ENHANCE)) { + if (__is_valid_data_blkaddr(blkaddr) && + !f2fs_is_valid_blkaddr(sbi, blkaddr, DATA_GENERIC_ENHANCE)) { f2fs_bug_on(sbi, 1); return -EINVAL; } @@ -953,8 +954,7 @@ static void __update_extent_cache(struct dnode_of_data = *dn, enum extent_type typ else ei.blk =3D dn->data_blkaddr; } else if (type =3D=3D EX_BLOCK_AGE) { - ei.blk =3D dn->data_blkaddr; - if (__get_new_block_age(dn->inode, &ei)) + if (__get_new_block_age(dn->inode, &ei, dn->data_blkaddr)) return; } __update_extent_tree_range(dn->inode, &ei, type); --=20 2.39.0.314.g84b9a713c41-goog From nobody Wed Sep 17 15:57:58 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEDA9C4332F for ; Sat, 17 Dec 2022 00:47:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229840AbiLQArS (ORCPT ); Fri, 16 Dec 2022 19:47:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229793AbiLQArK (ORCPT ); Fri, 16 Dec 2022 19:47:10 -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 AEB334F643 for ; Fri, 16 Dec 2022 16:47:08 -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 4C88062300 for ; Sat, 17 Dec 2022 00:47:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DF15C433D2; Sat, 17 Dec 2022 00:47:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671238027; bh=AzwJwO831ToMtkyVqdqwG2XUb0eIPd36DW9P8p2Lef0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ItJS5nPxoXXc64tEoC8hOfl3x6pXx4brhOBseH0Pyxksxzz8in1nqVZnqERljNmqU brEIUU6hQEmXiUDL3EO7RmSQSIZ39aeG+LvjL+ndsRthYCklXmUKHKbg1ZU1/4euEv DdJjdXqHwWWcNokSfdY0S0YFxiPnuVTTkXUeC9dmmtwPepkh7gwmibrfwTU3/6nCZU hr9DCu5h1Ocig/o8lj4ISjo1vRRGvUhvMbraTdE8qMuigvKPWF1tNvzanI+Qb2U3O4 nsjUThYrohqD37nig5b+Z6mGHivajLd5heX/wzOmPxVyim35RY649jXB+2LRCXELTn 3g0kXPxMvVdyw== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Jaegeuk Kim Subject: [PATCH 3/3] f2fs: should use a temp extent_info for lookup Date: Fri, 16 Dec 2022 16:46:59 -0800 Message-Id: <20221217004659.2092427-4-jaegeuk@kernel.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20221217004659.2092427-1-jaegeuk@kernel.org> References: <20221217004659.2092427-1-jaegeuk@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Otherwise, __lookup_extent_tree() will override the given extent_info which= will be used by caller. Signed-off-by: Jaegeuk Kim --- fs/f2fs/extent_cache.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c index 7bd1e1832412..a510fa57a823 100644 --- a/fs/f2fs/extent_cache.c +++ b/fs/f2fs/extent_cache.c @@ -888,6 +888,7 @@ static int __get_new_block_age(struct inode *inode, str= uct extent_info *ei, loff_t f_size =3D i_size_read(inode); unsigned long long cur_blocks =3D atomic64_read(&sbi->allocated_data_blocks); + struct extent_info tei =3D *ei; /* only fofs and len are valid */ =20 /* * When I/O is not aligned to a PAGE_SIZE, update will happen to the last @@ -898,17 +899,17 @@ static int __get_new_block_age(struct inode *inode, s= truct extent_info *ei, blkaddr =3D=3D NEW_ADDR) return -EINVAL; =20 - if (__lookup_extent_tree(inode, ei->fofs, ei, EX_BLOCK_AGE)) { + if (__lookup_extent_tree(inode, ei->fofs, &tei, EX_BLOCK_AGE)) { unsigned long long cur_age; =20 - if (cur_blocks >=3D ei->last_blocks) - cur_age =3D cur_blocks - ei->last_blocks; + if (cur_blocks >=3D tei.last_blocks) + cur_age =3D cur_blocks - tei.last_blocks; else /* allocated_data_blocks overflow */ - cur_age =3D ULLONG_MAX - ei->last_blocks + cur_blocks; + cur_age =3D ULLONG_MAX - tei.last_blocks + cur_blocks; =20 - if (ei->age) - ei->age =3D __calculate_block_age(cur_age, ei->age); + if (tei.age) + ei->age =3D __calculate_block_age(cur_age, tei.age); else ei->age =3D cur_age; ei->last_blocks =3D cur_blocks; --=20 2.39.0.314.g84b9a713c41-goog