* [PATCH] ext4: Avoid unnecessary calls to ext4_mb_load_buddy while reading mb_groups proc file
@ 2011-01-14 22:05 Aditya Kali
2012-06-13 23:52 ` Ted Ts'o
0 siblings, 1 reply; 2+ messages in thread
From: Aditya Kali @ 2011-01-14 22:05 UTC (permalink / raw)
To: tytso, linux-ext4
Currently ext4_mb_load_buddy is called for every group, irrespective
of whether the group info is already in memory, while reading
/proc/fs/ext4/<partition>/mb_groups proc file. For the purpose of
mb_groups proc file, it is unnecessary to load the file group info
from disk if it was loaded in past. These calls to ext4_mb_load_buddy
make reading the mb_groups proc file expensive.
Also, the locks around ext4_get_group_info are not required.
This patch modifies the code to call ext4_mb_load_buddy only if the
group info had never been loaded into memory in past. It also removes
the mb group locking around ext4_get_group_info call.
Signed-off-by: Aditya Kali <adityakali@google.com>
---
fs/ext4/mballoc.c | 23 +++++++++++++++--------
1 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 851f49b..5738082 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2171,8 +2171,9 @@ static int ext4_mb_seq_groups_show(struct
seq_file *seq, void *v)
struct super_block *sb = seq->private;
ext4_group_t group = (ext4_group_t) ((unsigned long) v);
int i;
- int err;
+ int err, buddy_loaded = 0;
struct ext4_buddy e4b;
+ struct ext4_group_info *grinfo;
struct sg {
struct ext4_group_info info;
ext4_grpblk_t counters[16];
@@ -2189,15 +2190,21 @@ static int ext4_mb_seq_groups_show(struct
seq_file *seq, void *v)
i = (sb->s_blocksize_bits + 2) * sizeof(sg.info.bb_counters[0]) +
sizeof(struct ext4_group_info);
- err = ext4_mb_load_buddy(sb, group, &e4b);
- if (err) {
- seq_printf(seq, "#%-5u: I/O error\n", group);
- return 0;
+ grinfo = ext4_get_group_info(sb, group);
+ /* Load the group info in memory only if not already loaded. */
+ if (unlikely(EXT4_MB_GRP_NEED_INIT(grinfo))) {
+ err = ext4_mb_load_buddy(sb, group, &e4b);
+ if (err) {
+ seq_printf(seq, "#%-5u: I/O error\n", group);
+ return 0;
+ }
+ buddy_loaded = 1;
}
- ext4_lock_group(sb, group);
+
memcpy(&sg, ext4_get_group_info(sb, group), i);
- ext4_unlock_group(sb, group);
- ext4_mb_unload_buddy(&e4b);
+
+ if (buddy_loaded)
+ ext4_mb_unload_buddy(&e4b);
seq_printf(seq, "#%-5u: %-5u %-5u %-5u [", group, sg.info.bb_free,
sg.info.bb_fragments, sg.info.bb_first_free);
--
1.7.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ext4: Avoid unnecessary calls to ext4_mb_load_buddy while reading mb_groups proc file
2011-01-14 22:05 [PATCH] ext4: Avoid unnecessary calls to ext4_mb_load_buddy while reading mb_groups proc file Aditya Kali
@ 2012-06-13 23:52 ` Ted Ts'o
0 siblings, 0 replies; 2+ messages in thread
From: Ted Ts'o @ 2012-06-13 23:52 UTC (permalink / raw)
To: Aditya Kali; +Cc: linux-ext4
On Fri, Jan 14, 2011 at 02:05:15PM -0800, Aditya Kali wrote:
> Currently ext4_mb_load_buddy is called for every group, irrespective
> of whether the group info is already in memory, while reading
> /proc/fs/ext4/<partition>/mb_groups proc file. For the purpose of
> mb_groups proc file, it is unnecessary to load the file group info
> from disk if it was loaded in past. These calls to ext4_mb_load_buddy
> make reading the mb_groups proc file expensive.
> Also, the locks around ext4_get_group_info are not required.
> This patch modifies the code to call ext4_mb_load_buddy only if the
> group info had never been loaded into memory in past. It also removes
> the mb group locking around ext4_get_group_info call.
>
> Signed-off-by: Aditya Kali <adityakali@google.com>
I realized that this had dropped through the cracks. Sorry!
I've queued this for the next merge window.
- Ted
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-06-14 0:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-14 22:05 [PATCH] ext4: Avoid unnecessary calls to ext4_mb_load_buddy while reading mb_groups proc file Aditya Kali
2012-06-13 23:52 ` Ted Ts'o
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).