Skip to content

Commit

Permalink
ext4: trim allocation requests to group size
Browse files Browse the repository at this point in the history
If filesystem groups are artifically small (using parameter -g to
mkfs.ext4), ext4_mb_normalize_request() can result in a request that is
larger than a block group. Trim the request size to not confuse
allocation code.

Reported-by: "Kirill A. Shutemov" <[email protected]>
Signed-off-by: Jan Kara <[email protected]>
Signed-off-by: Theodore Ts'o <[email protected]>
Cc: [email protected]
  • Loading branch information
jankara authored and tytso committed Jan 27, 2017
1 parent 43c7322 commit cd648b8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions fs/ext4/mballoc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3133,6 +3133,13 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac,
if (ar->pright && start + size - 1 >= ar->lright)
size -= start + size - ar->lright;

/*
* Trim allocation request for filesystems with artificially small
* groups.
*/
if (size > EXT4_BLOCKS_PER_GROUP(ac->ac_sb))
size = EXT4_BLOCKS_PER_GROUP(ac->ac_sb);

end = start + size;

/* check we don't cross already preallocated blocks */
Expand Down

0 comments on commit cd648b8

Please sign in to comment.