mbox series

[v2,00/20] Some bugfix and cleanup to mballoc

Message ID 20230228114306.3328235-1-shikemeng@huaweicloud.com
Headers show
Series Some bugfix and cleanup to mballoc | expand

Message

Kemeng Shi Feb. 28, 2023, 11:42 a.m. UTC
Hi, this series contain some random cleanup patches and some bugfix
patches to make EXT4_MB_HINT_GOAL_ONLY work properly, protect pa->pa_free
from race and so on. More details can be found in git log.
Thanks!

---
V2:
-Add signed-off from Ritesh and Ojaswin to patch 3/20 "ext4: get correct
ext4_group_info in ext4_mb_prefetch_fini" as this is a duplicate of
a patch under reviewing.
-Split out original patch "ext4: avoid to use preallocated blocks if
EXT4_MB_HINT_GOAL_ONLY is set" which will be resend after improved.
-Improve log information of patch 20.
-Collect Reviewed-by from Ojaswin and Ritesh. Now only patch 3, 12 and
20 need futher review.
---

Kemeng Shi (20):
  ext4: set goal start correctly in ext4_mb_normalize_request
  ext4: allow to find by goal if EXT4_MB_HINT_GOAL_ONLY is set
  ext4: get correct ext4_group_info in ext4_mb_prefetch_fini
  ext4: correct calculation of s_mb_preallocated
  ext4: correct start of used group pa for debug in ext4_mb_use_group_pa
  ext4: protect pa->pa_free in ext4_discard_allocated_blocks
  ext4: add missed brelse in ext4_free_blocks_simple
  ext4: remove unused return value of ext4_mb_try_best_found and
    ext4_mb_free_metadata
  ext4: Remove unnecessary release when memory allocation failed in
    ext4_mb_init_cache
  ext4: remove unnecessary e4b->bd_buddy_page check in
    ext4_mb_load_buddy_gfp
  ext4: remove unnecessary check in ext4_mb_new_blocks
  ext4: remove dead check in mb_buddy_mark_free
  ext4: remove ac->ac_found > sbi->s_mb_min_to_scan dead check in
    ext4_mb_check_limits
  ext4: use best found when complex scan of group finishs
  ext4: remove unnecessary exit_meta_group_info tag
  ext4: remove unnecessary count2 in ext4_free_data_in_buddy
  ext4: remove unnecessary goto in ext4_mb_mark_diskspace_used
  ext4: remove repeat assignment to ac_f_ex
  ext4: remove comment code ext4_discard_preallocations
  ext4: simplify calculation of blkoff in ext4_mb_new_blocks_simple

 fs/ext4/mballoc.c | 104 +++++++++++++++++-----------------------------
 1 file changed, 38 insertions(+), 66 deletions(-)

Comments

Ritesh Harjani (IBM) Feb. 28, 2023, 4:34 p.m. UTC | #1
Kemeng Shi <shikemeng@huaweicloud.com> writes:

> Hi, this series contain some random cleanup patches and some bugfix
> patches to make EXT4_MB_HINT_GOAL_ONLY work properly, protect pa->pa_free
> from race and so on. More details can be found in git log.
> Thanks!

Hi Kemeng,

Did you run any testing on these patches? Because I was very easily able
to hit ext/009 causing kernel BUG_ON with default mkfs/mount options.
It's always a good and recommended practice to ensure some level of
testing on any of the patches we submit to community for review
and call out in the cover letter on what has been tested and what is not.

<Call stack>

