From: Jaegeuk Kim <jaegeuk@kernel.org>
To: linux-f2fs-devel@lists.sourceforge.net
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Subject: [PATCH 3/6] mkfs.f2fs: export get_best_overprovision
Date: Fri, 11 Dec 2015 16:00:11 -0800 [thread overview]
Message-ID: <1449878414-41254-3-git-send-email-jaegeuk@kernel.org> (raw)
In-Reply-To: <1449878414-41254-1-git-send-email-jaegeuk@kernel.org>
This patch exports get_best_overprovision() function.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
include/f2fs_fs.h | 28 ++++++++++++++++++++++++++++
mkfs/f2fs_format.c | 30 +-----------------------------
2 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 6fd4c80..bbdeb51 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -886,4 +886,32 @@ extern struct f2fs_configuration config;
#define ZONE_ALIGN(blks) ALIGN(blks, config.blks_per_seg * \
config.segs_per_zone)
+static inline double get_best_overprovision(struct f2fs_super_block *sb)
+{
+ double reserved, ovp, candidate, end, diff, space;
+ double max_ovp = 0, max_space = 0;
+
+ if (get_sb(segment_count_main) < 256) {
+ candidate = 10;
+ end = 95;
+ diff = 5;
+ } else {
+ candidate = 0.01;
+ end = 10;
+ diff = 0.01;
+ }
+
+ for (; candidate <= end; candidate += diff) {
+ reserved = (2 * (100 / candidate + 1) + 6) *
+ get_sb(segs_per_sec);
+ ovp = (get_sb(segment_count_main) - reserved) * candidate / 100;
+ space = get_sb(segment_count_main) - reserved - ovp;
+ if (max_space < space) {
+ max_space = space;
+ max_ovp = candidate;
+ }
+ }
+ return max_ovp;
+}
+
#endif /*__F2FS_FS_H */
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index b0c12f2..c4b17de 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -117,34 +117,6 @@ next:
free(config.extension_list);
}
-static double get_best_overprovision(void)
-{
- double reserved, ovp, candidate, end, diff, space;
- double max_ovp = 0, max_space = 0;
-
- if (get_sb(segment_count_main) < 256) {
- candidate = 10;
- end = 95;
- diff = 5;
- } else {
- candidate = 0.01;
- end = 10;
- diff = 0.01;
- }
-
- for (; candidate <= end; candidate += diff) {
- reserved = (2 * (100 / candidate + 1) + 6) *
- get_sb(segs_per_sec);
- ovp = (get_sb(segment_count_main) - reserved) * candidate / 100;
- space = get_sb(segment_count_main) - reserved - ovp;
- if (max_space < space) {
- max_space = space;
- max_ovp = candidate;
- }
- }
- return max_ovp;
-}
-
static int f2fs_prepare_super_block(void)
{
u_int32_t blk_size_bytes;
@@ -302,7 +274,7 @@ static int f2fs_prepare_super_block(void)
/* Let's determine the best reserved and overprovisioned space */
if (config.overprovision == 0)
- config.overprovision = get_best_overprovision();
+ config.overprovision = get_best_overprovision(sb);
config.reserved_segments =
(2 * (100 / config.overprovision + 1) + 6)
--
2.5.4 (Apple Git-61)
------------------------------------------------------------------------------
next prev parent reply other threads:[~2015-12-12 0:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-12 0:00 [PATCH 1/6] libf2fs: enhance the bit operations Jaegeuk Kim
2015-12-12 0:00 ` [PATCH 2/6] fsck.f2fs: sanity_check for extent_cache entry Jaegeuk Kim
2015-12-12 0:00 ` Jaegeuk Kim [this message]
2015-12-12 0:00 ` [PATCH 4/6] f2fs-tools: export print_raw_sb_info Jaegeuk Kim
2015-12-12 0:00 ` [PATCH 5/6] fsck.f2fs: LFS alloc_type must have free segment after blkoff Jaegeuk Kim
2015-12-12 0:00 ` [PATCH 6/6] defrag.f2fs: introduce defragmentation tool Jaegeuk Kim
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=1449878414-41254-3-git-send-email-jaegeuk@kernel.org \
--to=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
/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).