• Andrew Morton's avatar
    [PATCH] ext2: inode allocation race fix · 6501a85b
    Andrew Morton authored
    ext2's inode allocator will call find_group_orlov(), which will return a
    suitable blockgroup in which the inode should be allocated.  But by the time
    we actually try to allocate an inode in the blockgroup, other CPUs could have
    used them all up.
    
    ext2 will bogusly fail with "ext2_new_inode: Free inodes count corrupted in
    group NN".
    
    
    To fix this we just advance onto the next blockgroup if the rare race
    happens.  If we've scanned all blockgroups then return -ENOSPC.
    
    
    (This is a bit inaccurate: after we've scanned all blockgroups, there may
    still be available inodes due to inode freeing activity in other blockgroups.
     This cannot be fixed without fs-wide locking.  The effect is a slightly
    early ENOSPC in a nearly-full filesystem).
    6501a85b
ialloc.c 21.2 KB