Fix "journal superblock changes" so that needs_recovery flag is
[ext4-patch-queue.git] / trim-allocation-requests-to-group-size
blob41d893e0e6fe8d59195b38289a7fa47061234c4c
1 ext4: trim allocation requests to group size
3 From: Jan Kara <jack@suse.cz>
5 If filesystem groups are artifically small (using parameter -g to
6 mkfs.ext4), ext4_mb_normalize_request() can result in a request that is
7 larger than a block group. Trim the request size to not confuse
8 allocation code.
10 Reported-by: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
11 Signed-off-by: Jan Kara <jack@suse.cz>
12 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
13 Cc: stable@vger.kernel.org
14 ---
15  fs/ext4/mballoc.c | 7 +++++++
16  1 file changed, 7 insertions(+)
18 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
19 index 7ae43c59bc79..2e9fc7a61048 100644
20 --- a/fs/ext4/mballoc.c
21 +++ b/fs/ext4/mballoc.c
22 @@ -3123,6 +3123,13 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac,
23         if (ar->pright && start + size - 1 >= ar->lright)
24                 size -= start + size - ar->lright;
26 +       /*
27 +        * Trim allocation request for filesystems with artificially small
28 +        * groups.
29 +        */
30 +       if (size > EXT4_BLOCKS_PER_GROUP(ac->ac_sb))
31 +               size = EXT4_BLOCKS_PER_GROUP(ac->ac_sb);
33         end = start + size;
35         /* check we don't cross already preallocated blocks */
36 -- 
37 2.10.2