Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2462178imm; Mon, 24 Sep 2018 04:56:54 -0700 (PDT) X-Google-Smtp-Source: ACcGV63AliNMdbJxj8px/5H3NEUbdpnDtQvFuRLxFooLIA4q8t/6ji+AxtdFnWSR88D0KAkrB7k/ X-Received: by 2002:a17:902:3081:: with SMTP id v1-v6mr10560048plb.58.1537790214220; Mon, 24 Sep 2018 04:56:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537790214; cv=none; d=google.com; s=arc-20160816; b=0kTp8G5Rycw4GVnTDowUYUVG7cvqrAaSC38ZANdyaj+3rmlpt2rGp2qqi0aiurE/ug cY8xudcaw6fPie5FjszcAUSLgt0Q5t9AsPRBttcDI3ecZayOQqHXbYXIM5vbih5aqjes HGGrpNYA8aJma17IQ728i7pE1GpG7+m07i7odFgyZdhO/a7mqpWnuLfo6uWsR1ZLYSD6 VVvwCbr0iMoKUNl4f4cUTaTSbYB/zOQ1wKdPRHYJhM9fDEsj0ruPyFyDclWb9c30AL33 sOvSAb1ESBwW/s8reK0oelrXie15TCkd0eJHxrJmWZtX5fNsQ8EpbzWE9a7zoMy7XdQ3 08Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=ACIYP3kYgI24S0dVvl74906/Uwi48fRxYQGcuKn18UU=; b=ELZjlRQJxtTLDGa5RgbS+RyjzTa0PR7Mv0nwiqhBLlgfjC+3oLjFC69aMG3Oibx1en 8lprMsLxgcTB+zmrZ2ZLMmB7lE8IPa4mxsJfVF5nw5KQuH+yFF/wPLF24P27GNdhYLBH 6NgJ5fZ+yzlTqc3cvgpnmQzCeqMkE4g7MjM8mLPn+i9rZGjYJmF89t2WpII8fZ5t5gti 7WJjCAlgkx42GWf8k6xXPotGxLEo+vC9WHF8XVk3MkkqU+eNDN5VR/x7FdXTmAm8R/Th oHvqdjbMIK1RIcbs4EAfu7zvQLfy42/W12OuHjlN9NkRsCvPwafmBVu4NbhlIsmi3i9X JOFA== ARC-Authentication-Results: i=1; mx.google.com; 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 ay10-v6si35404600plb.293.2018.09.24.04.56.38; Mon, 24 Sep 2018 04:56:54 -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; 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 S1729889AbeIXR5e (ORCPT + 99 others); Mon, 24 Sep 2018 13:57:34 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:51922 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728081AbeIXR5e (ORCPT ); Mon, 24 Sep 2018 13:57:34 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id DED5C1072; Mon, 24 Sep 2018 11:55:48 +0000 (UTC) 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 05/70] gfs2: Special-case rindex for gfs2_grow Date: Mon, 24 Sep 2018 13:52:04 +0200 Message-Id: <20180924113058.997615561@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113058.420454070@linuxfoundation.org> References: <20180924113058.420454070@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 776125785a87ff05d49938bd5b9f336f2a05bff6 ] To speed up the common case of appending to a file, gfs2_write_alloc_required presumes that writing beyond the end of a file will always require additional blocks to be allocated. This assumption is incorrect for preallocates files, but there are no negative consequences as long as *some* space is still left on the filesystem. One special file that always has some space preallocated beyond the end of the file is the rindex: when growing a filesystem, gfs2_grow adds one or more new resource groups and appends records describing those resource groups to the rindex; the preallocated space ensures that this is always possible. However, when a filesystem is completely full, gfs2_write_alloc_required will indicate that an additional allocation is required, and appending the next record to the rindex will fail even though space for that record has already been preallocated. To fix that, skip the incorrect optimization in gfs2_write_alloc_required, but for the rindex only. Other writes to preallocated space beyond the end of the file are still allowed to fail on completely full filesystems. Signed-off-by: Andreas Gruenbacher Reviewed-by: Bob Peterson Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/gfs2/bmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -1476,7 +1476,7 @@ int gfs2_write_alloc_required(struct gfs end_of_file = (i_size_read(&ip->i_inode) + sdp->sd_sb.sb_bsize - 1) >> shift; lblock = offset >> shift; lblock_stop = (offset + len + sdp->sd_sb.sb_bsize - 1) >> shift; - if (lblock_stop > end_of_file) + if (lblock_stop > end_of_file && ip != GFS2_I(sdp->sd_rindex)) return 1; size = (lblock_stop - lblock) << shift;