Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2437886imm; Mon, 28 May 2018 08:05:40 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLPJXZfl5M+y+HpdGNILOrEr8Vw5hcMTPgpN5Qi90PTt+Lo+zKgSOzb7Ri4YlrakCKEVZ2n X-Received: by 2002:a62:418b:: with SMTP id g11-v6mr5568991pfd.51.1527519940360; Mon, 28 May 2018 08:05:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527519940; cv=none; d=google.com; s=arc-20160816; b=Vu6Y6GAvLs90GfykTyVPnNR29mBsEf/JCk4QIsyjIlVue5kIN6Rj28xAO9dC3HMYF4 qKKDvqdLLHFgNmUQwHg5VC3owFjpt08nw0BnSpMh7leVc2ouRHNoce1qi8Z6+EOUVLZr ZmMGNLmXlfmDe2ihiL0kIAQ8BPhpEzO0Nmfyn7Ya/YpiTCwIQw06r3Pj7w7k+ICIy6c7 CTob9JlmAfhbDZ+2Yo4F/KzxxPv7joJmsdCiH6R2WuX0jk8WYZCzj8tpo7065lw4nGsP TC3u/c4XwVEmMSt8RI8FWjhD00+VKocyv5v4GMVmmI+IG8OWtNfR5Z1QPWJdSLBxd15/ o9Gg== 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=gSF4/y7ksUc9Ml9wd10CSqF7VCcDqe2sCKntEVlNiCU=; b=c48lpvf2SALCex9oxpeSPA6++Iv1wHkA1ASUDIhF1neMblbkSadRvw7FZ1nIw5gtlc JhozuW8EDGBvRcRTHWjq1elF5g41OWD+SdijV8Om6PywEw4TleuZg792/xDi5ZsSJGYx o7Ahnqcp6IH7HoY7Fr7ee8wTlk/2gg7TbjFVaOPKMF2iDHFEU5Sfq+ZrXZD2H8/FZ+AW zUaeenj5Z5pSlSLGku1e/w8hOUXzKo8nOhxeMGH9b7+4mtwx41UI39ojx4uZpeF5gFAO fkckruBc89txGFxEPjlkPalzgdn72arK2kbAHbhtsqh4kBt2D3t8tgicS/0LWzFQk2vk ZYeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Qtws1sv5; 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 l139-v6si30891726pfd.51.2018.05.28.08.05.25; Mon, 28 May 2018 08:05:40 -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=Qtws1sv5; 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 S939494AbeE1PEV (ORCPT + 99 others); Mon, 28 May 2018 11:04:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:44888 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033541AbeE1KZd (ORCPT ); Mon, 28 May 2018 06:25:33 -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 2CCD0208A2; Mon, 28 May 2018 10:25:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527503132; bh=03vi81xLLJpyhbwPZGEwnWp0MbEdjqPZJxDGyVzAEms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qtws1sv5B9nA3ytG1SYI7zmwXcGUjBA9VwvU3rN3ybtx2yWIftxXZgpStDfyAEYmQ iNS+Na8Eq7/Fl00yKzyWlldTmT7cWgaZ8suPhLcenaHhfVnIiGL+K6IjMjhQTPFJrU fwcuOkzs3IaPfFvMkVVNIuGrsewMSdwfBjHJoTsA= 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.4 222/268] gfs2: Fix fallocate chunk size Date: Mon, 28 May 2018 12:03:16 +0200 Message-Id: <20180528100227.541495672@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100202.045206534@linuxfoundation.org> References: <20180528100202.045206534@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.4-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 @@ -806,7 +806,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; @@ -858,7 +858,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 @@ -43,6 +43,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);