Commit c001077f authored by Eric Sandeen's avatar Eric Sandeen Committed by Theodore Ts'o

ext4: Fix bug where we return ENOSPC even though we have plenty of inodes

The find_group_flex() function starts with best_flex as the
parent_fbg_group, which happens to have 0 inodes free.  Some of the
flex groups searched have free blocks and free inodes, but the
flex_freeb_ratio is < 10, so they're skipped.  Then when a group is
compared to the current "best" flex group, it does not have more free
blocks than "best", so it is skipped as well.

This continues until no flex group with free inodes is found which has
a proper ratio or which has more free blocks than the "best" group,
and we're left with a "best" group that has 0 inodes free, and we
return -ENOSPC.

We fix this by changing the logic so that if the current "best" flex
group has no inodes free, and the current one does have room, it is
promoted to the next "best."
Signed-off-by: default avatarEric Sandeen <sandeen@redhat.com>
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent 37609fd5
...@@ -351,7 +351,7 @@ find_close_to_parent: ...@@ -351,7 +351,7 @@ find_close_to_parent:
goto found_flexbg; goto found_flexbg;
} }
if (best_flex < 0 || if (flex_group[best_flex].free_inodes == 0 ||
(flex_group[i].free_blocks > (flex_group[i].free_blocks >
flex_group[best_flex].free_blocks && flex_group[best_flex].free_blocks &&
flex_group[i].free_inodes)) flex_group[i].free_inodes))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment