diff options
author | Theodore Ts'o <tytso@mit.edu> | 2013-07-26 15:15:46 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-14 22:57:06 -0700 |
commit | b2fea70a4a26d2946b470affd5582d7916be93ab (patch) | |
tree | 118d6d33a6dcaadbbd059747d71d7a29786e4cd4 /fs | |
parent | 3b8d21f4237f7ef442314feec300cdbce72592b5 (diff) | |
download | kernel-common-b2fea70a4a26d2946b470affd5582d7916be93ab.tar.gz kernel-common-b2fea70a4a26d2946b470affd5582d7916be93ab.tar.bz2 kernel-common-b2fea70a4a26d2946b470affd5582d7916be93ab.zip |
ext4: make sure group number is bumped after a inode allocation race
commit a34eb503742fd25155fd6cff6163daacead9fbc3 upstream.
When we try to allocate an inode, and there is a race between two
CPU's trying to grab the same inode, _and_ this inode is the last free
inode in the block group, make sure the group number is bumped before
we continue searching the rest of the block groups. Otherwise, we end
up searching the current block group twice, and we end up skipping
searching the last block group. So in the unlikely situation where
almost all of the inodes are allocated, it's possible that we will
return ENOSPC even though there might be free inodes in that last
block group.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/ialloc.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index e42b4687dbf0..b1c3f2ade2b0 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c @@ -687,11 +687,8 @@ repeat_in_this_group: ino = ext4_find_next_zero_bit((unsigned long *) inode_bitmap_bh->b_data, EXT4_INODES_PER_GROUP(sb), ino); - if (ino >= EXT4_INODES_PER_GROUP(sb)) { - if (++group == ngroups) - group = 0; - continue; - } + if (ino >= EXT4_INODES_PER_GROUP(sb)) + goto next_group; if (group == 0 && (ino+1) < EXT4_FIRST_INO(sb)) { ext4_error(sb, "reserved inode found cleared - " "inode=%lu", ino + 1); @@ -709,6 +706,9 @@ repeat_in_this_group: goto got; /* we grabbed the inode! */ if (ino < EXT4_INODES_PER_GROUP(sb)) goto repeat_in_this_group; +next_group: + if (++group == ngroups) + group = 0; } err = -ENOSPC; goto out; |