Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp577187ybz; Wed, 22 Apr 2020 04:04:30 -0700 (PDT) X-Google-Smtp-Source: APiQypKpQK0Ksovg22t3ny9AfhdwBNRMBhLSkLGwvKWDw9/fX/EZsX0m+6qPNiRmzXqu9jqZe7S1 X-Received: by 2002:a17:906:55c4:: with SMTP id z4mr25496475ejp.353.1587553470698; Wed, 22 Apr 2020 04:04:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587553470; cv=none; d=google.com; s=arc-20160816; b=ut67jCd9RmB1Mr++A+bsNRQ+gOhFjoowd88Nbo1RHmLaHmBN/lALWlTgO1aW9wLWiC 96jJS4M/VcM7OTboi5pFKQWy1hIZOBictzhaotRoE051fuDcZiyjcK4ZMERhZo5dqcVD rg8igHGfPAU/Kns5H206D9+w6Aaa71bgb3dDAsAQHnj0Fvye98/SD87AfSQpNzHZwCK1 8JODKydNMF1WkeeqfcOqLIRwGX9EhtDdPdbbQIIO5xQ+YAD2ceLabQZjNFHryyudhuYj WDlq/Cmh3Yw+q4038Q8Ix9zvZlqP3+P5xBxhKTVRpJ5cURoqbun0zcdEVLXvqddV0STD Fb7w== 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=E4Gp0f2hqYFyatf/HdqhVjDzg3XqoVRydggjOi6O4hg=; b=QOqC58Jt+wmROJpdQlZoeDyQGJM1JViLEtJ/w/7BZit5VGEk0Ofubeq6tw168S4f0N 828BDEBqLoN2cqQRptgfEkRjQVGms4EEZp6D/UqP7mIiKUsXnkEXZtFbxPyY9yFQKbfc rOsrboQWEGk/l7MHEExM9iTqkZC4XcqlChyqH31/KJ2symQFcctPiIO/GtTSYkabNpu/ dd5RKDwDPUAl5o8ekA6ixfVJdhJGz3yYuDb7SdjxhFt+9FbGH1O6CGnk53K39VHtYKBl 7Jejf5XCe4kInp7jd5JWhKP6Yt4RQ8+kmW6YtrP5do9HAoMxRMnxx9Fn6i/4ad36T6Vp UdFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lWA0ILj8; 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 d24si1341245ejc.345.2020.04.22.04.03.54; Wed, 22 Apr 2020 04:04:30 -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=lWA0ILj8; 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 S1726550AbgDVKDH (ORCPT + 99 others); Wed, 22 Apr 2020 06:03:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:52500 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727100AbgDVKDD (ORCPT ); Wed, 22 Apr 2020 06:03:03 -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 CC4EC208E4; Wed, 22 Apr 2020 10:03:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587549783; bh=XJr0lxy5vIcZ2OGNprXuiu1yZaGRxoLt/EV3+aKxOn8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lWA0ILj8Bdaw+kt3B1ofb7ZneWKzgNMT44P1iiE/7lUf4z8upT6erEJ2IhKLSCpKa dlVQJ+TlxD5HDJVx9nY13acDdb/8Pb1ErDHUlMQTEnDh2CBFHcrx60aAIJM6Iq21hP CICcK71bSZFBfPdMbEzpZcWdEWUvQq4tloAEw1mo= 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 4.4 066/100] ext4: do not zeroout extents beyond i_disksize Date: Wed, 22 Apr 2020 11:56:36 +0200 Message-Id: <20200422095034.909940954@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200422095022.476101261@linuxfoundation.org> References: <20200422095022.476101261@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 @@ -3439,8 +3439,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; @@ -3701,8 +3701,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; /*