Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp692845ybb; Fri, 10 Apr 2020 08:13:15 -0700 (PDT) X-Google-Smtp-Source: APiQypLmwGBOWETrWu6FMTQe+jnvk+wgzex5Rb5B0mCYRI3y55OiMeFiJl0a5ahP/ySVv7fbY/i1 X-Received: by 2002:a05:6214:17c8:: with SMTP id cu8mr5747456qvb.178.1586531595303; Fri, 10 Apr 2020 08:13:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586531595; cv=none; d=google.com; s=arc-20160816; b=rOeqWVp5fBJJj8D9vnk7ijFYwSDRtp3wQcIzTd6etYOOzIfefQ5rljqdXPIdH85woY McOibfBvtQtZwI8unzeKkmbUtFE45iT3nLIC72A8byVyuVxBL71osyIibkPuFXBPKoBC vYgrq5stTEy65zIk5LlUdes+wLJuLo+vFju2v2j037BW8EYUpplQYU3qVmw9mF5mmoUR mCF7X9+h15cO999o9xDPm3YpDLwBQ1p/joq+QE89zufri4D0/v1ydI36K75D9hGplVqR xQDWMGWXv5kDw1SQ7PVnHV+DHmjXWCU1+/MY/npm46i4Ht3L6JHPnkjR19Ty1Vgmj+gC fVpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=jrCi0+MfIbfy61zw0+fl/xbltNyOygUxatc2lL2mdfA=; b=EARACutDjwhz3UpvJtkXnlS16zr6YsWxwRpEQPmTJJFu8y2NuBukmwB1oVvMj5mZDv nHv+eBZfcfL7erdEf0QpdUw0YdIzH5p8tywZBomx8pf9rrK0J7FuswTR0zC5fjCV/rxP UEz+iK3mU+WDl6bfXQ5yrGgktJ3XaMj4pU07uxDu7r/kNz+nHZbi2xrYFRC6e65V7WHo V42ZO4LLVblTsnJ2zIVSkWAZHZk2bldsfaFXVzmD6l8qJrs5mC49ufkZXCVL0bpV2Dme Ah/ztmszEIEyLNUXzO5NjCYU10ZMl0Ztqy7+KxsDluINS6UIWktF7/TqGUNLBP37XMZi H/Ow== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-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 x30si1313613qta.316.2020.04.10.08.13.00; Fri, 10 Apr 2020 08:13:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-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-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726142AbgDJPMo (ORCPT + 99 others); Fri, 10 Apr 2020 11:12:44 -0400 Received: from mx2.suse.de ([195.135.220.15]:58340 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726009AbgDJPMo (ORCPT ); Fri, 10 Apr 2020 11:12:44 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E3876AE70; Fri, 10 Apr 2020 15:12:42 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 447C01E1246; Fri, 10 Apr 2020 17:12:42 +0200 (CEST) Date: Fri, 10 Apr 2020 17:12:42 +0200 From: Jan Kara To: Ted Tso Cc: linux-ext4@vger.kernel.org, Dmitry Monakhov , Jan Kara , stable@vger.kernel.org Subject: Re: [PATCH] ext4: Do not zeroout extents beyond i_disksize Message-ID: <20200410151242.GA3922@quack2.suse.cz> References: <20200331105016.8674-1-jack@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200331105016.8674-1-jack@suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Tue 31-03-20 12:50:16, Jan Kara wrote: > 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") > Signed-off-by: Jan Kara Ping Ted? Did this patch get lost? Honza > --- > fs/ext4/extents.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c > index 954013d6076b..c5e190fd4589 100644 > --- a/fs/ext4/extents.c > +++ b/fs/ext4/extents.c > @@ -3532,8 +3532,8 @@ static int ext4_ext_convert_to_initialized(handle_t *handle, > (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; > > @@ -3785,8 +3785,8 @@ static int ext4_split_convert_extents(handle_t *handle, > __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; > /* > -- > 2.16.4 > -- Jan Kara SUSE Labs, CR