[  208.545365] run fstests ext4/009 at 2023-02-28 21:44:06
[  216.581660] EXT4-fs (loop7): mounted filesystem 33805b33-04c1-48c3-8de3-9c78f99a7598 with ordered data mode..
[  216.709050] EXT4-fs (loop7): unmounting filesystem 33805b33-04c1-48c3-8de3-9c78f99a7598.
[  218.878042] EXT4-fs (loop7): mounted filesystem 8a919af6-f8f4-4ef4-949b-673ccd9ae8c7 with ordered data mode..
[  255.517357] ------------[ cut here ]------------
[  255.520274] kernel BUG at fs/ext4/ext4.h:3331!
[  255.522233] invalid opcode: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC KASAN PTI
[  255.524740] CPU: 7 PID: 2567 Comm: xfs_io Not tainted 6.2.0-rc8-xfstests-00041-gb1b4634ed055 #21
[  255.527807] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.15.0-0-g2dd4b9b3f840-prebuilt.4
[  255.531645] RIP: 0010:ext4_get_group_info+0x272/0x2f0
[  255.533682] Code: 0f 85 a9 fe ff ff 48 c7 c2 c0 9b 7d 84 be fd 02 00 00 48 c7 c7 c0 95 7d 84 c6 05 9e b4 3b 8
[  255.539798] RSP: 0018:ffff8881fcd6f6b0 EFLAGS: 00010246
[  255.541721] RAX: 0000000000000000 RBX: ffff8881bfc54000 RCX: ffffffff81ec3d1a
[  255.544181] RDX: 1ffff11040b8a208 RSI: 0000000000000050 RDI: ffff888205c51040
[  255.546695] RBP: ffff888205c51000 R08: 0000000000000000 R09: ffff8881bfc54000
[  255.549151] R10: ffffed102af9756b R11: ffff8881fcd6f5b4 R12: ffff8881fcd6f8a8
[  255.551588] R13: ffff8881bfc546e8 R14: ffff888157c189b8 R15: ffff888157c189e0
[  255.554039] FS:  00007ffff7e58840(0000) GS:ffff8883ecc00000(0000) knlGS:0000000000000000
[  255.556788] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  255.558806] CR2: 00007ffff7a7bd58 CR3: 0000000181db4005 CR4: 0000000000170ee0
[  255.561259] Call Trace:
[  255.562248]  <TASK>
[  255.563164]  ? kasan_set_track+0x25/0x30
[  255.564710]  ext4_mb_find_by_goal+0xf1/0xda0
[  255.566317]  ? ext4_alloc_file_blocks.isra.0+0x2a7/0x9a0
[  255.568230]  ? ext4_fallocate+0x28b/0x7d0
[  255.569727]  ? vfs_fallocate+0x2b0/0xb90
[  255.571238]  ? __x64_sys_fallocate+0xb9/0x110
[  255.572852]  ? do_syscall_64+0x3f/0x90
[  255.574372]  ? __pfx_ext4_mb_find_by_goal+0x10/0x10
[  255.576131]  ? set_track_prepare+0x40/0x70
[  255.577677]  ? kmem_cache_alloc+0x388/0x440
[  255.579207]  ext4_mb_regular_allocator+0x1f7/0x1970
[  255.580981]  ? entry_SYSCALL_64_after_hwframe+0x72/0xdc
[  255.582874]  ? ___slab_alloc+0xc93/0xd40
[  255.584329]  ? ext4_mb_new_blocks+0xc8f/0x15c0
[  255.585976]  ? __pfx___lock_release+0x10/0x10
[  255.587652]  ? __pfx_ext4_mb_regular_allocator+0x10/0x10
[  255.589554]  ? rcu_read_lock_sched_held+0x47/0x80
[  255.591293]  ? trace_kmem_cache_alloc+0x2d/0xe0
[  255.592997]  ? kmem_cache_alloc+0x25a/0x440
[  255.594552]  ? ext4_mb_new_blocks+0xc8f/0x15c0
[  255.596176]  ext4_mb_new_blocks+0xd3b/0x15c0
[  255.597767]  ? ext4_find_extent+0x742/0xbf0
[  255.599301]  ? __pfx_ext4_mb_new_blocks+0x10/0x10
[  255.601021]  ? lock_is_held_type+0xda/0x130
[  255.602601]  ext4_ext_map_blocks+0x151a/0x2490
[  255.604237]  ? __pfx_ext4_ext_map_blocks+0x10/0x10
[  255.605980]  ? __pfx___lock_acquired+0x10/0x10
[  255.607648]  ? lock_is_held_type+0xda/0x130
[  255.609199]  ? ext4_map_blocks+0x6c9/0x1670
[  255.610757]  ? ext4_map_blocks+0x6c9/0x1670
[  255.612289]  ? lock_acquired+0x10d/0x2b0
[  255.613759]  ? rcu_read_lock_sched_held+0x47/0x80
[  255.615467]  ? ext4_es_lookup_extent+0x43e/0xa20
[  255.617152]  ext4_map_blocks+0x724/0x1670
[  255.618655]  ? lock_is_held_type+0xda/0x130
[  255.620179]  ? __pfx_ext4_map_blocks+0x10/0x10
[  255.621813]  ? rcu_read_lock_sched_held+0x47/0x80
[  255.623512]  ? jbd2__journal_start+0x4ef/0x780
[  255.625191]  ext4_alloc_file_blocks.isra.0+0x2a7/0x9a0
[  255.627019]  ? __pfx_ext4_alloc_file_blocks.isra.0+0x10/0x10
[  255.629034]  ? __pfx_file_modified_flags+0x10/0x10
[  255.630797]  ? lock_is_held_type+0xda/0x130
[  255.632320]  ext4_fallocate+0x28b/0x7d0
[  255.633855]  vfs_fallocate+0x2b0/0xb90
[  255.635252]  __x64_sys_fallocate+0xb9/0x110
[  255.636789]  do_syscall_64+0x3f/0x90
[  255.638135]  entry_SYSCALL_64_after_hwframe+0x72/0xdc


