From 1ccc52da7414574c215d330e796875f34bb78110 Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Thu, 21 Nov 2024 08:55:54 +0700 Subject: [PATCH] LU-18471 ldiskfs: large directory causes htree corruption When creating a lot of files in a single directory, it can get corrupted because of a typo in ext4-kill-dx-root.patch. Lustre-change: https://review.whamcloud.com/46526 Lustre-commit: ea3ee9337f9bcd42360e4523f1e34bcd04d3bf41 Test-Parameters: trivial HPE-bug-id: LUS-12617 Fixes: 8da23f070c ("LU-15544 ldiskfs: SUSE 15 SP4 kernel 5.14.21 SUSE") Fixes: fc87b01f96 ("LU-12477 ldiskfs: remove obsolete ext4 patches") Fixes: 89075044b3 ("LU-12477 ldiskfs: drop SUSE kernel 4.4 and earlier") Signed-off-by: Shaun Tancheff Change-Id: Iacbaf9840db76ea7e2e017835a14b476ca9be391 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57094 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Alex Zhuravlev Reviewed-by: Artem Blagodarenko Reviewed-by: Andrew Perepechko Reviewed-by: Oleg Drokin --- .../patches/linux-5.14/ext4-kill-dx-root.patch | 14 ++++++++++++-- .../kernel_patches/patches/rhel7.6/ext4-kill-dx-root.patch | 11 ++++++++++- .../kernel_patches/patches/rhel7.7/ext4-large-dir.patch | 9 +++------ .../kernel_patches/patches/suse15/ext4-kill-dx-root.patch | 11 ++++++++++- 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/ldiskfs/kernel_patches/patches/linux-5.14/ext4-kill-dx-root.patch b/ldiskfs/kernel_patches/patches/linux-5.14/ext4-kill-dx-root.patch index 505c7f3..c1ca5a9 100644 --- a/ldiskfs/kernel_patches/patches/linux-5.14/ext4-kill-dx-root.patch +++ b/ldiskfs/kernel_patches/patches/linux-5.14/ext4-kill-dx-root.patch @@ -1,5 +1,15 @@ -Subject: [PATCH] linux-5.14/ext4-kill-dx-root.patch +removes static definition of dx_root struct. so that "." and ".." dirent can +have extra data. This patch does not change any functionality but is required for +ext4_data_in_dirent patch. +Signed-off-by: Bob Glossman +Signed-off-by: Yang Sheng +Change-Id: Ifbc294a53bd21eb35d373637d3326fc3c611c9f0 +Reviewed-on: http://review.whamcloud.com/10249 +Tested-by: Jenkins +Tested-by: Maloo +Reviewed-by: Andreas Dilger +Reviewed-by: Oleg Drokin --- fs/ext4/namei.c | 119 +++++++++++++++++++++++++----------------------- 1 file changed, 61 insertions(+), 58 deletions(-) @@ -251,7 +261,7 @@ index e4514c9..92d29fe 100644 - dxroot->info.indirect_levels += 1; + info = dx_get_dx_info((struct ext4_dir_entry_2 *) + frames[0].bh->b_data); -+ info->indirect_levels = 1; ++ info->indirect_levels += 1; dxtrace(printk(KERN_DEBUG "Creating %d level index...\n", dxroot->info.indirect_levels)); diff --git a/ldiskfs/kernel_patches/patches/rhel7.6/ext4-kill-dx-root.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-kill-dx-root.patch index 37caa04..d21cedb 100644 --- a/ldiskfs/kernel_patches/patches/rhel7.6/ext4-kill-dx-root.patch +++ b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-kill-dx-root.patch @@ -1,6 +1,15 @@ removes static definition of dx_root struct. so that "." and ".." dirent can have extra data. This patch does not change any functionality but is required for ext4_data_in_dirent patch. + +Signed-off-by: Bob Glossman +Signed-off-by: Yang Sheng +Change-Id: Ifbc294a53bd21eb35d373637d3326fc3c611c9f0 +Reviewed-on: http://review.whamcloud.com/10249 +Tested-by: Jenkins +Tested-by: Maloo +Reviewed-by: Andreas Dilger +Reviewed-by: Oleg Drokin Index: linux-3.10.0-123.9.3.el7.x86_64/fs/ext4/namei.c =================================================================== @@ -241,7 +250,7 @@ Index: linux-3.10.0-123.9.3.el7.x86_64/fs/ext4/namei.c - ((struct dx_root *) frames[0].bh->b_data)->info.indirect_levels = 1; + info = dx_get_dx_info((struct ext4_dir_entry_2 *) + frames[0].bh->b_data); -+ info->indirect_levels = 1; ++ info->indirect_levels += 1; /* Add new access path frame */ frame = frames + 1; diff --git a/ldiskfs/kernel_patches/patches/rhel7.7/ext4-large-dir.patch b/ldiskfs/kernel_patches/patches/rhel7.7/ext4-large-dir.patch index 765fd7e..98ac24e 100644 --- a/ldiskfs/kernel_patches/patches/rhel7.7/ext4-large-dir.patch +++ b/ldiskfs/kernel_patches/patches/rhel7.7/ext4-large-dir.patch @@ -279,12 +279,10 @@ Index: linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/namei.c icount * sizeof(struct dx_entry)); dx_set_limit(entries2, dx_node_limit(dir)); -@@ -2224,22 +2267,17 @@ static int ext4_dx_add_entry(handle_t *h - dx_set_block(entries + 0, newblock); - info = dx_get_dx_info((struct ext4_dir_entry_2*) +@@ -2348,20 +2391,16 @@ static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry, frames[0].bh->b_data); -- info->indirect_levels = 1; -- + info->indirect_levels += 1; + - /* Add new access path frame */ - frame = frames + 1; - frame->at = at = at - entries + entries2; @@ -292,7 +290,6 @@ Index: linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/namei.c - frame->bh = bh2; - err = ext4_journal_get_write_access(handle, - frame->bh); -+ info->indirect_levels += 1; + dxtrace(printk(KERN_DEBUG + "Creating %d level index...\n", + info->indirect_levels)); diff --git a/ldiskfs/kernel_patches/patches/suse15/ext4-kill-dx-root.patch b/ldiskfs/kernel_patches/patches/suse15/ext4-kill-dx-root.patch index 231f76b..b0bcdf0 100644 --- a/ldiskfs/kernel_patches/patches/suse15/ext4-kill-dx-root.patch +++ b/ldiskfs/kernel_patches/patches/suse15/ext4-kill-dx-root.patch @@ -1,6 +1,15 @@ removes static definition of dx_root struct. so that "." and ".." dirent can have extra data. This patch does not change any functionality but is required for ext4_data_in_dirent patch. + +Signed-off-by: Bob Glossman +Signed-off-by: Yang Sheng +Change-Id: Ifbc294a53bd21eb35d373637d3326fc3c611c9f0 +Reviewed-on: http://review.whamcloud.com/10249 +Tested-by: Jenkins +Tested-by: Maloo +Reviewed-by: Andreas Dilger +Reviewed-by: Oleg Drokin Index: linux-3.10.0-123.9.3.el7.x86_64/fs/ext4/namei.c =================================================================== @@ -216,7 +225,7 @@ Index: linux-3.10.0-123.9.3.el7.x86_64/fs/ext4/namei.c - ((struct dx_root *) frames[0].bh->b_data)->info.indirect_levels = 1; + info = dx_get_dx_info((struct ext4_dir_entry_2 *) + frames[0].bh->b_data); -+ info->indirect_levels = 1; ++ info->indirect_levels += 1; /* Add new access path frame */ frame = frames + 1; -- 1.8.3.1