From: Chao Yu <chao@kernel.org>
To: chenzhangqi79@163.com, jaegeuk@kernel.org
Cc: chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, chenzhangqi@xiaomi.com,
Zhijun Li <lizhijun3@xiaomi.com>
Subject: Re: [PATCH V0 RESEND] f2fs: fix error map extent flag while block not allocated
Date: Wed, 22 Jan 2025 19:40:35 +0800 [thread overview]
Message-ID: <d0b32f14-114b-4f18-94eb-fa83fc611cff@kernel.org> (raw)
In-Reply-To: <20250113055702.1347172-1-chenzhangqi79@163.com>
Hi Zhangqi,
On 1/13/25 13:57, chenzhangqi79@163.com wrote:
> From: Zhangqi Chen <chenzhangqi@xiaomi.com>
>
> 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 <lizhijun3@xiaomi.com>
> Signed-off-by: Zhijun Li <lizhijun3@xiaomi.com>
> Signed-off-by: Zhangqi Chen <chenzhangqi@xiaomi.com>
> ---
> 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);
prev parent reply other threads:[~2025-01-22 11:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-13 5:57 [PATCH V0 RESEND] f2fs: fix error map extent flag while block not allocated chenzhangqi79
2025-01-22 11:40 ` Chao Yu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d0b32f14-114b-4f18-94eb-fa83fc611cff@kernel.org \
--to=chao@kernel.org \
--cc=chenzhangqi79@163.com \
--cc=chenzhangqi@xiaomi.com \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lizhijun3@xiaomi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox