From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933501AbdCJLub (ORCPT ); Fri, 10 Mar 2017 06:50:31 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:35918 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933065AbdCJJOH (ORCPT ); Fri, 10 Mar 2017 04:14:07 -0500 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Kirill A. Shutemov" , Jan Kara , Theodore Tso Subject: [PATCH 4.4 46/91] ext4: trim allocation requests to group size Date: Fri, 10 Mar 2017 10:08:45 +0100 Message-Id: <20170310083903.091325116@linuxfoundation.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170310083900.730556986@linuxfoundation.org> References: <20170310083900.730556986@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jan Kara commit cd648b8a8fd5071d232242d5ee7ee3c0815776af upstream. 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" Signed-off-by: Jan Kara Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/ext4/mballoc.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -3120,6 +3120,13 @@ ext4_mb_normalize_request(struct ext4_al 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 */