ext4: trim allocation requests to group size
[firefly-linux-kernel-4.4.55.git] / fs / ext4 / mballoc.c
index b7a3957a9dcafbe9d3ba1113b259f18db4498090..84cd77663e1f5b8ac1978f8a11efec8c3d64f6a2 100644 (file)
@@ -3120,6 +3120,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 */