All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] EXT4: optimizing group serch for inode allocation
@ 2015-12-18 23:32 lokesh jaliminche
  2015-12-21 17:27 ` Andreas Dilger
  0 siblings, 1 reply; 12+ messages in thread
From: lokesh jaliminche @ 2015-12-18 23:32 UTC (permalink / raw)
  To: Andreas Dilger; +Cc: linux-ext4

[-- Attachment #1: Type: text/plain, Size: 2072 bytes --]

>From 9e09fef78b2fa552c883bf8124af873abfde0805 Mon Sep 17 00:00:00 2001
From: Lokesh Nagappa Jaliminche <lokesh.jaliminche@seagate.com>

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" and "best_group" and then break
out of the loop just to set "stats" and "group" again.

Signed-off-by: Lokesh N Jaliminche <lokesh.jaliminche@gmail.com>
---
 fs/ext4/ialloc.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 1b8024d..588bf8e 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -446,6 +446,8 @@ static int find_group_orlov(struct super_block
*sb, struct inode *parent,
  struct ext4_sb_info *sbi = EXT4_SB(sb);
  ext4_group_t real_ngroups = ext4_get_groups_count(sb);
  int inodes_per_group = EXT4_INODES_PER_GROUP(sb);
+ unsigned int inodes_per_flex_group;
+ long unsigned int blocks_per_clustre;
  unsigned int freei, avefreei, grp_free;
  ext4_fsblk_t freeb, avefreec;
  unsigned int ndirs;
@@ -470,6 +472,8 @@ static int find_group_orlov(struct super_block
*sb, struct inode *parent,
  percpu_counter_read_positive(&sbi->s_freeclusters_counter));
  avefreec = freeb;
  do_div(avefreec, ngroups);
+ inodes_per_flex_group = inodes_per_group * flex_size;
+ blocks_per_clustre = sbi->s_blocks_per_group * flex_size;
  ndirs = percpu_counter_read_positive(&sbi->s_dirs_counter);

  if (S_ISDIR(mode) &&
@@ -489,6 +493,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);
+ /* the group can't get any better than empty */
+ if (inodes_per_flex_group == stats.free_inodes &&
+ blocks_per_clustre == stats.free_clusters)
+ goto found_flex_bg;
  if (!stats.free_inodes)
  continue;
  if (stats.used_dirs >= best_ndir)
-- 
1.7.1

[-- Attachment #2: 0001-EXT4-optimizing-group-serch-for-inode-allocation.patch --]
[-- Type: application/octet-stream, Size: 2208 bytes --]

From 9e09fef78b2fa552c883bf8124af873abfde0805 Mon Sep 17 00:00:00 2001
From: Lokesh Nagappa Jaliminche <lokesh.jaliminche@seagate.com>
Date: Sat, 19 Dec 2015 00:33:06 +0530
Subject: [PATCH] EXT4: optimizing group serch for inode allocation

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" and "best_group" and then break
out of the loop just to set "stats" and "group" again.

Signed-off-by: Lokesh Nagappa Jaliminche <lokesh.jaliminche@gmail.com>
---
 fs/ext4/ialloc.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 1b8024d..588bf8e 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -446,6 +446,8 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent,
 	struct ext4_sb_info *sbi = EXT4_SB(sb);
 	ext4_group_t real_ngroups = ext4_get_groups_count(sb);
 	int inodes_per_group = EXT4_INODES_PER_GROUP(sb);
+	unsigned int inodes_per_flex_group;
+	long unsigned int blocks_per_clustre;
 	unsigned int freei, avefreei, grp_free;
 	ext4_fsblk_t freeb, avefreec;
 	unsigned int ndirs;
@@ -470,6 +472,8 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent,
 		percpu_counter_read_positive(&sbi->s_freeclusters_counter));
 	avefreec = freeb;
 	do_div(avefreec, ngroups);
+	inodes_per_flex_group = inodes_per_group * flex_size;
+	blocks_per_clustre = sbi->s_blocks_per_group * flex_size;
 	ndirs = percpu_counter_read_positive(&sbi->s_dirs_counter);
 
 	if (S_ISDIR(mode) &&
@@ -489,6 +493,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);
+			/* the group can't get any better than empty */
+			if (inodes_per_flex_group == stats.free_inodes &&
+				blocks_per_clustre == stats.free_clusters)
+					goto found_flex_bg;
 			if (!stats.free_inodes)
 				continue;
 			if (stats.used_dirs >= best_ndir)
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-02-23  4:04 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-18 23:32 [PATCH] EXT4: optimizing group serch for inode allocation lokesh jaliminche
2015-12-21 17:27 ` Andreas Dilger
2015-12-26  8:28   ` [PATCH v3] " Lokesh Jaliminche
2015-12-26  8:41   ` [PATCH v3] EXT4: optimizing group search " Lokesh Jaliminche
     [not found]     ` <2DA2ED68-7DD4-425D-8A47-E896E9BF0F4A@dilger.ca>
2016-01-07  0:46       ` [PATCH v4] " Lokesh Jaliminche
2016-01-11 21:13         ` Andreas Dilger
2016-01-16 22:50           ` [PATCH v5] " Lokesh Jaliminche
2016-01-16 23:02           ` Lokesh Jaliminche
2016-01-18 21:50             ` Andreas Dilger
2016-01-19  6:08               ` [PATCH v6] " Lokesh Jaliminche
2016-01-19  7:24                 ` Andreas Dilger
2016-02-23  4:04                 ` Theodore Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.