Skip to contentSkip to conversation

Fix in the flex_bg inode allocator.

PATCH New Jose R. Santos 1 participant 2 messages Apr 23, 2008 ext4 file system

lore
Share & tools
lore
#0 lore raw

Notice that the patch in the patch queue did not update flex group stats when using mballoc causing the allocator to behave stangely.

Mingming - please update the patch queue with the new patch
---

Jose R. Santos (1):

      commit e8fa6c1ac978815e421c296673ff34776551f4b9
 fs/ext4/balloc.c  |   16 +++++++++
 fs/ext4/ext4.h    |   25 +++++++++++++-
 fs/ext4/ext4_sb.h |    3 ++
 fs/ext4/ialloc.c  |   96 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 fs/ext4/mballoc.c |   14 ++++++++
 fs/ext4/super.c   |   57 +++++++++++++++++++++++++++++++
 6 files changed, 210 insertions(+), 1 deletions(-)
Signature · 1 line
-JRS
#1 lore raw

PATCH 1/1 commit e8fa6c1ac978815e421c296673ff34776551f4b9

commit e8fa6c1ac978815e421c296673ff34776551f4b9

ext4: New inode allocation for FLEX_BG meta-data groups.

This patch mostly controls the way inode are allocated in order to make ialloc aware of flex_bg block group grouping. It achieves this by bypassing the Orlov allocator when block group meta-data are packed toghether through mke2fs. Since the impact on the block allocator is minimal, this patch should have little or no effect on other block allocation algorithms. By controlling the inode allocation, it can basically control where the initial search for new block begins and thus indirectly manipulate the block allocator.

This allocator favors data and meta-data locality so the disk will gradually be filled from block group zero upward. This helps improve performance by reducing seek time. Since the group of inode tables within one flex_bg are treated as one giant inode table, uninitialized block groups would not need to partially initialize as many inode table as with Orlov which would help fsck time as the filesystem usage goes up.

--

 fs/ext4/balloc.c  |   16 +++++++++
 fs/ext4/ext4.h    |   25 +++++++++++++-
 fs/ext4/ext4_sb.h |    3 ++
 fs/ext4/ialloc.c  |   96 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 fs/ext4/mballoc.c |   14 ++++++++
 fs/ext4/super.c   |   57 +++++++++++++++++++++++++++++++
 6 files changed, 210 insertions(+), 1 deletions(-)
fs/ext4/balloc.c +16 -0
index 6adf896..3e22d69 100644
@@ -127,6 +127,8 @@ unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh,
 		mark_bitmap_end(group_blocks, sb->s_blocksize * 8, bh->b_data);
 	}
 
+	if (sbi->s_log_groups_per_flex)
+		return free_blocks;
 	return free_blocks - sbi->s_itb_per_group - 2;
 }
 
@@ -757,6 +759,13 @@ do_more:
 	spin_unlock(sb_bgl_lock(sbi, block_group));
 	percpu_counter_add(&sbi->s_freeblocks_counter, count);
 
+	if (sbi->s_log_groups_per_flex) {
+		ext4_group_t flex_group = ext4_flex_group(sbi, block_group);
+		spin_lock(sb_bgl_lock(sbi, flex_group));
+		sbi->s_flex_groups[flex_group].free_blocks += count;
+		spin_unlock(sb_bgl_lock(sbi, flex_group));
+	}
+
 	/* We dirtied the bitmap block */
 	BUFFER_TRACE(bitmap_bh, "dirtied bitmap block");
 	err = ext4_journal_dirty_metadata(handle, bitmap_bh);
@@ -1831,6 +1840,13 @@ allocated:
 	spin_unlock(sb_bgl_lock(sbi, group_no));
 	percpu_counter_sub(&sbi->s_freeblocks_counter, num);
 
+	if (sbi->s_log_groups_per_flex) {
+		ext4_group_t flex_group = ext4_flex_group(sbi, group_no);
+		spin_lock(sb_bgl_lock(sbi, flex_group));
+		sbi->s_flex_groups[flex_group].free_blocks -= num;
+		spin_unlock(sb_bgl_lock(sbi, flex_group));
+	}
+
 	BUFFER_TRACE(gdp_bh, "journal_dirty_metadata for group descriptor");
 	err = ext4_journal_dirty_metadata(handle, gdp_bh);
 	if (!fatal)
