Skip to content

Commit bc2fbaa

Browse files
Mikulas Patockajankara
authored andcommitted
ext2: fix missing percpu_counter_inc
sbi->s_freeinodes_counter is only decreased by the ext2 code, it is never increased. This patch fixes it. Note that sbi->s_freeinodes_counter is only used in the algorithm that tries to find the group for new allocations, so this bug is not easily visible (the only visibility is that the group finding algorithm selects inoptinal result). Link: https://lore.kernel.org/r/alpine.LRH.2.02.2004201538300.19436@file01.intranet.prod.int.rdu2.redhat.com Signed-off-by: Mikulas Patocka <[email protected]> Cc: [email protected] Signed-off-by: Jan Kara <[email protected]>
1 parent a43850a commit bc2fbaa

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/ext2/ialloc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ static void ext2_release_inode(struct super_block *sb, int group, int dir)
8080
if (dir)
8181
le16_add_cpu(&desc->bg_used_dirs_count, -1);
8282
spin_unlock(sb_bgl_lock(EXT2_SB(sb), group));
83+
percpu_counter_inc(&EXT2_SB(sb)->s_freeinodes_counter);
8384
if (dir)
8485
percpu_counter_dec(&EXT2_SB(sb)->s_dirs_counter);
8586
mark_buffer_dirty(bh);
@@ -528,7 +529,7 @@ struct inode *ext2_new_inode(struct inode *dir, umode_t mode,
528529
goto fail;
529530
}
530531

531-
percpu_counter_add(&sbi->s_freeinodes_counter, -1);
532+
percpu_counter_dec(&sbi->s_freeinodes_counter);
532533
if (S_ISDIR(mode))
533534
percpu_counter_inc(&sbi->s_dirs_counter);
534535

0 commit comments

Comments
 (0)