ocfs2-improve-write-io-performance-when-fragmentation-is-high.patch removed from -mm tree
The quilt patch titled
Subject: ocfs2: improve write IO performance when fragmentation is high
has been removed from the -mm tree. Its filename was
ocfs2-improve-write-io-performance-when-fragmentation-is-high.patch
This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Heming Zhao <[email protected]>
Subject: ocfs2: improve write IO performance when fragmentation is high
Date: Thu, 28 Mar 2024 20:52:00 +0800
The group_search function ocfs2_cluster_group_search() should bypass groups with insufficient space to avoid unnecessary searches.
This patch is particularly useful when ocfs2 is handling huge number small files, and volume fragmentation is very high. In this case, ocfs2 is busy with looking up available la window from //global_bitmap.
This patch introduces a new member in the Group Description (gd) struct called 'bg_contig_free_bits', representing the max contigous free bits in this gd. When ocfs2 allocates a new la window from //global_bitmap, 'bg_contig_free_bits' helps expedite the search process.
Let's image below path.
1. la state (->local_alloc_state) is set THROTTLED or DISABLED.
2. when user delete a large file and trigger ocfs2_local_alloc_seen_free_bits set osb->local_alloc_state unconditionally.
3. a write IOs thread run and trigger the worst performance path
```
ocfs2_reserve_clusters_with_limit
ocfs2_reserve_local_alloc_bits
ocfs2_local_alloc_slide_window //[1]
+ ocfs2_local_alloc_reserve_for_window //[2]
+ ocfs2_local_alloc_new_window //[3]
ocfs2_recalc_la_window
```[1]:
will be called when la window bits used up.
[2]:
under la state is ENABLED, and this func only check global_bitmap free bits, it will succeed in general.
[3]:
will use the default la window size to search clusters then fail. ocfs2_recalc_la_window attempts other la window sizes. the timing complexity is O(n^4), resulting in a significant time cost for scanning global bitmap. This leads to a dramatic slowdown in write I/Os (e.g., user space 'dd').
i.e.
an ocfs2 partition size: 1.45TB, cluster size: 4KB,
la window default size: 106MB.
The partition is fragmentation by creating & deleting huge mount of small files.
before this patch, the timing of [3] should be
(the number got from real world):
- la window size change order (size: MB):
106, 53, 26.5, 13, 6.5, 3.25, 1.6, 0.8
only 0.8MB succeed, 0.8MB also triggers la window to disable. ocfs2_local_alloc_new_window retries 8 times, first 7 times totally runs in worst case.
- group chain number: 242
ocfs2_claim_suballoc_bits calls for-loop 242 times
- each chain has 49 block group
ocfs2_search_chain calls while-loop 49 times
- each bg has 32256 blocks ocfs2_block_group_find_clear_bits calls while-loop for 32256 bits. for ocfs2_find_next_zero_bit uses ffz() to find zero bit, let's use (32256/64) (this is not worst value) for timing calucation.
the loop times: 7*242*49*(32256/64) = 41835024 (~42 million times)
In the worst case, user space writes 1MB data will trigger 42M scanning times.
under this patch, the timing is '7*242*49 = 83006', reduced by three orders of magnitude.
---
fs/ocfs2/move_extents.c | 2 fs/ocfs2/ocfs2_fs.h | 3 - fs/ocfs2/resize.c | 8 +++ fs/ocfs2/suballoc.c | 100 ++++++++++++++++++++++++++++++++++---- fs/ocfs2/suballoc.h | 6 +- 5 files changed, 108 insertions(+), 11 deletions(-)
fs/ocfs2/move_extents.c renamed from fs/ocfs2/move_extents.c~ocfs2-improve-write-io-performance-when-fragmentation-is-high +1 -1
@@ -685,7 +685,7 @@ static int ocfs2_move_extent(struct ocfs } ret =ocfs2_block_group_set_bits (handle, gb_inode, gd, gd_bh, - goal_bit, len); + goal_bit, len,0 ,0 );if (ret) {ocfs2_rollback_alloc_dinode_counts (gb_inode, gb_bh, len,le16_to_cpu (gd->bg_chain));
fs/ocfs2/ocfs2_fs.h renamed from fs/ocfs2/ocfs2_fs.h~ocfs2-improve-write-io-performance-when-fragmentation-is-high +2 -1
@@ -883,7 +883,8 @@ struct ocfs2_group_desc__le16 bg_free_bits_count;/* Free bits count */ __le16 bg_chain;/* What chain I am in. */ /*10*/ __le32 bg_generation; -__le32 bg_reserved1; +__le16 bg_contig_free_bits;/* max contig free bits length */ +__le16 bg_reserved1;__le64 bg_next_group;/* Next group in my list, in blocks */ /*20*/ __le64 bg_parent_dinode;/* dinode which owns me, in
fs/ocfs2/resize.c renamed from fs/ocfs2/resize.c~ocfs2-improve-write-io-performance-when-fragmentation-is-high +8 -0
@@ -91,6 +91,8 @@ static int ocfs2_update_last_group_and_iu16 cl_bpc =le16_to_cpu (cl->cl_bpc);u16 cl_cpg =le16_to_cpu (cl->cl_cpg);u16 old_bg_clusters; +u16 contig_bits; +__le16 old_bg_contig_free_bits;trace_ocfs2_update_last_group_and_inode (new_clusters, first_new_cluster);
@@ -122,6 +124,11 @@ static int ocfs2_update_last_group_and_ile16_add_cpu (&group->bg_free_bits_count,-1 * backups); } + contig_bits =ocfs2_find_max_contig_free_bits (group->bg_bitmap, +le16_to_cpu (group->bg_bits),0 ); + old_bg_contig_free_bits = group->bg_contig_free_bits; + group->bg_contig_free_bits =cpu_to_le16 (contig_bits); +ocfs2_journal_dirty (handle, group_bh);/* update the inode accordingly. */
@@ -160,6 +167,7 @@ out_rollback:le16_add_cpu (&group->bg_free_bits_count, backups);le16_add_cpu (&group->bg_bits,-1 * num_bits);le16_add_cpu (&group->bg_free_bits_count,-1 * num_bits); + group->bg_contig_free_bits = old_bg_contig_free_bits; } out:if (ret)
fs/ocfs2/suballoc.c renamed from fs/ocfs2/suballoc.c~ocfs2-improve-write-io-performance-when-fragmentation-is-high +92 -8
213 lines not on this page · raw message
fs/ocfs2/suballoc.h renamed from fs/ocfs2/suballoc.h~ocfs2-improve-write-io-performance-when-fragmentation-is-high +5 -1
@@ -79,12 +79,16 @@ void ocfs2_rollback_alloc_dinode_counts(struct buffer_head *di_bh, u32 num_bits, u16 chain); +u16 ocfs2_find_max_contig_free_bits (void *bitmap, +u16 total_bits,u16 start);int ocfs2_block_group_set_bits (handle_t *handle,struct inode *alloc_inode,struct ocfs2_group_desc *bg,struct buffer_head *group_bh,unsigned int bit_off, -unsigned int num_bits); +unsigned int num_bits, +unsigned int max_contig_bits, +int fastpath); int ocfs2_claim_metadata(handle_t *handle, struct ocfs2_alloc_context *ac,
_
Patches currently in -mm which might be from [email protected] are