Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2287564imm; Mon, 28 May 2018 05:26:45 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrIpZbYcLsjr/VjUpZhZFq0a5PgwW9Rk+ljfYHHl6uksdonAyBk6g7RBRtQzdpQ8dXk+jI/ X-Received: by 2002:a62:3b5d:: with SMTP id i90-v6mr13188611pfa.24.1527510405441; Mon, 28 May 2018 05:26:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527510405; cv=none; d=google.com; s=arc-20160816; b=trRQfxE64/woi/gknzJMTcpQm+0zdxnZ4DueGjozUVqF0DSWICKTPqHfpKUXW3iEhw XkIi61gBNbkMh5Umr/DFYJVAEadRVxr12w9difYPyXKZYV64p6zfes7UbbhmnaEaksAN +CNoIzTZeo3bSgcz/+oLom35FC68LD1YP//lE4+hPKgewVtueAmi/pOyd+hcS7wghOvJ wkShZ5RV0eeb88v93BcY4oyFVwXXehQOFMEajJoMCpgVv32sWbjaiIMqSHD8YbQSbWhV TKvkawLIgk4zpX38s2riGA9iQGHndRl5pmhOPM8nGTz8ufTeEz6eBiCsA8JYlMKQz4DU PDbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=SBQ9jv/aVsbefxbaEEcWf9gAorfW7jdQgAWQWgUY/mA=; b=R710a8sWXyrZeJRAeJxJL5QzhDuEfY6LAv34tRt2rUxxKcvsKVHMXTakMKEYDuvfl7 jQCMWlWUAiJ1ytH/0O3+KOx8tPPO5710/DdyZEAGluHw7s+4SSMKsyKFnfveADVIkOmO MJ9Pn47uj6P1rd7IftVHYEtcWSYUn6SO5nd2Y2Ncw/ccga9tejVWtFmIf8pIDJGwAcUp eqPZnxwAm+0N48Q+3875zIUXXIJ7dfDbneYPMbXyU9mpyDkAE4sR2TXGHNU77HFbKG5c JswBHgd5iJZ0E9Ltg1YnEEtxpsMpPENBeLul2qbu67gjo6G7ylOfIqQrRqXvuRDylnRj Afhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LFqfz451; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3-v6si29782708plc.14.2018.05.28.05.26.30; Mon, 28 May 2018 05:26:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LFqfz451; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422729AbeE1LBR (ORCPT + 99 others); Mon, 28 May 2018 07:01:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:48686 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164830AbeE1LBG (ORCPT ); Mon, 28 May 2018 07:01:06 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 35CC5206B7; Mon, 28 May 2018 11:01:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527505265; bh=VvZerCH182AwyP0ko8xXVUQJ2RV0qGbgq6OQrQwxCYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LFqfz451Mop6HMEdPSEX3dxeElYbS3aXpM+bO6aIIDBbx2W8gafN3xMT7L63dWxgO +j4N9faT325XjxnJ7g1UQlMIcVT9M4iHvwS6Sr8ts3oCSctvqSgUeKAl9U64tBkAnR /rhABGKUE9OG1mcLqlF0RoVI4xtU2juZerRnBAYU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andreas Gruenbacher , Bob Peterson , Sasha Levin Subject: [PATCH 4.14 436/496] gfs2: Fix fallocate chunk size Date: Mon, 28 May 2018 12:03:41 +0200 Message-Id: <20180528100338.094884074@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100319.498712256@linuxfoundation.org> References: <20180528100319.498712256@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Andreas Gruenbacher [ Upstream commit 174d1232ebc84fcde8f5889d1171c9c7e74a10a7 ] The chunk size of allocations in __gfs2_fallocate is calculated incorrectly. The size can collapse, causing __gfs2_fallocate to allocate one block at a time, which is very inefficient. This needs fixing in two places: In gfs2_quota_lock_check, always set ap->allowed to UINT_MAX to indicate that there is no quota limit. This fixes callers that rely on ap->allowed to be set even when quotas are off. In __gfs2_fallocate, reset max_blks to UINT_MAX in each iteration of the loop to make sure that allocation limits from one resource group won't spill over into another resource group. Signed-off-by: Andreas Gruenbacher Signed-off-by: Bob Peterson Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/gfs2/file.c | 5 +++-- fs/gfs2/quota.h | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c @@ -803,7 +803,7 @@ static long __gfs2_fallocate(struct file struct gfs2_inode *ip = GFS2_I(inode); struct gfs2_alloc_parms ap = { .aflags = 0, }; unsigned int data_blocks = 0, ind_blocks = 0, rblocks; - loff_t bytes, max_bytes, max_blks = UINT_MAX; + loff_t bytes, max_bytes, max_blks; int error; const loff_t pos = offset; const loff_t count = len; @@ -855,7 +855,8 @@ static long __gfs2_fallocate(struct file return error; /* ap.allowed tells us how many blocks quota will allow * us to write. Check if this reduces max_blks */ - if (ap.allowed && ap.allowed < max_blks) + max_blks = UINT_MAX; + if (ap.allowed) max_blks = ap.allowed; error = gfs2_inplace_reserve(ip, &ap); --- a/fs/gfs2/quota.h +++ b/fs/gfs2/quota.h @@ -45,6 +45,8 @@ static inline int gfs2_quota_lock_check( { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); int ret; + + ap->allowed = UINT_MAX; /* Assume we are permitted a whole lot */ if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF) return 0; ret = gfs2_quota_lock(ip, NO_UID_QUOTA_CHANGE, NO_GID_QUOTA_CHANGE);