Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3582791ybz; Mon, 20 Apr 2020 05:46:22 -0700 (PDT) X-Google-Smtp-Source: APiQypIyOMIHUrWIMjzA9grQJZRJ1nu+O7JnttW2UIywPO1SRzgR7lB84gIHGz+BjNLrhHEBHZ4B X-Received: by 2002:a50:d987:: with SMTP id w7mr13722564edj.276.1587386782368; Mon, 20 Apr 2020 05:46:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587386782; cv=none; d=google.com; s=arc-20160816; b=XNSJjmo5f3nrdj/wUE4A3KfpNPIF5YBG6ANbFb0px3yBzVabZQRcPgSkMtogW0BQHE 2YDfchesSxG1Sxpky0EOh11mb/PPons1Tn1Mq/5wkHW7ZwwmhLF6v8a3/ApQyCS2tKK6 r0OfN850YHNvBvXy77YK4bFhKQfxJFSFRHYkdGdHa6EJ5lSwQ3vgfYYRhQs3IsfBqNK/ TRVWl5AFmPuJkjz/UuIp9N02oPneX9m7DQk1QLiJDK3Ylpjnq7WYGReHzzW7DoxhBQi0 NmvLd8O+ivo/q1HOgrEccHcE4t+aom2l2PIWmetur/doygeP2X+tSFhjqTTHp7KXaLJl wI+g== 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:dkim-signature; bh=Jm8TlUSGSLFPjPgMuCfos9VGyfIDQJ1UkvvH0PopCd4=; b=qyfuNsdgMuUGF5sBhN5jS1QEpbaVbo/oFfl/HVEYIudgLFD5YFEORIea3gKRFMV8Ow Mc3D6z03jfBZqVMueI9hWVilnL3d8afcxkh/7y23W02+P1kwkzPt82KOzJJxSQpdF+0O r1AGW4bNZU3wkUqDJbTTcoj28jARuh3Vt8NsDg4LMPBe1VReHuftXZ4bhzZCRkQjIK+J 33YWh55iU62O6J5iXtjAICywqcyoeLnNpPgw6Y09YB50CbmqzghBx2K7GC4UktFiKO5H VX/i/BVZe2XA4Gn/qMPGUyZebo0FEBuBqP/3VG17wiAFZvlXftyOGcmLokmOuabkSDzO 5Aug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jqxEszSx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e5si442456edc.160.2020.04.20.05.45.59; Mon, 20 Apr 2020 05:46:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jqxEszSx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728166AbgDTMmL (ORCPT + 99 others); Mon, 20 Apr 2020 08:42:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:35064 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728139AbgDTMmI (ORCPT ); Mon, 20 Apr 2020 08:42:08 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 1C0DE21473; Mon, 20 Apr 2020 12:42:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587386528; bh=e2LmvBy0QEq7kzKFYINQFw6ZWjivBByKAKZVzSDNcRY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jqxEszSxAYZGjHaMf4M2ftJ8DEqhKLdA+HKwzvpGA8IoUrqU3FWim5K1rZaWK6Cc1 1dnoVa19bwn4DK8AzA++VJoZ7p2qEZ1grC+f2lmKrCTzDsdIFPVO4zUhGnZQX9hc+9 taMeFYsvxcC8egS5SgN3bWIzPbI5DRG0EprJ/sOs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lukas Czerner , Jan Kara , Theodore Tso Subject: [PATCH 5.5 59/65] ext4: do not zeroout extents beyond i_disksize Date: Mon, 20 Apr 2020 14:39:03 +0200 Message-Id: <20200420121519.396618789@linuxfoundation.org> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200420121505.909671922@linuxfoundation.org> References: <20200420121505.909671922@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Jan Kara commit 801674f34ecfed033b062a0f217506b93c8d5e8a upstream. We do not want to create initialized extents beyond end of file because for e2fsck it is impossible to distinguish them from a case of corrupted file size / extent tree and so it complains like: Inode 12, i_size is 147456, should be 163840. Fix? no Code in ext4_ext_convert_to_initialized() and ext4_split_convert_extents() try to make sure it does not create initialized extents beyond inode size however they check against inode->i_size which is wrong. They should instead check against EXT4_I(inode)->i_disksize which is the current inode size on disk. That's what e2fsck is going to see in case of crash before all dirty data is written. This bug manifests as generic/456 test failure (with recent enough fstests where fsx got fixed to properly pass FALLOC_KEEP_SIZE_FL flags to the kernel) when run with dioread_lock mount option. CC: stable@vger.kernel.org Fixes: 21ca087a3891 ("ext4: Do not zero out uninitialized extents beyond i_size") Reviewed-by: Lukas Czerner Signed-off-by: Jan Kara Signed-off-by: Theodore Ts'o Link: https://lore.kernel.org/r/20200331105016.8674-1-jack@suse.cz Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/ext4/extents.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -3570,8 +3570,8 @@ static int ext4_ext_convert_to_initializ (unsigned long long)map->m_lblk, map_len); sbi = EXT4_SB(inode->i_sb); - eof_block = (inode->i_size + inode->i_sb->s_blocksize - 1) >> - inode->i_sb->s_blocksize_bits; + eof_block = (EXT4_I(inode)->i_disksize + inode->i_sb->s_blocksize - 1) + >> inode->i_sb->s_blocksize_bits; if (eof_block < map->m_lblk + map_len) eof_block = map->m_lblk + map_len; @@ -3826,8 +3826,8 @@ static int ext4_split_convert_extents(ha __func__, inode->i_ino, (unsigned long long)map->m_lblk, map->m_len); - eof_block = (inode->i_size + inode->i_sb->s_blocksize - 1) >> - inode->i_sb->s_blocksize_bits; + eof_block = (EXT4_I(inode)->i_disksize + inode->i_sb->s_blocksize - 1) + >> inode->i_sb->s_blocksize_bits; if (eof_block < map->m_lblk + map->m_len) eof_block = map->m_lblk + map->m_len; /*