From: Theodore Ts'o <tytso@mit.edu>
To: Ext4 Developers List <linux-ext4@vger.kernel.org>
Cc: Theodore Ts'o <tytso@mit.edu>
Subject: [PATCH 13/23] ext4: convert the free_blocks field in s_flex_groups to be free_clusters
Date: Wed, 6 Jul 2011 12:35:56 -0400 [thread overview]
Message-ID: <1309970166-11770-14-git-send-email-tytso@mit.edu> (raw)
In-Reply-To: <1309970166-11770-1-git-send-email-tytso@mit.edu>
Convert the free_blocks to be free_clusters to make the final revised
bigalloc changes easier to read/understand.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
fs/ext4/ext4.h | 2 +-
fs/ext4/ialloc.c | 40 +++++++++++++++++++++-------------------
fs/ext4/mballoc.c | 9 +++++----
fs/ext4/resize.c | 4 ++--
fs/ext4/super.c | 2 +-
5 files changed, 30 insertions(+), 27 deletions(-)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index cabc9fd..ca5ab11 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -299,7 +299,7 @@ struct ext4_group_desc
struct flex_groups {
atomic_t free_inodes;
- atomic_t free_blocks;
+ atomic_t free_clusters;
atomic_t used_dirs;
};
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 31a4dc3..048ee7f 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -346,7 +346,7 @@ static int find_group_flex(struct super_block *sb, struct inode *parent,
int flex_size = ext4_flex_bg_size(sbi);
ext4_group_t best_flex = parent_fbg_group;
int blocks_per_flex = sbi->s_blocks_per_group * flex_size;
- int flexbg_free_blocks;
+ int flexbg_free_clusters;
int flex_freeb_ratio;
ext4_group_t n_fbg_groups;
ext4_group_t i;
@@ -355,8 +355,9 @@ static int find_group_flex(struct super_block *sb, struct inode *parent,
sbi->s_log_groups_per_flex;
find_close_to_parent:
- flexbg_free_blocks = atomic_read(&flex_group[best_flex].free_blocks);
- flex_freeb_ratio = flexbg_free_blocks * 100 / blocks_per_flex;
+ flexbg_free_clusters = atomic_read(&flex_group[best_flex].free_clusters);
+ flex_freeb_ratio = EXT4_C2B(sbi, flexbg_free_clusters) * 100 /
+ blocks_per_flex;
if (atomic_read(&flex_group[best_flex].free_inodes) &&
flex_freeb_ratio > free_block_ratio)
goto found_flexbg;
@@ -370,8 +371,9 @@ find_close_to_parent:
if (i == parent_fbg_group || i == parent_fbg_group - 1)
continue;
- flexbg_free_blocks = atomic_read(&flex_group[i].free_blocks);
- flex_freeb_ratio = flexbg_free_blocks * 100 / blocks_per_flex;
+ flexbg_free_clusters = atomic_read(&flex_group[i].free_clusters);
+ flex_freeb_ratio = EXT4_C2B(sbi, flexbg_free_clusters) * 100 /
+ blocks_per_flex;
if (flex_freeb_ratio > free_block_ratio &&
(atomic_read(&flex_group[i].free_inodes))) {
@@ -380,14 +382,14 @@ find_close_to_parent:
}
if ((atomic_read(&flex_group[best_flex].free_inodes) == 0) ||
- ((atomic_read(&flex_group[i].free_blocks) >
- atomic_read(&flex_group[best_flex].free_blocks)) &&
+ ((atomic_read(&flex_group[i].free_clusters) >
+ atomic_read(&flex_group[best_flex].free_clusters)) &&
atomic_read(&flex_group[i].free_inodes)))
best_flex = i;
}
if (!atomic_read(&flex_group[best_flex].free_inodes) ||
- !atomic_read(&flex_group[best_flex].free_blocks))
+ !atomic_read(&flex_group[best_flex].free_clusters))
return -1;
found_flexbg:
@@ -407,7 +409,7 @@ out:
struct orlov_stats {
__u32 free_inodes;
- __u32 free_blocks;
+ __u32 free_clusters;
__u32 used_dirs;
};
@@ -424,7 +426,7 @@ static void get_orlov_stats(struct super_block *sb, ext4_group_t g,
if (flex_size > 1) {
stats->free_inodes = atomic_read(&flex_group[g].free_inodes);
- stats->free_blocks = atomic_read(&flex_group[g].free_blocks);
+ stats->free_clusters = atomic_read(&flex_group[g].free_clusters);
stats->used_dirs = atomic_read(&flex_group[g].used_dirs);
return;
}
@@ -432,11 +434,11 @@ static void get_orlov_stats(struct super_block *sb, ext4_group_t g,
desc = ext4_get_group_desc(sb, g, NULL);
if (desc) {
stats->free_inodes = ext4_free_inodes_count(sb, desc);
- stats->free_blocks = ext4_free_blks_count(sb, desc);
+ stats->free_clusters = ext4_free_blks_count(sb, desc);
stats->used_dirs = ext4_used_dirs_count(sb, desc);
} else {
stats->free_inodes = 0;
- stats->free_blocks = 0;
+ stats->free_clusters = 0;
stats->used_dirs = 0;
}
}
@@ -471,10 +473,10 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent,
ext4_group_t real_ngroups = ext4_get_groups_count(sb);
int inodes_per_group = EXT4_INODES_PER_GROUP(sb);
unsigned int freei, avefreei;
- ext4_fsblk_t freeb, avefreeb;
+ ext4_fsblk_t freeb, avefreec;
unsigned int ndirs;
int max_dirs, min_inodes;
- ext4_grpblk_t min_blocks;
+ ext4_grpblk_t min_clusters;
ext4_group_t i, grp, g, ngroups;
struct ext4_group_desc *desc;
struct orlov_stats stats;
@@ -492,8 +494,8 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent,
avefreei = freei / ngroups;
freeb = EXT4_C2B(sbi,
percpu_counter_read_positive(&sbi->s_freeclusters_counter));
- avefreeb = freeb;
- do_div(avefreeb, ngroups);
+ avefreec = freeb;
+ do_div(avefreec, ngroups);
ndirs = percpu_counter_read_positive(&sbi->s_dirs_counter);
if (S_ISDIR(mode) &&
@@ -519,7 +521,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent,
continue;
if (stats.free_inodes < avefreei)
continue;
- if (stats.free_blocks < avefreeb)
+ if (stats.free_clusters < avefreec)
continue;
grp = g;
ret = 0;
@@ -557,7 +559,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent,
min_inodes = avefreei - inodes_per_group*flex_size / 4;
if (min_inodes < 1)
min_inodes = 1;
- min_blocks = avefreeb - EXT4_BLOCKS_PER_GROUP(sb)*flex_size / 4;
+ min_clusters = avefreec - EXT4_CLUSTERS_PER_GROUP(sb)*flex_size / 4;
/*
* Start looking in the flex group where we last allocated an
@@ -576,7 +578,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent,
continue;
if (stats.free_inodes < min_inodes)
continue;
- if (stats.free_blocks < min_blocks)
+ if (stats.free_clusters < min_clusters)
continue;
goto found_flex_bg;
}
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index a0f92c0..48172a1 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2817,7 +2817,7 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac,
ext4_group_t flex_group = ext4_flex_group(sbi,
ac->ac_b_ex.fe_group);
atomic_sub(ac->ac_b_ex.fe_len,
- &sbi->s_flex_groups[flex_group].free_blocks);
+ &sbi->s_flex_groups[flex_group].free_clusters);
}
err = ext4_handle_dirty_metadata(handle, NULL, bitmap_bh);
@@ -4664,7 +4664,8 @@ do_more:
if (sbi->s_log_groups_per_flex) {
ext4_group_t flex_group = ext4_flex_group(sbi, block_group);
- atomic_add(count, &sbi->s_flex_groups[flex_group].free_blocks);
+ atomic_add(count_clusters,
+ &sbi->s_flex_groups[flex_group].free_clusters);
}
ext4_mb_unload_buddy(&e4b);
@@ -4794,8 +4795,8 @@ void ext4_add_groupblocks(handle_t *handle, struct super_block *sb,
if (sbi->s_log_groups_per_flex) {
ext4_group_t flex_group = ext4_flex_group(sbi, block_group);
- atomic_add(blocks_freed,
- &sbi->s_flex_groups[flex_group].free_blocks);
+ atomic_add(EXT4_B2C(sbi, blocks_freed),
+ &sbi->s_flex_groups[flex_group].free_clusters);
}
ext4_mb_unload_buddy(&e4b);
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index 405c1cb..cef49d3 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -928,8 +928,8 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input)
sbi->s_log_groups_per_flex) {
ext4_group_t flex_group;
flex_group = ext4_flex_group(sbi, input->group);
- atomic_add(input->free_blocks_count,
- &sbi->s_flex_groups[flex_group].free_blocks);
+ atomic_add(EXT4_B2C(sbi, input->free_blocks_count),
+ &sbi->s_flex_groups[flex_group].free_clusters);
atomic_add(EXT4_INODES_PER_GROUP(sb),
&sbi->s_flex_groups[flex_group].free_inodes);
}
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 307e453..a803d65 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1995,7 +1995,7 @@ static int ext4_fill_flex_info(struct super_block *sb)
atomic_add(ext4_free_inodes_count(sb, gdp),
&sbi->s_flex_groups[flex_group].free_inodes);
atomic_add(ext4_free_blks_count(sb, gdp),
- &sbi->s_flex_groups[flex_group].free_blocks);
+ &sbi->s_flex_groups[flex_group].free_clusters);
atomic_add(ext4_used_dirs_count(sb, gdp),
&sbi->s_flex_groups[flex_group].used_dirs);
}
--
1.7.4.1.22.gec8e1.dirty
next prev parent reply other threads:[~2011-07-06 16:36 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-06 16:35 [PATCH 00/23] New spin of the bigalloc patches Theodore Ts'o
2011-07-06 16:35 ` [PATCH 01/23] ext4: read-only support for bigalloc file systems Theodore Ts'o
2011-07-06 16:35 ` [PATCH 02/23] ext4: enforce bigalloc restrictions (e.g., no online resizing, etc.) Theodore Ts'o
2011-09-28 12:55 ` [02/23] " Ted Ts'o
2011-07-06 16:35 ` [PATCH 03/23] ext4: convert instances of EXT4_BLOCKS_PER_GROUP to EXT4_CLUSTERS_PER_GROUP Theodore Ts'o
2011-07-06 16:35 ` [PATCH 04/23] ext4: factor out block group accounting into functions Theodore Ts'o
2011-07-06 16:35 ` [PATCH 05/23] ext4: split out ext4_free_blocks_after_init() Theodore Ts'o
2011-07-06 16:35 ` [PATCH 06/23] ext4: bigalloc changes to block bitmap initialization functions Theodore Ts'o
2011-07-06 16:35 ` [PATCH 07/23] ext4: convert block group-relative offsets to use clusters Theodore Ts'o
2011-07-06 16:35 ` [PATCH 08/23] ext4: teach mballoc preallocation code about bigalloc clusters Theodore Ts'o
2011-07-06 16:35 ` [PATCH 09/23] ext4: teach ext4_free_blocks() about bigalloc and clusters Theodore Ts'o
2011-07-06 16:35 ` [PATCH 10/23] ext4: teach ext4_ext_map_blocks() about the bigalloc feature Theodore Ts'o
2011-07-06 16:35 ` [PATCH 11/23] ext4: teach ext4_ext_truncate() " Theodore Ts'o
2011-07-06 16:35 ` [PATCH 12/23] ext4: convert s_{dirty,free}blocks_counter to s_{dirty,free}clusters_counter Theodore Ts'o
2011-07-06 22:59 ` Andreas Dilger
2011-07-08 22:41 ` Ted Ts'o
2011-07-06 16:35 ` Theodore Ts'o [this message]
2011-07-06 16:35 ` [PATCH 14/23] ext4: teach ext4_statfs() to deal with clusters if bigalloc is enabled Theodore Ts'o
2011-07-06 22:58 ` Andreas Dilger
2011-07-08 22:40 ` Ted Ts'o
2011-07-06 16:35 ` [PATCH 15/23] ext4: tune mballoc's default group prealloc size for bigalloc file systems Theodore Ts'o
2011-07-06 16:35 ` [PATCH 16/23] ext4: Fix bigalloc quota accounting and i_blocks value Theodore Ts'o
2011-07-06 16:36 ` [PATCH 17/23] ext4: enable mounting bigalloc as read/write Theodore Ts'o
2011-07-06 16:36 ` [PATCH 18/23] ext4: Rename ext4_free_blks_{count,set}() to refer to clusters Theodore Ts'o
2011-07-06 23:06 ` Andreas Dilger
2011-07-08 22:42 ` Ted Ts'o
2011-07-06 16:36 ` [PATCH 19/23] ext4: rename ext4_count_free_blocks() to ext4_count_free_clusters() Theodore Ts'o
2011-07-06 16:36 ` [PATCH 20/23] ext4: rename ext4_free_blocks_after_init() to ext4_free_clusters_after_init() Theodore Ts'o
2011-07-06 16:36 ` [PATCH 21/23] ext4: rename ext4_claim_free_blocks() to ext4_claim_free_clusters() Theodore Ts'o
2011-07-06 16:36 ` [PATCH 22/23] ext4: rename ext4_has_free_blocks() to ext4_has_free_clusters() Theodore Ts'o
2011-07-06 16:36 ` [PATCH 23/23] ext4: add some tracepoints in ext4/extents.c Theodore Ts'o
2011-07-06 18:12 ` Eric Gouriou
2011-07-08 23:20 ` Ted Ts'o
2011-07-08 23:02 ` bigalloc performance stats (was Re: [PATCH 00/23] New spin of the bigalloc patches) Ted Ts'o
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=1309970166-11770-14-git-send-email-tytso@mit.edu \
--to=tytso@mit.edu \
--cc=linux-ext4@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).