summaryrefslogtreecommitdiffstats
path: root/fs/ext4/mballoc.c
diff options
context:
space:
mode:
authorJan Kara2017-01-27 20:34:30 +0100
committerTheodore Ts'o2017-01-27 20:34:30 +0100
commitcd648b8a8fd5071d232242d5ee7ee3c0815776af (patch)
treeeff784d1c9b958a05db5f6cccf5938a157a6c175 /fs/ext4/mballoc.c
parentext4: replace BUG_ON with WARN_ON in mb_find_extent() (diff)
downloadkernel-qcow2-linux-cd648b8a8fd5071d232242d5ee7ee3c0815776af.tar.gz
kernel-qcow2-linux-cd648b8a8fd5071d232242d5ee7ee3c0815776af.tar.xz
kernel-qcow2-linux-cd648b8a8fd5071d232242d5ee7ee3c0815776af.zip
ext4: trim allocation requests to group size
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" <kirill.shutemov@linux.intel.com> Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@vger.kernel.org
Diffstat (limited to 'fs/ext4/mballoc.c')
-rw-r--r--fs/ext4/mballoc.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index ec2f64b0e696..f513f273ff89 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -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 */