From d92c8f3bde8fffc570273c24a49134d900b27e4d Mon Sep 17 00:00:00 2001 From: Artem Blagodarenko Date: Wed, 28 Sep 2022 10:28:11 -0400 Subject: [PATCH] EX-6069 ldiskfs: ext4-simple-blockalloc.patch small fixes The LU-14305 requires cleanup to do. MB_DEFAULT_MAX_CX_BYTES #defines are not used anymore, and should be removed. Also, in the el8 version of the patch for b_es6_0, the THRESHOLD_BLOCKS() function should explicitly take "sbi" as a parameter. Test-Parameters: trivial Fixes: d5d5cfdde2 ("add persistent tuning for mb_c3_threshold") Change-Id: Idcb93432fdfa7694b4e7cabbf46a0bf21a412f87 Signed-off-by:Artem Blagodarenko Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/48714 Reviewed-by: Andreas Dilger Tested-by: jenkins Tested-by: Maloo --- .../patches/rhel7.6/ext4-simple-blockalloc.patch | 45 ++++++++++------------ .../patches/rhel8/ext4-simple-blockalloc.patch | 16 ++++---- 2 files changed, 29 insertions(+), 32 deletions(-) diff --git a/ldiskfs/kernel_patches/patches/rhel7.6/ext4-simple-blockalloc.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-simple-blockalloc.patch index b47d3a0..eef940a 100644 --- a/ldiskfs/kernel_patches/patches/rhel7.6/ext4-simple-blockalloc.patch +++ b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-simple-blockalloc.patch @@ -2,7 +2,7 @@ Index: linux-stage/fs/ext4/mballoc.c =================================================================== --- linux-stage.orig/fs/ext4/mballoc.c +++ linux-stage/fs/ext4/mballoc.c -@@ -2098,6 +2098,21 @@ static int ext4_mb_good_group(struct ext4_allocation_context *ac, +@@ -2087,6 +2087,21 @@ static int ext4_mb_good_group(struct ext return 0; } @@ -24,7 +24,7 @@ Index: linux-stage/fs/ext4/mballoc.c static noinline_for_stack int ext4_mb_regular_allocator(struct ext4_allocation_context *ac) { -@@ -2087,6 +2102,7 @@ ext4_mb_regular_allocator(struct ext4_al +@@ -2096,6 +2111,7 @@ ext4_mb_regular_allocator(struct ext4_al struct ext4_sb_info *sbi; struct super_block *sb; struct ext4_buddy e4b; @@ -32,7 +32,7 @@ Index: linux-stage/fs/ext4/mballoc.c sb = ac->ac_sb; sbi = EXT4_SB(sb); -@@ -2136,6 +2152,21 @@ ext4_mb_regular_allocator(struct ext4_al +@@ -2146,6 +2162,21 @@ ext4_mb_regular_allocator(struct ext4_al /* Let's just scan groups to find more-less suitable blocks */ cr = ac->ac_2order ? 0 : 1; @@ -54,7 +54,7 @@ Index: linux-stage/fs/ext4/mballoc.c /* * cr == 0 try to get exact allocation, * cr == 3 try to get anything -@@ -2193,6 +2224,9 @@ repeat: +@@ -2211,6 +2242,9 @@ repeat: if (ac->ac_status != AC_STATUS_CONTINUE) break; } @@ -64,7 +64,7 @@ Index: linux-stage/fs/ext4/mballoc.c } if (ac->ac_b_ex.fe_len > 0 && ac->ac_status != AC_STATUS_FOUND && -@@ -2316,6 +2350,93 @@ static const struct seq_operations ext4_ +@@ -2336,6 +2370,93 @@ static const struct seq_operations ext4_ .show = ext4_mb_seq_groups_show, }; @@ -158,7 +158,7 @@ Index: linux-stage/fs/ext4/mballoc.c #define EXT4_MB_PREALLOC_TABLE "prealloc_table" static int ext4_mb_check_and_update_prealloc(struct ext4_sb_info *sbi, -@@ -2730,6 +2851,8 @@ static int ext4_groupinfo_create_slab(si +@@ -2750,6 +2871,8 @@ static int ext4_groupinfo_create_slab(si return 0; } @@ -167,7 +167,7 @@ Index: linux-stage/fs/ext4/mballoc.c int ext4_mb_init(struct super_block *sb) { struct ext4_sb_info *sbi = EXT4_SB(sb); -@@ -2789,6 +2911,15 @@ int ext4_mb_init(struct super_block *sb) +@@ -2801,6 +2924,15 @@ int ext4_mb_init(struct super_block *sb) sbi->s_mb_min_to_scan = MB_DEFAULT_MIN_TO_SCAN; sbi->s_mb_stats = MB_DEFAULT_STATS; sbi->s_mb_order2_reqs = MB_DEFAULT_ORDER2_REQS; @@ -183,7 +183,7 @@ Index: linux-stage/fs/ext4/mballoc.c /* * The default group preallocation is 512, which for 4k block * sizes translates to 2 megabytes. However for bigalloc file -@@ -2853,6 +2978,8 @@ int ext4_mb_init(struct super_block *sb) +@@ -2873,6 +3005,8 @@ int ext4_mb_init(struct super_block *sb) proc_create_data(EXT4_MB_PREALLOC_TABLE, S_IFREG | S_IRUGO | S_IWUSR, sbi->s_proc, &ext4_mb_prealloc_seq_fops, sb); @@ -192,7 +192,7 @@ Index: linux-stage/fs/ext4/mballoc.c proc_create_data("mb_last_group", S_IFREG | S_IRUGO | S_IWUSR, sbi->s_proc, &ext4_mb_seq_last_group_fops, sb); -@@ -2906,6 +3033,7 @@ int ext4_mb_release(struct super_block * +@@ -2926,6 +3060,7 @@ int ext4_mb_release(struct super_block * remove_proc_entry("mb_last_group", sbi->s_proc); remove_proc_entry("mb_last_start", sbi->s_proc); remove_proc_entry(EXT4_MB_PREALLOC_TABLE, sbi->s_proc); @@ -200,7 +200,7 @@ Index: linux-stage/fs/ext4/mballoc.c } if (sbi->s_group_info) { -@@ -2936,6 +3064,16 @@ int ext4_mb_release(struct super_block * +@@ -2956,6 +3091,16 @@ int ext4_mb_release(struct super_block * atomic_read(&sbi->s_bal_reqs), atomic_read(&sbi->s_bal_success)); ext4_msg(sb, KERN_INFO, @@ -221,7 +221,7 @@ Index: linux-stage/fs/ext4/ext4.h =================================================================== --- linux-stage.orig/fs/ext4/ext4.h +++ linux-stage/fs/ext4/ext4.h -@@ -1409,6 +1409,9 @@ struct ext4_sb_info { +@@ -1412,6 +1412,9 @@ struct ext4_sb_info { unsigned int s_mb_min_to_scan; unsigned int s_mb_stats; unsigned int s_mb_order2_reqs; @@ -231,7 +231,7 @@ Index: linux-stage/fs/ext4/ext4.h unsigned long *s_mb_prealloc_table; unsigned int s_mb_group_prealloc; unsigned int s_max_dir_size_kb; -@@ -1425,6 +1428,9 @@ struct ext4_sb_info { +@@ -1428,6 +1431,9 @@ struct ext4_sb_info { atomic_t s_bal_goals; /* goal hits */ atomic_t s_bal_breaks; /* too long searches */ atomic_t s_bal_2orders; /* 2^order hits */ @@ -241,7 +241,7 @@ Index: linux-stage/fs/ext4/ext4.h spinlock_t s_bal_lock; unsigned long s_mb_buddies_generated; unsigned long long s_mb_generation_time; -@@ -2115,6 +2121,8 @@ struct ext4_sb_info { +@@ -2340,6 +2346,8 @@ extern int ext4_init_inode_table(struct extern void ext4_end_bitmap_read(struct buffer_head *bh, int uptodate); /* mballoc.c */ @@ -254,7 +254,7 @@ Index: linux-stage/fs/ext4/super.c =================================================================== --- linux-stage.orig/fs/ext4/super.c +++ linux-stage/fs/ext4/super.c -@@ -1208,6 +1208,7 @@ enum { +@@ -1228,6 +1228,7 @@ enum { Opt_nomblk_io_submit, Opt_block_validity, Opt_noblock_validity, Opt_inode_readahead_blks, Opt_journal_ioprio, Opt_dioread_nolock, Opt_dioread_lock, @@ -262,7 +262,7 @@ Index: linux-stage/fs/ext4/super.c Opt_no_mbcache, Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable, Opt_max_dir_size_kb, Opt_nojournal_checksum, -@@ -1287,6 +1288,9 @@ static const match_table_t tokens = { +@@ -1307,6 +1308,9 @@ static const match_table_t tokens = { {Opt_nodiscard, "nodiscard"}, {Opt_init_itable, "init_itable=%u"}, {Opt_no_mbcache, "no_mbcache"}, @@ -272,7 +272,7 @@ Index: linux-stage/fs/ext4/super.c {Opt_init_itable, "init_itable"}, {Opt_noinit_itable, "noinit_itable"}, {Opt_max_dir_size_kb, "max_dir_size_kb=%u"}, -@@ -1449,6 +1453,9 @@ static const struct mount_opts { +@@ -1470,6 +1474,9 @@ static const struct mount_opts { {Opt_auto_da_alloc, EXT4_MOUNT_NO_AUTO_DA_ALLOC, MOPT_CLEAR}, {Opt_noinit_itable, EXT4_MOUNT_INIT_INODE_TABLE, MOPT_CLEAR}, {Opt_no_mbcache, EXT4_MOUNT_NO_MBCACHE, MOPT_SET}, @@ -282,7 +282,7 @@ Index: linux-stage/fs/ext4/super.c {Opt_commit, 0, MOPT_GTE0}, {Opt_max_batch_time, 0, MOPT_GTE0}, {Opt_min_batch_time, 0, MOPT_GTE0}, -@@ -1571,6 +1578,12 @@ static const struct mount_opts { +@@ -1616,6 +1623,12 @@ static int handle_mount_opt(struct super sbi->s_max_dir_size_kb = arg; /* reset s_warning_dir_size and make it re-calculated */ sbi->s_warning_dir_size = 0; @@ -295,7 +295,7 @@ Index: linux-stage/fs/ext4/super.c } else if (token == Opt_stripe) { sbi->s_stripe = arg; } else if (token == Opt_resuid) { -@@ -2734,6 +2747,74 @@ static ssize_t sbi_deprecated_show(struc +@@ -2780,6 +2793,74 @@ static ssize_t sbi_deprecated_show(struc return snprintf(buf, PAGE_SIZE, "%d\n", a->u.deprecated_val); } @@ -370,7 +370,7 @@ Index: linux-stage/fs/ext4/super.c #define EXT4_ATTR_OFFSET(_name,_mode,_show,_store,_elname) \ static struct ext4_attr ext4_attr_##_name = { \ .attr = {.name = __stringify(_name), .mode = _mode }, \ -@@ -2790,6 +2857,9 @@ EXT4_RW_ATTR_SBI_UI(mb_stats, s_mb_stats +@@ -2836,6 +2917,9 @@ EXT4_RW_ATTR_SBI_UI(mb_stats, s_mb_stats EXT4_RW_ATTR_SBI_UI(mb_max_to_scan, s_mb_max_to_scan); EXT4_RW_ATTR_SBI_UI(mb_min_to_scan, s_mb_min_to_scan); EXT4_RW_ATTR_SBI_UI(mb_order2_req, s_mb_order2_reqs); @@ -380,7 +380,7 @@ Index: linux-stage/fs/ext4/super.c EXT4_RW_ATTR_SBI_UI(mb_small_req, s_mb_small_req); EXT4_RW_ATTR_SBI_UI(mb_large_req, s_mb_large_req); EXT4_RW_ATTR_SBI_UI(mb_group_prealloc, s_mb_group_prealloc); -@@ -2820,6 +2890,9 @@ static struct attribute *ext4_attrs[] = +@@ -2866,6 +2950,9 @@ static struct attribute *ext4_attrs[] = ATTR_LIST(mb_max_to_scan), ATTR_LIST(mb_min_to_scan), ATTR_LIST(mb_order2_req), @@ -394,16 +394,13 @@ Index: linux-stage/fs/ext4/mballoc.h =================================================================== --- linux-stage.orig/fs/ext4/mballoc.h +++ linux-stage/fs/ext4/mballoc.h -@@ -84,6 +84,12 @@ extern ushort ext4_mballoc_debug; +@@ -84,6 +84,9 @@ extern ushort ext4_mballoc_debug; * for which requests use 2^N search using buddies */ #define MB_DEFAULT_ORDER2_REQS 8 +#define MB_DEFAULT_C1_THRESHOLD 15 +#define MB_DEFAULT_C2_THRESHOLD 10 +#define MB_DEFAULT_C3_THRESHOLD 5 -+#define MB_DEFAULT_MAX_C1_BYTES (15ULL << 40) /* 15TB */ -+#define MB_DEFAULT_MAX_C2_BYTES (10ULL << 40) -+#define MB_DEFAULT_MAX_C3_BYTES (5ULL << 40) /* * default group prealloc size 512 blocks diff --git a/ldiskfs/kernel_patches/patches/rhel8/ext4-simple-blockalloc.patch b/ldiskfs/kernel_patches/patches/rhel8/ext4-simple-blockalloc.patch index f5ecabd..a0a7ae3 100644 --- a/ldiskfs/kernel_patches/patches/rhel8/ext4-simple-blockalloc.patch +++ b/ldiskfs/kernel_patches/patches/rhel8/ext4-simple-blockalloc.patch @@ -193,7 +193,7 @@ index 15c962f..7870406 100644 return 0; } -+#define THRESHOLD_BLOCKS(ts) (ext4_blocks_count(sbi->s_es) / 100 * ts) ++#define THRESHOLD_BLOCKS(sbi, percent) (ext4_blocks_count((sbi)->s_es) / 100 * (percent)) int ext4_mb_init(struct super_block *sb) { struct ext4_sb_info *sbi = EXT4_SB(sb); @@ -201,9 +201,9 @@ index 15c962f..7870406 100644 sbi->s_mb_min_to_scan = MB_DEFAULT_MIN_TO_SCAN; sbi->s_mb_stats = MB_DEFAULT_STATS; sbi->s_mb_order2_reqs = MB_DEFAULT_ORDER2_REQS; -+ sbi->s_mb_c1_blocks = THRESHOLD_BLOCKS(MB_DEFAULT_C1_THRESHOLD); -+ sbi->s_mb_c2_blocks = THRESHOLD_BLOCKS(MB_DEFAULT_C2_THRESHOLD); -+ sbi->s_mb_c3_blocks = THRESHOLD_BLOCKS(MB_DEFAULT_C3_THRESHOLD); ++ sbi->s_mb_c1_blocks = THRESHOLD_BLOCKS(sbi, MB_DEFAULT_C1_THRESHOLD); ++ sbi->s_mb_c2_blocks = THRESHOLD_BLOCKS(sbi, MB_DEFAULT_C2_THRESHOLD); ++ sbi->s_mb_c3_blocks = THRESHOLD_BLOCKS(sbi, MB_DEFAULT_C3_THRESHOLD); /* * The default group preallocation is 512, which for 4k block * sizes translates to 2 megabytes. However for bigalloc file @@ -256,7 +256,7 @@ index 417b33a..f49821e 100644 task_pid_vnr(sbi->s_journal->j_task)); } -+#define THRESHOLD_PERCENT(ts) (ts * 100 / ext4_blocks_count(sbi->s_es)) ++#define THRESHOLD_PERCENT(sbi, blocks) ((blocks) * 100 / ext4_blocks_count((sbi)->s_es)) + +static int save_threshold_percent(struct ext4_sb_info *sbi, const char *buf, + ext4_fsblk_t *blocks) @@ -311,13 +311,13 @@ index 417b33a..f49821e 100644 percpu_counter_sum(&sbi->s_dirtyclusters_counter))); + case attr_mb_c1_threshold: + return scnprintf(buf, PAGE_SIZE, "%llu\n", -+ THRESHOLD_PERCENT(sbi->s_mb_c1_blocks)); ++ THRESHOLD_PERCENT(sbi, sbi->s_mb_c1_blocks)); + case attr_mb_c2_threshold: + return scnprintf(buf, PAGE_SIZE, "%llu\n", -+ THRESHOLD_PERCENT(sbi->s_mb_c2_blocks)); ++ THRESHOLD_PERCENT(sbi, sbi->s_mb_c2_blocks)); + case attr_mb_c3_threshold: + return scnprintf(buf, PAGE_SIZE, "%llu\n", -+ THRESHOLD_PERCENT(sbi->s_mb_c3_blocks)); ++ THRESHOLD_PERCENT(sbi, sbi->s_mb_c3_blocks)); case attr_session_write_kbytes: return session_write_kbytes_show(sbi, buf); case attr_lifetime_write_kbytes: -- 1.8.3.1