Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2497391imm; Mon, 24 Sep 2018 05:29:24 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaynvvWi6w2XhTmqy545TAcAScEyDijRsz8HqdCkn9xfaNNzQ99t7kiUpoFiFqwYFDQ0ldy X-Received: by 2002:a62:9cd7:: with SMTP id u84-v6mr10216856pfk.90.1537792163983; Mon, 24 Sep 2018 05:29:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537792163; cv=none; d=google.com; s=arc-20160816; b=T88dRvT/O6/XV4OUO536cjyTJSiPXyrmYb70k/rNxXBbc+nTsxiC+GP8btZfVudXcT uCE0DOlRXarf+RdukM8Y41NzExggkVidDgRCfMe4tUcxFuyuI9toX3Mkex10bkLhr6Gn HUPjjMNQGFYmzkpHQLl29VwCPQ4+lKNdsEc28e4Bgpe+968TQO5BA/dlTrBD9lYLD27r +lyrR3I6GHFhS/gelv05ot0QlXdr9VARPGujAA9WWA7Gf78D8hMaQ7XEJeWldKu2mVkZ 8r/3GGzZXKQSC+VlN5BVnyrlpCgm5pWTmKak/IB6BOaNzKHG+s6xbGs78vxWbu7fjv9S Ke2Q== 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=WSi5g8Etl0+GK6Jnv5UGTIl+LMsdJqWmVirTLyynirI=; b=kf7Wq4CLrv5C1EY689ayh5rgRx8kMQ74Dvc3ySZsNVH/etfU3Yi/uB4r1QoZNvlKn5 f1Bz9Pm5g7GFcDisVFrKhBSbvKlobzKXAKzM/q5WULf7dpzK5A5dkUeP72F1gb1DwgHc bfGKIMM67hNQNVspJJjeGEA8CrTXp2Az066AWKxB3kkF0nvjrpUYdnJQY223cBPPJSlc 5v5Ly/FOtBO+6YxEiorEayZyGWgT821vwnYS5XHiYE1Ll30TbwQayVvqsciharq8ctzY Z7/Aq9l9nK4do2Aowx6+gHdI6mycZmeFJuTUA2PoBL7BxpnXOyWlbfE5QWp5u1KogWVr GG3w== 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 g20-v6si33776694pgb.239.2018.09.24.05.29.08; Mon, 24 Sep 2018 05:29:23 -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 S2387481AbeIXSaC (ORCPT + 99 others); Mon, 24 Sep 2018 14:30:02 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:57392 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730233AbeIXSaB (ORCPT ); Mon, 24 Sep 2018 14:30:01 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 856FD1018; Mon, 24 Sep 2018 12:28:07 +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.18 027/235] gfs2: Special-case rindex for gfs2_grow Date: Mon, 24 Sep 2018 13:50:13 +0200 Message-Id: <20180924113107.427808714@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.999624566@linuxfoundation.org> References: <20180924113103.999624566@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.18-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 @@ -2060,7 +2060,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;