[PATCH V2 0/7] ext4: get discard out of jbd2 commit kthread

From: Wang Jianchao
Date: Wed May 26 2021 - 04:43:10 EST


Hi

This is the version 2 patch set that attempts to get discard out of the jbd2
commit kthread. When the user delete a lot data and cause discard flooding,
the jbd2 commit kthread can be blocked for very long time and then all of
the metadata operations are blocked due to no journal space.

This version patch is based on Ted's suggestion that free the blocks after
commit immediately and then use a background kworker to do the discard with
the fstrim fashion. The discard maybe slower than before but it doesn't matter
as the blocks has been freed back to mb allocator and nothing would be blocked.

There are 7 patches,

Patch 1 ~ 4, there are no functional changes in them, but just some preparation
for following patches

Patch 5 does the buddy cache get only after insert ext4_free_data successfully

Patch 6 get rid of the s_freed_data_list which carries ext4_free_data and iterate
free data rbtree to get ext4_free_data. This is also a preparation.

Patch 7 introduces a async kworker to do discard which implements the core idea
of this patch set.


Any comments are welcome ;)

Chagnes from V1:
- free blocks back to mb allocator immediately after commit and do discard
in fstrim fashion.

Wang Jianchao (7):
ext4: remove the 'group' parameter of ext4_trim_extent
ext4: add new helper interface ext4_try_to_trim_range()
ext4: add new helper interface ext4_insert_free_data
ext4: remove the repeated comment of ext4_trim_all_free
ext4: get buddy cache after insert successfully
ext4: use bb_free_root to get the free data entry
ext4: get discard out of jbd2 commit kthread context


fs/ext4/balloc.c | 2 +-
fs/ext4/ext4.h | 6 +-
fs/ext4/mballoc.c | 434 ++++++++++++++++++++++++++++++++++++++++++++------------------------------------
fs/ext4/mballoc.h | 3 -
4 files changed, 241 insertions(+), 204 deletions(-)