More commit description fixups
[ext4-patch-queue.git] / fix-flex_bg-ialloc
blobcc95c550f05794bb337dbd0afe61e215a32a96db
1 ext4: Fix bug where we return ENOSPC even though we have plenty of inodes
3 From: Eric Sandeen <sandeen@redhat.com>
5 The find_group_flex() function starts with best_flex as the
6 parent_fbg_group, which happens to have 0 inodes free.  Some of the
7 flex groups searched have free blocks and free inodes, but the
8 flex_freeb_ratio is < 10, so they're skipped.  Then when a group is
9 compared to the current "best" flex group, it does not have more free
10 blocks than "best", so it is skipped as well.
12 This continues until no flex group with free inodes is found which has
13 a proper ratio or which has more free blocks than the "best" group,
14 and we're left with a "best" group that has 0 inodes free, and we
15 return -ENOSPC.
17 We fix this by changing the logic so that if the current "best" flex
18 group has no inodes free, and the current one does have room, it is
19 promoted to the next "best."
21 Signed-off-by: Eric Sandeen <sandeen@redhat.com>
22 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
23 ---
25 Index: linux-2.6/fs/ext4/ialloc.c
26 ===================================================================
27 --- linux-2.6.orig/fs/ext4/ialloc.c     2008-08-04 15:30:30.000000000 -0500
28 +++ linux-2.6/fs/ext4/ialloc.c  2008-08-15 16:12:47.366515679 -0500
29 @@ -351,7 +351,7 @@ find_close_to_parent:
30                         goto found_flexbg;
31                 }
33 -               if (best_flex < 0 ||
34 +               if (flex_group[best_flex].free_inodes == 0 ||
35                     (flex_group[i].free_blocks >
36                      flex_group[best_flex].free_blocks &&
37                      flex_group[i].free_inodes))