From 1482d42a507ce79c750430e9a6156ddf0516e045 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 22 Feb 2016 23:07:50 -0500 Subject: [PATCH] add patch optimize-group-search-for-inode-allocation --- optimize-group-search-for-inode-allocation | 50 ++++++++++++++++++++++++++++++ series | 1 + timestamps | 7 +++-- 3 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 optimize-group-search-for-inode-allocation diff --git a/optimize-group-search-for-inode-allocation b/optimize-group-search-for-inode-allocation new file mode 100644 index 00000000..944b8597 --- /dev/null +++ b/optimize-group-search-for-inode-allocation @@ -0,0 +1,50 @@ +ext4: optimize group search for inode allocation + +From: Lokesh Jaliminche + +Added a check at the start of group search loop to +avoid looping unecessarily in case of empty group. +This also allow group search to jump directly to +"found_flex_bg" with "stats" and "group" already set, +so there is no need to go through the extra steps of +setting "best_desc" , "best_group" and then break +out of the loop just to set "stats" and "group" again. + +Reviewed-by: Andreas Dilger +Signed-off-by: Lokesh Nagappa Jaliminche +Signed-off-by: Theodore Ts'o +--- + fs/ext4/ialloc.c | 10 ++++++++++ + 1 files changed, 10 insertions(+), 0 deletions(-) + +diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c +index 1b8024d..3463d30 100644 +--- a/fs/ext4/ialloc.c ++++ b/fs/ext4/ialloc.c +@@ -477,6 +477,12 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent, + (ext4_test_inode_flag(parent, EXT4_INODE_TOPDIR)))) { + int best_ndir = inodes_per_group; + int ret = -1; ++ /* Maximum usable blocks per group as some blocks are used ++ * for inode tables and allocation bitmaps */ ++ unsigned long long max_blocks_per_flex = ++ ((sbi->s_blocks_per_group - ++ (sbi->s_itb_per_group + 2)) * ++ flex_size) >> sbi->s_cluster_bits; + + if (qstr) { + hinfo.hash_version = DX_HASH_HALF_MD4; +@@ -489,6 +495,10 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent, + for (i = 0; i < ngroups; i++) { + g = (parent_group + i) % ngroups; + get_orlov_stats(sb, g, flex_size, &stats); ++ /* can't get better group than empty group */ ++ if (max_blocks_per_flex == stats.free_clusters && ++ (inodes_per_group * flex_size) == stats.free_inodes) ++ goto found_flex_bg; + if (!stats.free_inodes) + continue; + if (stats.used_dirs >= best_ndir) +-- +1.7.1 + diff --git a/series b/series index a83ae450..4d8094a0 100644 --- a/series +++ b/series @@ -16,6 +16,7 @@ shortcut-setting-of-xattr-to-the-same-value add-reusable-flag-to-cache-entries trim-unused-params-from-convert_initialized_extent +optimize-group-search-for-inode-allocation ########################################## # unstable patches diff --git a/timestamps b/timestamps index 7a9775b7..bdbc695c 100755 --- a/timestamps +++ b/timestamps @@ -41,7 +41,8 @@ touch -d @1456198865 kill-ext4_mballoc_ready touch -d @1456198925 get-rid-of-e_hash_list_head touch -d @1456198984 shortcut-setting-of-xattr-to-the-same-value touch -d @1456199044 add-reusable-flag-to-cache-entries -touch -d @1456199108 timestamps -touch -d @1456199406 series touch -d @1456199935 trim-unused-params-from-convert_initialized_extent -touch -d @1456199941 status +touch -d @1456199992 timestamps +touch -d @1456200179 series +touch -d @1456200258 optimize-group-search-for-inode-allocation +touch -d @1456200267 status -- 2.11.4.GIT