From: Chao Yu <chao2.yu@samsung.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: [PATCH 1/3] f2fs: introduce __try_update_largest_extent
Date: Fri, 18 Sep 2015 16:53:07 +0800 [thread overview]
Message-ID: <00cb01d0f1ef$8886fc90$9994f5b0$@samsung.com> (raw)
This patch adds a new helper __try_update_largest_extent for cleanup.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
---
fs/f2fs/extent_cache.c | 14 +++++---------
fs/f2fs/f2fs.h | 7 +++++++
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c
index c9d1cfd..31d5b48 100644
--- a/fs/f2fs/extent_cache.c
+++ b/fs/f2fs/extent_cache.c
@@ -351,8 +351,7 @@ static struct extent_node *__try_merge_extent_node(struct f2fs_sb_info *sbi,
}
if (en) {
- if (en->ei.len > et->largest.len)
- et->largest = en->ei;
+ __try_update_largest_extent(&et->largest, &en->ei);
et->cached_en = en;
}
return en;
@@ -389,8 +388,7 @@ do_insert:
if (!en)
return NULL;
- if (en->ei.len > et->largest.len)
- et->largest = en->ei;
+ __try_update_largest_extent(&et->largest, &en->ei);
et->cached_en = en;
return en;
}
@@ -476,12 +474,10 @@ static unsigned int f2fs_update_extent_tree_range(struct inode *inode,
: NULL;
}
- if (parts) {
- if (en->ei.len > et->largest.len)
- et->largest = en->ei;
- } else {
+ if (parts)
+ __try_update_largest_extent(&et->largest, &en->ei);
+ else
__detach_extent_node(sbi, et, en);
- }
/*
* if original extent is split into zero or two parts, extent
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index dbceb35..3342619 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -498,6 +498,13 @@ static inline bool __is_front_mergeable(struct extent_info *cur,
return __is_extent_mergeable(cur, front);
}
+static inline void __try_update_largest_extent(struct extent_info *largest,
+ struct extent_info *cur)
+{
+ if (cur->len > largest->len)
+ *largest = *cur;
+}
+
struct f2fs_nm_info {
block_t nat_blkaddr; /* base disk address of NAT */
nid_t max_nid; /* maximum possible node ids */
--
2.5.2
------------------------------------------------------------------------------
next reply other threads:[~2015-09-18 8:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-18 8:53 Chao Yu [this message]
2015-09-21 18:40 ` [PATCH 1/3] f2fs: introduce __try_update_largest_extent Jaegeuk Kim
2015-09-22 13:04 ` Chao Yu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='00cb01d0f1ef$8886fc90$9994f5b0$@samsung.com' \
--to=chao2.yu@samsung.com \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).