Skip to content

Commit c55ee7d

Browse files
brookxu-cntytso
authored andcommitted
ext4: add mb_debug logging when there are lost chunks
Lost chunks are when some other process raced with the current thread to grab a particular block allocation. Add mb_debug log for developers who wants to see how often this is happening for a particular workload. Signed-off-by: Chunguang Xu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 7ca4fcb commit c55ee7d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

fs/ext4/mballoc.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2309,6 +2309,7 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac)
23092309
struct ext4_sb_info *sbi;
23102310
struct super_block *sb;
23112311
struct ext4_buddy e4b;
2312+
unsigned int lost;
23122313

23132314
sb = ac->ac_sb;
23142315
sbi = EXT4_SB(sb);
@@ -2456,22 +2457,24 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac)
24562457
* We've been searching too long. Let's try to allocate
24572458
* the best chunk we've found so far
24582459
*/
2459-
24602460
ext4_mb_try_best_found(ac, &e4b);
24612461
if (ac->ac_status != AC_STATUS_FOUND) {
24622462
/*
24632463
* Someone more lucky has already allocated it.
24642464
* The only thing we can do is just take first
24652465
* found block(s)
2466-
printk(KERN_DEBUG "EXT4-fs: someone won our chunk\n");
24672466
*/
2467+
lost = (unsigned int)atomic_inc_return(&sbi->s_mb_lost_chunks);
2468+
mb_debug(sb, "lost chunk, group: %u, start: %d, len: %d, lost: %u\n",
2469+
ac->ac_b_ex.fe_group, ac->ac_b_ex.fe_start,
2470+
ac->ac_b_ex.fe_len, lost);
2471+
24682472
ac->ac_b_ex.fe_group = 0;
24692473
ac->ac_b_ex.fe_start = 0;
24702474
ac->ac_b_ex.fe_len = 0;
24712475
ac->ac_status = AC_STATUS_CONTINUE;
24722476
ac->ac_flags |= EXT4_MB_HINT_FIRST;
24732477
cr = 3;
2474-
atomic_inc(&sbi->s_mb_lost_chunks);
24752478
goto repeat;
24762479
}
24772480
}

0 commit comments

Comments
 (0)