Skip to content

Commit 14c83c9

Browse files
committed
ext4: avoid counting the number of free inodes twice in find_group_orlov()
Signed-off-by: "Theodore Ts'o" <[email protected]>
1 parent 88635ca commit 14c83c9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/ext4/ialloc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent,
358358
struct ext4_sb_info *sbi = EXT4_SB(sb);
359359
ext4_group_t real_ngroups = ext4_get_groups_count(sb);
360360
int inodes_per_group = EXT4_INODES_PER_GROUP(sb);
361-
unsigned int freei, avefreei;
361+
unsigned int freei, avefreei, grp_free;
362362
ext4_fsblk_t freeb, avefreec;
363363
unsigned int ndirs;
364364
int max_dirs, min_inodes;
@@ -477,8 +477,8 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent,
477477
for (i = 0; i < ngroups; i++) {
478478
grp = (parent_group + i) % ngroups;
479479
desc = ext4_get_group_desc(sb, grp, NULL);
480-
if (desc && ext4_free_inodes_count(sb, desc) &&
481-
ext4_free_inodes_count(sb, desc) >= avefreei) {
480+
grp_free = ext4_free_inodes_count(sb, desc);
481+
if (desc && grp_free && grp_free >= avefreei) {
482482
*group = grp;
483483
return 0;
484484
}

0 commit comments

Comments
 (0)