Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2483540imm; Mon, 24 Sep 2018 05:16:29 -0700 (PDT) X-Google-Smtp-Source: ACcGV633iYvwozpMUbhmCEUxOBkBDdZKZkTHvQXww3ouoBa3QKy4zWzJ7iJdwX8RyYYpjkiOz+WW X-Received: by 2002:a17:902:8481:: with SMTP id c1-v6mr10548985plo.158.1537791388971; Mon, 24 Sep 2018 05:16:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537791388; cv=none; d=google.com; s=arc-20160816; b=QskkB+noBiwpEdmcwgHN4w8Yrj020bMKoiq0NNuM62fsWyabl67Al7TqF+ZYJ4lonA AjJIzubUomVlxIAU3a091DWFSiwhrGwZst7AdyKFGiIrWW1ywdblZ902y9qKOF3iW1ax IbaSl1gdEKrgDvhNF9z9xg7XGNPNvzRfjXFKWSjhNeDZrVWUO9yJ/VMgiTi2sdFV3Tfc yMmOsaFAOwF6WCVSMwejGnucohKs2kHOXeVLIhbTrRhScowuauBKD763Lfs5hH1//HFH /xcDdRBCJ/t1YPk11aIu2IGdErG/J0lWWVyTXynB4CNbA96WTAuMtp1do8CpJhgw+M6i 3dTA== 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=8fv1FCy33O5niMPgZSBokAnmn6Pl0GdJCGBsHYPpsW4=; b=z50bn/8fJSFOpvhoNXUGOzhUZvfFB/jiAJEPUy9dTtIPsfaz3Uzyt755gDdYxH6XGs x4EvsHjl7aSdTvm/KCFgSj8bWWcBDbMQOwiDSv85URdSSQOoEDPTLxwdekPFlv01oRrd xUWky8D/q2KycNjBCuH5uEgXUhhBbkz1gYhJzZT6t8Xvoi+Oo1Yh35Cx0xVl2XZ65NXD J/HszG+Px7V5lG+u/1HzHAzWE+4Xeo35Kx6J/auA7PCYXl4Twb4aEgex+W5IwRE2BV++ 91+OP5ID8qYaP+mI/HPvhI8QaSpC4SiN/da92lYJ9fNGdwYOHcZE702od+62vSECcY5n 7HeA== 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 be5-v6si34663199plb.67.2018.09.24.05.16.12; Mon, 24 Sep 2018 05:16:28 -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 S1732038AbeIXSRJ (ORCPT + 99 others); Mon, 24 Sep 2018 14:17:09 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:55546 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730150AbeIXSRJ (ORCPT ); Mon, 24 Sep 2018 14:17:09 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id DB20E10A5; Mon, 24 Sep 2018 12:15:17 +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.14 020/173] gfs2: Special-case rindex for gfs2_grow Date: Mon, 24 Sep 2018 13:50:54 +0200 Message-Id: <20180924113116.920174769@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113114.334025954@linuxfoundation.org> References: <20180924113114.334025954@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.14-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 @@ -1680,7 +1680,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;