fs/ext4/ext4.h +24 -1
index 6d4a896..093194b 100644
@@ -175,6 +175,15 @@ struct ext4_group_desc
 	__u32	bg_reserved2[3];
 };
 
+/*
+ * Structure of a flex block group info
+ */
+
+struct flex_groups {
+	__u32 free_inodes;
+	__u32 free_blocks;
+};
+
 #define EXT4_BG_INODE_UNINIT	0x0001 /* Inode table/bitmap not in use */
 #define EXT4_BG_BLOCK_UNINIT	0x0002 /* Block bitmap not in use */
 #define EXT4_BG_INODE_ZEROED	0x0004 /* On-disk itable initialized to zero */
@@ -714,7 +723,10 @@ struct ext4_super_block {
 	__le16  s_mmp_interval;         /* # seconds to wait in MMP checking */
 	__le64  s_mmp_block;            /* Block for multi-mount protection */
 	__le32  s_raid_stripe_width;    /* blocks on all data disks (N*stride)*/
-	__u32   s_reserved[163];        /* Padding to the end of the block */
+	__u8	s_log_groups_per_flex;  /* FLEX_BG group size */
+	__u8	s_reserved_char_pad2;
+	__le16  s_reserved_pad;
+	__u32   s_reserved[162];        /* Padding to the end of the block */
 };
 
 #ifdef __KERNEL__
@@ -1249,6 +1261,17 @@ struct ext4_group_info *ext4_get_group_info(struct super_block *sb,
 }
 
 
+static inline ext4_group_t ext4_flex_group(struct ext4_sb_info *sbi,
+					     ext4_group_t block_group)
+{
+	return block_group >> sbi->s_log_groups_per_flex;
+}
+
+static inline unsigned int ext4_flex_bg_size(struct ext4_sb_info *sbi)
+{
+	return 1 << sbi->s_log_groups_per_flex;
+}
+
 #define ext4_std_error(sb, errno)				\
 do {								\
 	if ((errno))						\
fs/ext4/ext4_sb.h +3 -0
index 5802e69..7450c62 100644
@@ -143,6 +143,9 @@ struct ext4_sb_info {
 
 	/* locality groups */
 	struct ext4_locality_group *s_locality_groups;
+
+	unsigned int s_log_groups_per_flex;
+	struct flex_groups *s_flex_groups;
 };
 
 #endif	/* _EXT4_SB */
fs/ext4/ialloc.c +96 -0

138 lines not on this page · raw message

fs/ext4/mballoc.c +14 -0
index be446f0..3c03906 100644
@@ -2830,6 +2830,13 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac,
 	gdp->bg_checksum = ext4_group_desc_csum(sbi, ac->ac_b_ex.fe_group, gdp);
 	spin_unlock(sb_bgl_lock(sbi, ac->ac_b_ex.fe_group));
 	percpu_counter_sub(&sbi->s_freeblocks_counter, ac->ac_b_ex.fe_len);
+	
+	if (sbi->s_log_groups_per_flex) {
+		ext4_group_t flex_group = ext4_flex_group(sbi, ac->ac_b_ex.fe_group);
+		spin_lock(sb_bgl_lock(sbi, flex_group));
+		sbi->s_flex_groups[flex_group].free_blocks -= ac->ac_b_ex.fe_len;
+		spin_unlock(sb_bgl_lock(sbi, flex_group));
+	}
 
 	err = ext4_journal_dirty_metadata(handle, bitmap_bh);
 	if (err)
@@ -4332,6 +4339,13 @@ do_more:
 	spin_unlock(sb_bgl_lock(sbi, block_group));
 	percpu_counter_add(&sbi->s_freeblocks_counter, count);
 
+        if (sbi->s_log_groups_per_flex) {
+                ext4_group_t flex_group = ext4_flex_group(sbi, block_group);
+                spin_lock(sb_bgl_lock(sbi, flex_group));
+                sbi->s_flex_groups[flex_group].free_blocks += count;
+                spin_unlock(sb_bgl_lock(sbi, flex_group));
+        }
+
 	ext4_mb_release_desc(&e4b);
 
 	*freed += count;
fs/ext4/super.c +57 -0

75 lines not on this page · raw message