From patchwork Sat Dec 17 00:46:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaegeuk Kim X-Patchwork-Id: 13075710 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 13B1BC4332F for ; Sat, 17 Dec 2022 00:47:17 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1p6LMA-0001pX-TZ; Sat, 17 Dec 2022 00:47:14 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1p6LM9-0001pR-UB for linux-f2fs-devel@lists.sourceforge.net; Sat, 17 Dec 2022 00:47:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: 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=O0jWofhmonwYucKE4BxS9QQ3NqBC241ik+3gBm8zMUc=; b=RUnyUyXK/bkYJBukWE5F7v6EKZ TxzGOtSQRXnsg+XxS3hlCDUscnrjjSfN/ZRjkMM5WXiml0wQJHyUj4Z1kvT6VR0x4eEGrqtGvdD7m QABu/iujZCUebQym3qid5BimacHgRZ+EdEpgNes3xHtkix21cKvMvPqujtsErHbpi+yM=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=O0jWofhmonwYucKE4BxS9QQ3NqBC241ik+3gBm8zMUc=; b=PzSJ1TAsZjgsHK3Ax4VcYg4Eue NDKTv4mtooZB23TCTIngAuWCCxxbyztYkJEesT6guQL/cW3+RPQahJ3WkrCe0DeVVwosXHDQ1Oupi u7Qp955iezT5bV3aJlcJQOp8siiwvaHlppbv1CmVaTrsrgAxZN5f6HDUBKkujJptzQiw=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1p6LM9-0000lq-2l for linux-f2fs-devel@lists.sourceforge.net; Sat, 17 Dec 2022 00:47:13 +0000 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 D1388622FB for ; Sat, 17 Dec 2022 00:47:06 +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 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 X-Headers-End: 1p6LM9-0000lq-2l Subject: [f2fs-dev] [PATCH 1/3] f2fs: initialize extent_cache parameter 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: , Cc: Jaegeuk Kim Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net 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, struct bio **bio_ret, sector_t last_block_in_file; const unsigned blocksize = blks_to_bytes(inode, 1); struct decompress_io_ctx *dic = NULL; - struct extent_info ei = {0, }; + struct extent_info ei = {}; bool from_dnode = true; int i; int ret = 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, struct extent_info *ei) static void __update_extent_cache(struct dnode_of_data *dn, enum extent_type type) { - struct extent_info ei; + struct extent_info ei = {}; 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 = { .m_next_extent = NULL, .m_seg_type = NO_CHECK_TYPE, .m_may_create = false }; - struct extent_info ei = {0, }; + struct extent_info ei = {}; pgoff_t pg_start, pg_end, next_pgofs; unsigned int blk_per_seg = sbi->blocks_per_seg; unsigned int total = 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 = F2FS_I_SB(inode); - struct extent_info ei; + struct extent_info ei = {}; if (f2fs_lookup_age_extent_cache(inode, pgofs, &ei)) { if (!ei.age) From patchwork Sat Dec 17 00:46:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaegeuk Kim X-Patchwork-Id: 13075711 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 A9F13C4708D for ; Sat, 17 Dec 2022 00:47:18 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1p6LMD-0008Ri-Rk; Sat, 17 Dec 2022 00:47:17 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1p6LMC-0008Rb-7g for linux-f2fs-devel@lists.sourceforge.net; Sat, 17 Dec 2022 00:47:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: 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=5d4nHECykwON0hPPvyXf1dMNYfQwP39CXcvkhJ1tw8o=; b=dDDuz5emrZ6MFN6lJ2ngKgW0wq DaAB4yCxvVQRk4FZLHfckwYxqCxKcCid4yVXgCoUm8svYDQHSIQksHuTGOqhcPEcc45MGLk8g1qSO +q0loPHCIIwMDetsdJVjmkXVp6xlxCGjXdBYsClMi/bD2QJHxlhNQKApj4jKEGOJQbqg=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=5d4nHECykwON0hPPvyXf1dMNYfQwP39CXcvkhJ1tw8o=; b=cQsE8vAcNkgE8tzbTiTmkprjJA F4q9u1XHvFLu1oEy1hAccj0loOOS02E1sITna67rvLrpVpN+rwi47YBSS1mhyp5PI761ehdKH7BxL KR51szVCoJdXFCePLgBBaOnDPrB81vGZxYxhYjLJ6LsphgUYCM6ZdJkZ5LRx+/GqdnWk=; Received: from ams.source.kernel.org ([145.40.68.75]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1p6LMA-0000lv-Le for linux-f2fs-devel@lists.sourceforge.net; Sat, 17 Dec 2022 00:47:16 +0000 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 5FC5BB81E53 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 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 X-Headers-End: 1p6LMA-0000lv-Le Subject: [f2fs-dev] [PATCH 2/3] f2fs: don't mix to use union values in extent_info 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: , Cc: Jaegeuk Kim Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net 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(unsigned long long new, } /* 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 = F2FS_I_SB(inode); loff_t f_size = i_size_read(inode); @@ -894,7 +895,7 @@ static int __get_new_block_age(struct inode *inode, struct extent_info *ei) * block here. */ if ((f_size >> PAGE_SHIFT) == ei->fofs && f_size & (PAGE_SIZE - 1) && - ei->blk == NEW_ADDR) + blkaddr == NEW_ADDR) return -EINVAL; if (__lookup_extent_tree(inode, ei->fofs, ei, EX_BLOCK_AGE)) { @@ -915,14 +916,14 @@ static int __get_new_block_age(struct inode *inode, struct extent_info *ei) return 0; } - f2fs_bug_on(sbi, ei->blk == NULL_ADDR); + f2fs_bug_on(sbi, blkaddr == NULL_ADDR); /* the data block was allocated for the first time */ - if (ei->blk == NEW_ADDR) + if (blkaddr == NEW_ADDR) goto out; - 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 = dn->data_blkaddr; } else if (type == EX_BLOCK_AGE) { - ei.blk = 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); From patchwork Sat Dec 17 00:46:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaegeuk Kim X-Patchwork-Id: 13075712 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 84216C3DA6E for ; Sat, 17 Dec 2022 00:47:18 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1p6LME-0006xT-3K; Sat, 17 Dec 2022 00:47:18 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1p6LMD-0006xM-EU for linux-f2fs-devel@lists.sourceforge.net; Sat, 17 Dec 2022 00:47:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: 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=hKYvtkFrQ5Gu/XGBw1Du7t9DP65ZOOocIcAU545xFeM=; b=LG078gzCtCTSWosXZMebD+Ax/Y ZwXDV/Re2IZaJ1R7kQ5ZTR0GNjCgTJdkGKJAmLH47DSjXdE0dH7oYEYO1fEN92b8IPRHcNy1ASEyZ uH6HGzIsQLqKGMxTC+y6oBeOeCMTLtISzUnyPUb+SCtaUkLfrEci/eX17EAkrPx8P5q4=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=hKYvtkFrQ5Gu/XGBw1Du7t9DP65ZOOocIcAU545xFeM=; b=PmG1NMYkEkC2ZQmNHek/nCibCV rRPDK3mLgC2TBMRUzov7ZEegMLfDKvOU0p7+eoo5lslr9F6o0NSu4iGVGfO3ty5X2fcBmv/TLWqd0 0ish0LXZA9FAlldXOogPZ4jFKsvype6g4agG36QyKycGMDd9nMuDD/ad6Tu9ud6ovpfg=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1p6LMC-001vH0-SY for linux-f2fs-devel@lists.sourceforge.net; Sat, 17 Dec 2022 00:47:17 +0000 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 46C82622FF 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 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 X-Headers-End: 1p6LMC-001vH0-SY Subject: [f2fs-dev] [PATCH 3/3] f2fs: should use a temp extent_info for lookup 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: , Cc: Jaegeuk Kim Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net 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, struct extent_info *ei, loff_t f_size = i_size_read(inode); unsigned long long cur_blocks = atomic64_read(&sbi->allocated_data_blocks); + struct extent_info tei = *ei; /* only fofs and len are valid */ /* * 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, struct extent_info *ei, blkaddr == NEW_ADDR) return -EINVAL; - 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; - if (cur_blocks >= ei->last_blocks) - cur_age = cur_blocks - ei->last_blocks; + if (cur_blocks >= tei.last_blocks) + cur_age = cur_blocks - tei.last_blocks; else /* allocated_data_blocks overflow */ - cur_age = ULLONG_MAX - ei->last_blocks + cur_blocks; + cur_age = ULLONG_MAX - tei.last_blocks + cur_blocks; - if (ei->age) - ei->age = __calculate_block_age(cur_age, ei->age); + if (tei.age) + ei->age = __calculate_block_age(cur_age, tei.age); else ei->age = cur_age; ei->last_blocks = cur_blocks;