From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D244A189902 for ; Wed, 22 Jan 2025 11:40:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737546039; cv=none; b=N+uzeW7WTwSXoaGk2xyHIBSlEHK6m4YDMnuUtICzUvm7q45T8eUxlbNCLiq0bLC3FmpRpBozGL05Ch+/Y6K2plOZbr+RrOS9LA5bYTcOK6MyOiVl0B/xO34u9ajgPnTZE9buk585CerZ4auIIGao0d8Z00651pmAqzdpnXHCgX0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737546039; c=relaxed/simple; bh=R0HCeHA4SOr96wGuO6NZipjkw2IwS7Me1pYxGGgeURU=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=sTWtZosKQeO79Xm+wXI63m26jiQx2xg96ARl8xhX4/BW9cyOLLhPBEZS2ub7x5/5YfS8FYZz/2Y1Z2AbGLmt0VHvlg2HSCzykX5xvJ7kabxNcK12c6GPzQNWQR9cm4CNIKlfIdx21sgejRo8xURltMAF1XLV3VuWHkmikAovZLk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TIF7iU2D; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TIF7iU2D" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC0B9C4CED6; Wed, 22 Jan 2025 11:40:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737546039; bh=R0HCeHA4SOr96wGuO6NZipjkw2IwS7Me1pYxGGgeURU=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=TIF7iU2DhngKRMbq72c5A+mUeacEZD5+hPJ0lEBHSVdC25JHeBSK6UwTiRd2fc6D3 enuBYLIDffgq4mwpsHmwI0gYeBg8FvBwxYzNWxKoV648uT/Go3pEAhC8EYBWEsreZH eam+yJIEYV6Iqps5yTNMrWTVL6y7q1eEckO+jfh6KqHEO8EGcg/v55VcfQUp+8l1Pr riQ/WpKZCSTZRCaXWNGss3pmHO0f28vSZSONS2PsK4nkLiV7UQMVIytG31J/w8Xi9D E0+i7DxlOPZN+oaICQ969NkHlMJp+e0Qz9//do4vKarMqUFZPR65w65VijeIwD9seL IhieMmEGTISzA== Message-ID: Date: Wed, 22 Jan 2025 19:40:35 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, chenzhangqi@xiaomi.com, Zhijun Li Subject: Re: [PATCH V0 RESEND] f2fs: fix error map extent flag while block not allocated To: chenzhangqi79@163.com, jaegeuk@kernel.org References: <20250113055702.1347172-1-chenzhangqi79@163.com> Content-Language: en-US From: Chao Yu In-Reply-To: <20250113055702.1347172-1-chenzhangqi79@163.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi Zhangqi, On 1/13/25 13:57, chenzhangqi79@163.com wrote: > From: Zhangqi Chen > > In the function f2fs_fiemap, when returning the file > map extent flag, the flag of the delayed allocation > block is set to FIEMAP_EXTENT_UNWRITTEN . At the same > time, the phy address of the file map extent reassigned > to 0 because it is not a valid address. > > In this way, the file map extent with address 0 and > FIEMAP_EXTENT_UNWRITTEN flag returned by ioctl, and > may be used for writing by userspace programs, thereby > destroying the superblock of the file system. I agree with you. FYI, there is a previous patch as below: https://lore.kernel.org/linux-f2fs-devel/20230405144359.930253-1-chao@kernel.org/ It seems such change will fail some testcases of xfstest, have you check this patch w/ 009, 092 and 094 in tests/generic/? Thanks, > > As mentioned in /Documentation/filesystems/fiemap.txt, > FIEMAP_EXTENT_UNWRITTEN should mean that the block has > been allocated but not filled with data. However, the > actual situation in f2fs is that there is no allocated > block, so it should be changed to FIEMAP_EXTENT_UNKNOWN > and FIEMAP_EXTENT_DELALLOC. > > Co-developed-by: Zhijun Li > Signed-off-by: Zhijun Li > Signed-off-by: Zhangqi Chen > --- > fs/f2fs/data.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > index 2ec0cfb41260..a945d1f1d40c 100644 > --- a/fs/f2fs/data.c > +++ b/fs/f2fs/data.c > @@ -2023,7 +2023,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, > size += F2FS_BLKSIZE; > } > } else if (map.m_flags & F2FS_MAP_DELALLOC) { > - flags = FIEMAP_EXTENT_UNWRITTEN; > + flags = FIEMAP_EXTENT_UNKNOWN | FIEMAP_EXTENT_DELALLOC; > } > > start_blk += F2FS_BYTES_TO_BLK(size);