-ritesh
Theodore Ts'o Feb. 28, 2023, 10:30 p.m. UTC | #2
On Tue, Feb 28, 2023 at 10:04:35PM +0530, Ritesh Harjani wrote:
> Kemeng Shi <shikemeng@huaweicloud.com> writes:
> 
> > Hi, this series contain some random cleanup patches and some bugfix
> > patches to make EXT4_MB_HINT_GOAL_ONLY work properly, protect pa->pa_free
> > from race and so on. More details can be found in git log.
> > Thanks!
> 
> Hi Kemeng,
> 
> Did you run any testing on these patches? Because I was very easily able
> to hit ext/009 causing kernel BUG_ON with default mkfs/mount options.
> It's always a good and recommended practice to ensure some level of
> testing on any of the patches we submit to community for review
> and call out in the cover letter on what has been tested and what is not.

Hi Kemeng,

If you need help running xfstests, I maintain a test appliance which
makes it very easy to run xfstests on development kernels.  Please see:

https://github.com/tytso/xfstests-bld/blob/master/Documentation/kvm-xfstests.md
https://github.com/tytso/xfstests-bld/blob/master/Documentation/kvm-quickstart.md

This test appliance can also be run on Android devices and using
Google Compute Engine; for more information see:

	https://thunk.org/android-xfstests
	https://thunk.org/gce-xfstests

If you're just getting started, I recommend that you start with
kvm-xfstests, and this is the simplest way to get started.

Cheers,

					- Ted
Kemeng Shi March 1, 2023, 1:28 a.m. UTC | #3
on 3/1/2023 6:30 AM, Theodore Ts'o wrote:
> On Tue, Feb 28, 2023 at 10:04:35PM +0530, Ritesh Harjani wrote:
>> Kemeng Shi <shikemeng@huaweicloud.com> writes:
>>
>>> Hi, this series contain some random cleanup patches and some bugfix
>>> patches to make EXT4_MB_HINT_GOAL_ONLY work properly, protect pa->pa_free
>>> from race and so on. More details can be found in git log.
>>> Thanks!
>>
>> Hi Kemeng,
>>
>> Did you run any testing on these patches? Because I was very easily able
>> to hit ext/009 causing kernel BUG_ON with default mkfs/mount options.
>> It's always a good and recommended practice to ensure some level of
>> testing on any of the patches we submit to community for review
>> and call out in the cover letter on what has been tested and what is not.
> 
> Hi Kemeng,
> 
> If you need help running xfstests, I maintain a test appliance which
> makes it very easy to run xfstests on development kernels.  Please see:
> 
> https://github.com/tytso/xfstests-bld/blob/master/Documentation/kvm-xfstests.md
> https://github.com/tytso/xfstests-bld/blob/master/Documentation/kvm-quickstart.md
> 
> This test appliance can also be run on Android devices and using
> Google Compute Engine; for more information see:
> 
> 	https://thunk.org/android-xfstests
> 	https://thunk.org/gce-xfstests
> 
> If you're just getting started, I recommend that you start with
> kvm-xfstests, and this is the simplest way to get started.
Hi, Theodore and Ritesh. Thanks for feedback. I will run xfstests before submitting
next version. Thanks!