Skip to content

Commit f51dac0

Browse files
zhaohemakpm00
authored andcommitted
ocfs2: adjust enabling place for la window
Patch series "improve write IO performance when fragmentation is high", v6. This patch (of 4): After introducing gd->bg_contig_free_bits, the code path 'ocfs2_cluster_group_search() => ocfs2_local_alloc_seen_free_bits()' becomes death when all the gd->bg_contig_free_bits are set to the correct value. This patch relocates ocfs2_local_alloc_seen_free_bits() to a more appropriate location. (The new place being ocfs2_block_group_set_bits().) In ocfs2_local_alloc_seen_free_bits(), the scope of the spin-lock has been adjusted to reduce meaningless lock races. e.g: when userspace creates & deletes 1 cluster_size files in parallel, acquiring the spin-lock in ocfs2_local_alloc_seen_free_bits() is totally pointless and impedes IO performance. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Heming Zhao <[email protected]> Reviewed-by: Joseph Qi <[email protected]> Cc: Mark Fasheh <[email protected]> Cc: Joel Becker <[email protected]> Cc: Junxiao Bi <[email protected]> Cc: Changwei Ge <[email protected]> Cc: Gang He <[email protected]> Cc: Jun Piao <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 4eb7b93 commit f51dac0

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

fs/ocfs2/localalloc.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,14 +212,15 @@ static inline int ocfs2_la_state_enabled(struct ocfs2_super *osb)
212212
void ocfs2_local_alloc_seen_free_bits(struct ocfs2_super *osb,
213213
unsigned int num_clusters)
214214
{
215-
spin_lock(&osb->osb_lock);
216-
if (osb->local_alloc_state == OCFS2_LA_DISABLED ||
217-
osb->local_alloc_state == OCFS2_LA_THROTTLED)
218-
if (num_clusters >= osb->local_alloc_default_bits) {
215+
if (num_clusters >= osb->local_alloc_default_bits) {
216+
spin_lock(&osb->osb_lock);
217+
if (osb->local_alloc_state == OCFS2_LA_DISABLED ||
218+
osb->local_alloc_state == OCFS2_LA_THROTTLED) {
219219
cancel_delayed_work(&osb->la_enable_wq);
220220
osb->local_alloc_state = OCFS2_LA_ENABLED;
221221
}
222-
spin_unlock(&osb->osb_lock);
222+
spin_unlock(&osb->osb_lock);
223+
}
223224
}
224225

225226
void ocfs2_la_enable_worker(struct work_struct *work)

fs/ocfs2/suballoc.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,7 @@ int ocfs2_block_group_set_bits(handle_t *handle,
13721372
int journal_type = OCFS2_JOURNAL_ACCESS_WRITE;
13731373
unsigned int start = bit_off + num_bits;
13741374
u16 contig_bits;
1375+
struct ocfs2_super *osb = OCFS2_SB(alloc_inode->i_sb);
13751376

13761377
/* All callers get the descriptor via
13771378
* ocfs2_read_group_descriptor(). Any corruption is a code bug. */
@@ -1421,6 +1422,7 @@ int ocfs2_block_group_set_bits(handle_t *handle,
14211422
if (contig_bits > max_contig_bits)
14221423
max_contig_bits = contig_bits;
14231424
bg->bg_contig_free_bits = cpu_to_le16(max_contig_bits);
1425+
ocfs2_local_alloc_seen_free_bits(osb, max_contig_bits);
14241426
} else {
14251427
bg->bg_contig_free_bits = 0;
14261428
}
@@ -1587,13 +1589,6 @@ static int ocfs2_cluster_group_search(struct inode *inode,
15871589
* of bits. */
15881590
if (min_bits <= res->sr_bits)
15891591
search = 0; /* success */
1590-
else if (res->sr_bits) {
1591-
/*
1592-
* Don't show bits which we'll be returning
1593-
* for allocation to the local alloc bitmap.
1594-
*/
1595-
ocfs2_local_alloc_seen_free_bits(osb, res->sr_bits);
1596-
}
15971592
}
15981593

15991594
return search;

0 commit comments

Comments
 (0)