Message ID | 20230131144701.34418-1-chao@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2790595wrn; Tue, 31 Jan 2023 06:47:41 -0800 (PST) X-Google-Smtp-Source: AK7set+EwZXUj7RsJsu3LMTi83a1B1GWwg49/4Iyz0ExcZZL8fTE2FchgHI+qDsC0yej8256uwar X-Received: by 2002:a05:6a21:9005:b0:bc:93c7:96ad with SMTP id tq5-20020a056a21900500b000bc93c796admr10013733pzb.12.1675176461035; Tue, 31 Jan 2023 06:47:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675176461; cv=none; d=google.com; s=arc-20160816; b=UnJ4rbQeEh3nmCiau9FlW5i7YsPeo10X65nMu7iBmS5JugDoRofjjbpZNvNuzsBFga ESc0N15/c/PjPhxS6RNawwfH3fTJ29u+R3hvB3tz82vCQP18aXZ7pOTZvr/RI2rdWW7i A5TbRGvA+tlGgEN1duYHH0eVzoyznojk/vtj/X/lStmBdbp6bItremZLqgURZzo/T3FY NjZi3tjqSrrWsJeF5g3l8CMaXURInstylFlnUot5lNYX9qofjgk1plRKT7vy6rDtRwE5 mGT2mKVuhFAPMa0Yi3K4TwA4fqOXeVMpIAWeg7r83lp+LqPSX1eXlDpinGb4oVrY1SMf /iGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=+FGTf5HuvO5/puVIx6bwuBMFZQlk4rXc/PUC03GODvA=; b=wXBT2zl+iptXpwBs6ChR6Ti7pagZbEt/41tBbz7DnS6lggTkQvIeSfbSDZLfWUGqWL JotnOMcVscV4dgFM9fAEUoDI7Hu4aoyWt794IR5CA7oABqoOOvkm7siun23tb5I+Wviv 58b0lR9p5tNEH6NO+E0R6NBR6RzoCvkwG9F8esRH0Kzv0+hMpWhXDgANG0S3PW9dFeU6 J9b+iH8GxsW7+3G/Z/uUE3/Iv1gi5/g7IV3vJqbf10UID2X2A1TGzAIG77KRvJq3Sxlx X9rfCeP0zWnQb0dLMJcQzCmot2TgQfDVSUUelZu1YU9WGhMcLXPr34GT8p3MkEk1dktD EefQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WSgUT5zF; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i11-20020a63bf4b000000b004b377960752si15410131pgo.353.2023.01.31.06.47.28; Tue, 31 Jan 2023 06:47:41 -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=WSgUT5zF; 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 S231968AbjAaOrK (ORCPT <rfc822;maxin.john@gmail.com> + 99 others); Tue, 31 Jan 2023 09:47:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231910AbjAaOrJ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 31 Jan 2023 09:47:09 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3C1C46727 for <linux-kernel@vger.kernel.org>; Tue, 31 Jan 2023 06:47:07 -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 7687661489 for <linux-kernel@vger.kernel.org>; Tue, 31 Jan 2023 14:47:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2456CC4339B; Tue, 31 Jan 2023 14:47:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675176426; bh=MmOxigM59X8JlcAHThlYTmmNijEJl7O6QUjLV9hpxdU=; h=From:To:Cc:Subject:Date:From; b=WSgUT5zF8Y2q8+duHXiW8g+tcnUn16069rvwvf8xaKL8/mDJAaqVDHG0Y3JMhplgg tKMSGbfB1liLsTfja/zODR7ZrbxJpocaSHAxnGZ3A1sJcQe6CsKPUS+W9rnt1JPTUn 5cYPmTkBSjaHktth2/i8hUa1AKDA+phUWfml4Gmm9GmWL6UMBxusf8ATwiw8ULjL2L 0nFiC06B3b9LFjZCf11QuDydPeaNNz1F6H+oXiV17rlVcxTwm2+5G09fW5FZ+ao4Gv 4whexxOWEJZxq1DI+SxxlFluyIMrPaX8LqPZ3XJajBL5OIUgFBx+yImGM5EyB+M7LW mGiSLhDazvA4g== From: Chao Yu <chao@kernel.org> To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu <chao@kernel.org> Subject: [PATCH 1/3] f2fs: clean up __update_extent_tree_range() Date: Tue, 31 Jan 2023 22:46:59 +0800 Message-Id: <20230131144701.34418-1-chao@kernel.org> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756549832646705987?= X-GMAIL-MSGID: =?utf-8?q?1756549832646705987?= |
Series |
[1/3] f2fs: clean up __update_extent_tree_range()
|
|
Commit Message
Chao Yu
Jan. 31, 2023, 2:46 p.m. UTC
No logic change, just avoid goto statement.
Signed-off-by: Chao Yu <chao@kernel.org>
---
fs/f2fs/extent_cache.c | 66 ++++++++++++++++++++----------------------
1 file changed, 31 insertions(+), 35 deletions(-)
Comments
On 01/31, Chao Yu wrote: > No logic change, just avoid goto statement. I wanted to avoid a deep if/else statement. > > Signed-off-by: Chao Yu <chao@kernel.org> > --- > fs/f2fs/extent_cache.c | 66 ++++++++++++++++++++---------------------- > 1 file changed, 31 insertions(+), 35 deletions(-) > > diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c > index d70ad6a44cbf..cf65a188d112 100644 > --- a/fs/f2fs/extent_cache.c > +++ b/fs/f2fs/extent_cache.c > @@ -782,47 +782,43 @@ static void __update_extent_tree_range(struct inode *inode, > en = next_en; > } > > - if (type == EX_BLOCK_AGE) > - goto update_age_extent_cache; > - > - /* 3. update extent in read extent cache */ > - BUG_ON(type != EX_READ); > - > - if (tei->blk) { > - __set_extent_info(&ei, fofs, len, tei->blk, false, > - 0, 0, EX_READ); > - if (!__try_merge_extent_node(sbi, et, &ei, prev_en, next_en)) > - __insert_extent_tree(sbi, et, &ei, > + /* 3. update extent in extent cache */ > + if (type == EX_READ) { > + if (tei->blk) { > + __set_extent_info(&ei, fofs, len, tei->blk, false, > + 0, 0, EX_READ); > + if (!__try_merge_extent_node(sbi, et, &ei, > + prev_en, next_en)) > + __insert_extent_tree(sbi, et, &ei, > insert_p, insert_parent, leftmost); > > - /* give up extent_cache, if split and small updates happen */ > - if (dei.len >= 1 && > - prev.len < F2FS_MIN_EXTENT_LEN && > - et->largest.len < F2FS_MIN_EXTENT_LEN) { > - et->largest.len = 0; > - et->largest_updated = true; > - set_inode_flag(inode, FI_NO_EXTENT); > + /* give up read extent cache, if split and small updates happen */ > + if (dei.len >= 1 && > + prev.len < F2FS_MIN_EXTENT_LEN && > + et->largest.len < F2FS_MIN_EXTENT_LEN) { > + et->largest.len = 0; > + et->largest_updated = true; > + set_inode_flag(inode, FI_NO_EXTENT); > + } > } > - } > - > - if (is_inode_flag_set(inode, FI_NO_EXTENT)) > - __free_extent_tree(sbi, et); > > - if (et->largest_updated) { > - et->largest_updated = false; > - updated = true; > - } > - goto out_read_extent_cache; > -update_age_extent_cache: > - if (!tei->last_blocks) > - goto out_read_extent_cache; > + if (is_inode_flag_set(inode, FI_NO_EXTENT)) > + __free_extent_tree(sbi, et); > > - __set_extent_info(&ei, fofs, len, 0, false, > - tei->age, tei->last_blocks, EX_BLOCK_AGE); > - if (!__try_merge_extent_node(sbi, et, &ei, prev_en, next_en)) > - __insert_extent_tree(sbi, et, &ei, > + if (et->largest_updated) { > + et->largest_updated = false; > + updated = true; > + } > + } else if (type == EX_BLOCK_AGE) { > + if (tei->last_blocks) { > + __set_extent_info(&ei, fofs, len, 0, false, > + tei->age, tei->last_blocks, EX_BLOCK_AGE); > + if (!__try_merge_extent_node(sbi, et, &ei, > + prev_en, next_en)) > + __insert_extent_tree(sbi, et, &ei, > insert_p, insert_parent, leftmost); > -out_read_extent_cache: > + } > + } > write_unlock(&et->lock); > > if (updated) > -- > 2.36.1
Hello: This series was applied to jaegeuk/f2fs.git (dev) by Jaegeuk Kim <jaegeuk@kernel.org>: On Tue, 31 Jan 2023 22:46:59 +0800 you wrote: > No logic change, just avoid goto statement. > > Signed-off-by: Chao Yu <chao@kernel.org> > --- > fs/f2fs/extent_cache.c | 66 ++++++++++++++++++++---------------------- > 1 file changed, 31 insertions(+), 35 deletions(-) Here is the summary with links: - [f2fs-dev,1/3] f2fs: clean up __update_extent_tree_range() (no matching commit) - [f2fs-dev,2/3] f2fs: fix to update age extent correctly during truncation https://git.kernel.org/jaegeuk/f2fs/c/334ce4a79c9e - [f2fs-dev,3/3] f2fs: fix to update age extent in f2fs_do_zero_range() https://git.kernel.org/jaegeuk/f2fs/c/de6b3a5e09b2 You are awesome, thank you!
On 2023/2/1 2:56, Jaegeuk Kim wrote: > I wanted to avoid a deep if/else statement. So how about this: From 418b408420367ac5491c97a7c4d26e3d0e68ea57 Mon Sep 17 00:00:00 2001 From: Chao Yu <chao@kernel.org> Date: Tue, 31 Jan 2023 22:46:59 +0800 Subject: [PATCH v2] f2fs: clean up __update_extent_tree_range() Introduce __update_read_extent_cache() and __update_age_extent_cache() to clean up __update_extent_tree_range(), no logic change. Signed-off-by: Chao Yu <chao@kernel.org> --- v2 - introduce __update_read_extent_cache() and __update_age_extent_cache() to avoid a deep if/else statement in __update_extent_tree_range(). fs/f2fs/extent_cache.c | 116 +++++++++++++++++++++++++++-------------- 1 file changed, 77 insertions(+), 39 deletions(-) diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c index d70ad6a44cbf..887b0b2898b9 100644 --- a/fs/f2fs/extent_cache.c +++ b/fs/f2fs/extent_cache.c @@ -666,6 +666,75 @@ static struct extent_node *__insert_extent_tree(struct f2fs_sb_info *sbi, return en; } +static inline bool __update_read_extent_cache(struct inode *inode, + struct extent_info *tei, + struct extent_info *ei, + struct extent_info *dei, + struct extent_info *prev, + unsigned int fofs, unsigned int len, + struct extent_node *prev_en, + struct extent_node *next_en, + struct rb_node **insert_p, + struct rb_node *insert_parent, + bool leftmost) +{ + struct f2fs_sb_info *sbi = F2FS_I_SB(inode); + struct extent_tree *et = F2FS_I(inode)->extent_tree[EX_READ]; + + if (!tei->blk) + return false; + + __set_extent_info(ei, fofs, len, tei->blk, false, + 0, 0, EX_READ); + if (!__try_merge_extent_node(sbi, et, ei, + prev_en, next_en)) + __insert_extent_tree(sbi, et, ei, + insert_p, insert_parent, leftmost); + + /* give up read extent cache, if split and small updates happen */ + if (dei->len >= 1 && + prev->len < F2FS_MIN_EXTENT_LEN && + et->largest.len < F2FS_MIN_EXTENT_LEN) { + et->largest.len = 0; + et->largest_updated = true; + set_inode_flag(inode, FI_NO_EXTENT); + } + + if (is_inode_flag_set(inode, FI_NO_EXTENT)) + __free_extent_tree(sbi, et); + + if (et->largest_updated) { + et->largest_updated = false; + return true; + } + + return false; +} + +static inline void __update_age_extent_cache(struct inode *inode, + struct extent_info *tei, + struct extent_info *ei, + unsigned int fofs, unsigned int len, + struct extent_node *prev_en, + struct extent_node *next_en, + struct rb_node **insert_p, + struct rb_node *insert_parent, + bool leftmost) +{ + struct f2fs_sb_info *sbi = F2FS_I_SB(inode); + struct extent_tree *et = F2FS_I(inode)->extent_tree[EX_BLOCK_AGE]; + + if (!tei->last_blocks) + return; + + __set_extent_info(ei, fofs, len, 0, false, + tei->age, tei->last_blocks, EX_BLOCK_AGE); + if (!__try_merge_extent_node(sbi, et, ei, + prev_en, next_en)) + __insert_extent_tree(sbi, et, ei, + insert_p, insert_parent, leftmost); +} + static void __update_extent_tree_range(struct inode *inode, struct extent_info *tei, enum extent_type type) { @@ -782,47 +851,16 @@ static void __update_extent_tree_range(struct inode *inode, en = next_en; } - if (type == EX_BLOCK_AGE) - goto update_age_extent_cache; - - /* 3. update extent in read extent cache */ - BUG_ON(type != EX_READ); - - if (tei->blk) { - __set_extent_info(&ei, fofs, len, tei->blk, false, - 0, 0, EX_READ); - if (!__try_merge_extent_node(sbi, et, &ei, prev_en, next_en)) - __insert_extent_tree(sbi, et, &ei, + /* 3. update extent in extent cache */ + if (type == EX_READ) + updated = __update_read_extent_cache(inode, tei, &ei, &dei, + &prev, fofs, len, prev_en, next_en, insert_p, insert_parent, leftmost); - - /* give up extent_cache, if split and small updates happen */ - if (dei.len >= 1 && - prev.len < F2FS_MIN_EXTENT_LEN && - et->largest.len < F2FS_MIN_EXTENT_LEN) { - et->largest.len = 0; - et->largest_updated = true; - set_inode_flag(inode, FI_NO_EXTENT); - } - } - - if (is_inode_flag_set(inode, FI_NO_EXTENT)) - __free_extent_tree(sbi, et); - - if (et->largest_updated) { - et->largest_updated = false; - updated = true; - } - goto out_read_extent_cache; -update_age_extent_cache: - if (!tei->last_blocks) - goto out_read_extent_cache; - - __set_extent_info(&ei, fofs, len, 0, false, - tei->age, tei->last_blocks, EX_BLOCK_AGE); - if (!__try_merge_extent_node(sbi, et, &ei, prev_en, next_en)) - __insert_extent_tree(sbi, et, &ei, + else if (type == EX_BLOCK_AGE) + __update_age_extent_cache(inode, tei, &ei, + fofs, len, prev_en, next_en, insert_p, insert_parent, leftmost); -out_read_extent_cache: + write_unlock(&et->lock); if (updated)
On 02/01, Chao Yu wrote: > On 2023/2/1 2:56, Jaegeuk Kim wrote: > > I wanted to avoid a deep if/else statement. > > So how about this: Nothing impressive. > > From 418b408420367ac5491c97a7c4d26e3d0e68ea57 Mon Sep 17 00:00:00 2001 > From: Chao Yu <chao@kernel.org> > Date: Tue, 31 Jan 2023 22:46:59 +0800 > Subject: [PATCH v2] f2fs: clean up __update_extent_tree_range() > > Introduce __update_read_extent_cache() and __update_age_extent_cache() > to clean up __update_extent_tree_range(), no logic change. > > Signed-off-by: Chao Yu <chao@kernel.org> > --- > v2 > - introduce __update_read_extent_cache() and __update_age_extent_cache() > to avoid a deep if/else statement in __update_extent_tree_range(). > fs/f2fs/extent_cache.c | 116 +++++++++++++++++++++++++++-------------- > 1 file changed, 77 insertions(+), 39 deletions(-) > > diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c > index d70ad6a44cbf..887b0b2898b9 100644 > --- a/fs/f2fs/extent_cache.c > +++ b/fs/f2fs/extent_cache.c > @@ -666,6 +666,75 @@ static struct extent_node *__insert_extent_tree(struct f2fs_sb_info *sbi, > return en; > } > > +static inline bool __update_read_extent_cache(struct inode *inode, > + struct extent_info *tei, > + struct extent_info *ei, > + struct extent_info *dei, > + struct extent_info *prev, > + unsigned int fofs, unsigned int len, > + struct extent_node *prev_en, > + struct extent_node *next_en, > + struct rb_node **insert_p, > + struct rb_node *insert_parent, > + bool leftmost) > +{ > + struct f2fs_sb_info *sbi = F2FS_I_SB(inode); > + struct extent_tree *et = F2FS_I(inode)->extent_tree[EX_READ]; > + > + if (!tei->blk) > + return false; > + > + __set_extent_info(ei, fofs, len, tei->blk, false, > + 0, 0, EX_READ); > + if (!__try_merge_extent_node(sbi, et, ei, > + prev_en, next_en)) > + __insert_extent_tree(sbi, et, ei, > + insert_p, insert_parent, leftmost); > + > + /* give up read extent cache, if split and small updates happen */ > + if (dei->len >= 1 && > + prev->len < F2FS_MIN_EXTENT_LEN && > + et->largest.len < F2FS_MIN_EXTENT_LEN) { > + et->largest.len = 0; > + et->largest_updated = true; > + set_inode_flag(inode, FI_NO_EXTENT); > + } > + > + if (is_inode_flag_set(inode, FI_NO_EXTENT)) > + __free_extent_tree(sbi, et); > + > + if (et->largest_updated) { > + et->largest_updated = false; > + return true; > + } > + > + return false; > +} > + > +static inline void __update_age_extent_cache(struct inode *inode, > + struct extent_info *tei, > + struct extent_info *ei, > + unsigned int fofs, unsigned int len, > + struct extent_node *prev_en, > + struct extent_node *next_en, > + struct rb_node **insert_p, > + struct rb_node *insert_parent, > + bool leftmost) > +{ > + struct f2fs_sb_info *sbi = F2FS_I_SB(inode); > + struct extent_tree *et = F2FS_I(inode)->extent_tree[EX_BLOCK_AGE]; > + > + if (!tei->last_blocks) > + return; > + > + __set_extent_info(ei, fofs, len, 0, false, > + tei->age, tei->last_blocks, EX_BLOCK_AGE); > + if (!__try_merge_extent_node(sbi, et, ei, > + prev_en, next_en)) > + __insert_extent_tree(sbi, et, ei, > + insert_p, insert_parent, leftmost); > +} > + > static void __update_extent_tree_range(struct inode *inode, > struct extent_info *tei, enum extent_type type) > { > @@ -782,47 +851,16 @@ static void __update_extent_tree_range(struct inode *inode, > en = next_en; > } > > - if (type == EX_BLOCK_AGE) > - goto update_age_extent_cache; > - > - /* 3. update extent in read extent cache */ > - BUG_ON(type != EX_READ); > - > - if (tei->blk) { > - __set_extent_info(&ei, fofs, len, tei->blk, false, > - 0, 0, EX_READ); > - if (!__try_merge_extent_node(sbi, et, &ei, prev_en, next_en)) > - __insert_extent_tree(sbi, et, &ei, > + /* 3. update extent in extent cache */ > + if (type == EX_READ) > + updated = __update_read_extent_cache(inode, tei, &ei, &dei, > + &prev, fofs, len, prev_en, next_en, > insert_p, insert_parent, leftmost); > - > - /* give up extent_cache, if split and small updates happen */ > - if (dei.len >= 1 && > - prev.len < F2FS_MIN_EXTENT_LEN && > - et->largest.len < F2FS_MIN_EXTENT_LEN) { > - et->largest.len = 0; > - et->largest_updated = true; > - set_inode_flag(inode, FI_NO_EXTENT); > - } > - } > - > - if (is_inode_flag_set(inode, FI_NO_EXTENT)) > - __free_extent_tree(sbi, et); > - > - if (et->largest_updated) { > - et->largest_updated = false; > - updated = true; > - } > - goto out_read_extent_cache; > -update_age_extent_cache: > - if (!tei->last_blocks) > - goto out_read_extent_cache; > - > - __set_extent_info(&ei, fofs, len, 0, false, > - tei->age, tei->last_blocks, EX_BLOCK_AGE); > - if (!__try_merge_extent_node(sbi, et, &ei, prev_en, next_en)) > - __insert_extent_tree(sbi, et, &ei, > + else if (type == EX_BLOCK_AGE) > + __update_age_extent_cache(inode, tei, &ei, > + fofs, len, prev_en, next_en, > insert_p, insert_parent, leftmost); > -out_read_extent_cache: > + > write_unlock(&et->lock); > > if (updated) > -- > 2.25.1 > > Thanks,
On 2023/2/6 11:41, Jaegeuk Kim wrote: > On 02/01, Chao Yu wrote: >> On 2023/2/1 2:56, Jaegeuk Kim wrote: >>> I wanted to avoid a deep if/else statement. >> >> So how about this: > > Nothing impressive. Oops... Thanks,
diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c index d70ad6a44cbf..cf65a188d112 100644 --- a/fs/f2fs/extent_cache.c +++ b/fs/f2fs/extent_cache.c @@ -782,47 +782,43 @@ static void __update_extent_tree_range(struct inode *inode, en = next_en; } - if (type == EX_BLOCK_AGE) - goto update_age_extent_cache; - - /* 3. update extent in read extent cache */ - BUG_ON(type != EX_READ); - - if (tei->blk) { - __set_extent_info(&ei, fofs, len, tei->blk, false, - 0, 0, EX_READ); - if (!__try_merge_extent_node(sbi, et, &ei, prev_en, next_en)) - __insert_extent_tree(sbi, et, &ei, + /* 3. update extent in extent cache */ + if (type == EX_READ) { + if (tei->blk) { + __set_extent_info(&ei, fofs, len, tei->blk, false, + 0, 0, EX_READ); + if (!__try_merge_extent_node(sbi, et, &ei, + prev_en, next_en)) + __insert_extent_tree(sbi, et, &ei, insert_p, insert_parent, leftmost); - /* give up extent_cache, if split and small updates happen */ - if (dei.len >= 1 && - prev.len < F2FS_MIN_EXTENT_LEN && - et->largest.len < F2FS_MIN_EXTENT_LEN) { - et->largest.len = 0; - et->largest_updated = true; - set_inode_flag(inode, FI_NO_EXTENT); + /* give up read extent cache, if split and small updates happen */ + if (dei.len >= 1 && + prev.len < F2FS_MIN_EXTENT_LEN && + et->largest.len < F2FS_MIN_EXTENT_LEN) { + et->largest.len = 0; + et->largest_updated = true; + set_inode_flag(inode, FI_NO_EXTENT); + } } - } - - if (is_inode_flag_set(inode, FI_NO_EXTENT)) - __free_extent_tree(sbi, et); - if (et->largest_updated) { - et->largest_updated = false; - updated = true; - } - goto out_read_extent_cache; -update_age_extent_cache: - if (!tei->last_blocks) - goto out_read_extent_cache; + if (is_inode_flag_set(inode, FI_NO_EXTENT)) + __free_extent_tree(sbi, et); - __set_extent_info(&ei, fofs, len, 0, false, - tei->age, tei->last_blocks, EX_BLOCK_AGE); - if (!__try_merge_extent_node(sbi, et, &ei, prev_en, next_en)) - __insert_extent_tree(sbi, et, &ei, + if (et->largest_updated) { + et->largest_updated = false; + updated = true; + } + } else if (type == EX_BLOCK_AGE) { + if (tei->last_blocks) { + __set_extent_info(&ei, fofs, len, 0, false, + tei->age, tei->last_blocks, EX_BLOCK_AGE); + if (!__try_merge_extent_node(sbi, et, &ei, + prev_en, next_en)) + __insert_extent_tree(sbi, et, &ei, insert_p, insert_parent, leftmost); -out_read_extent_cache: + } + } write_unlock(&et->lock); if (updated)