2024-05-29 11:25:48

by Sheng Yong

[permalink] [raw]
Subject: [PATCH] f2fs: avoid resetting non empty zone

If curseg is not the first segment in its zone, the zone is not empty,
and it should not be reset. This issue could be reproduced by:

modprobe null_blk nr_devices=1 zoned=1 zone_max_open=6 zone_max_active=6 zone_size=1024 gb=30
# /dev/vda is 4G
mkfs.f2fs -m -c /dev/nullb0 /dev/vda -f

while :; do
mount /dev/vda /mnt/
dd if=/dev/zero of=/mnt/file bs=4K count=11 conv=fsync status=none
if [ $? -ne 0 ]; then
umount /mnt
break
fi
f2fs_io shutdown 1 /mnt/file
umount /mnt
done

And the error looks like:
[ 123.169852] I/O error, dev nullb0, sector 41951232 op 0x1:(WRITE) flags 0x800 phys_seg 10 prio class 0
[ 123.173070] F2FS-fs (vda): do_checkpoint failed err:-5, stop checkpoint
dd: error writing '/mnt/testfile': Input/output error

Signed-off-by: Sheng Yong <[email protected]>
---
fs/f2fs/segment.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 4c8836ded90fc..50b38cbe33401 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -5004,7 +5004,8 @@ static int fix_curseg_write_pointer(struct f2fs_sb_info *sbi, int type)
}

/* Allocate a new section if it's not new. */
- if (cs->next_blkoff) {
+ if (cs->next_blkoff ||
+ cs->segno != GET_SEG_FROM_SEC(sbi, GET_ZONE_FROM_SEC(sbi, cs_section))) {
unsigned int old_segno = cs->segno, old_blkoff = cs->next_blkoff;

f2fs_allocate_new_section(sbi, type, true);
--
2.40.1



2024-05-29 11:28:08

by Chao Yu

[permalink] [raw]
Subject: Re: [PATCH] f2fs: avoid resetting non empty zone

On 2024/5/29 19:24, Sheng Yong wrote:
> If curseg is not the first segment in its zone, the zone is not empty,
> and it should not be reset. This issue could be reproduced by:
>
> modprobe null_blk nr_devices=1 zoned=1 zone_max_open=6 zone_max_active=6 zone_size=1024 gb=30
> # /dev/vda is 4G
> mkfs.f2fs -m -c /dev/nullb0 /dev/vda -f
>
> while :; do
> mount /dev/vda /mnt/
> dd if=/dev/zero of=/mnt/file bs=4K count=11 conv=fsync status=none
> if [ $? -ne 0 ]; then
> umount /mnt
> break
> fi
> f2fs_io shutdown 1 /mnt/file
> umount /mnt
> done
>
> And the error looks like:
> [ 123.169852] I/O error, dev nullb0, sector 41951232 op 0x1:(WRITE) flags 0x800 phys_seg 10 prio class 0
> [ 123.173070] F2FS-fs (vda): do_checkpoint failed err:-5, stop checkpoint
> dd: error writing '/mnt/testfile': Input/output error
>
> Signed-off-by: Sheng Yong <[email protected]>

Reviewed-by: Chao Yu <[email protected]>

Thanks,

2024-05-30 10:03:15

by Sheng Yong

[permalink] [raw]
Subject: [PATCH v2] f2fs: alloc new section if curseg is not the first seg in its zone

If curseg is not the first segment in its zone, the zone is not empty.
A new section should be allocated and avoid resetting the old zone.

Reviewed-by: Chao Yu <[email protected]>
Signed-off-by: Sheng Yong <[email protected]>
---
v2: remove and update inaccurate commit msg
---
fs/f2fs/segment.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 4c8836ded90fc..50b38cbe33401 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -5004,7 +5004,8 @@ static int fix_curseg_write_pointer(struct f2fs_sb_info *sbi, int type)
}

/* Allocate a new section if it's not new. */
- if (cs->next_blkoff) {
+ if (cs->next_blkoff ||
+ cs->segno != GET_SEG_FROM_SEC(sbi, GET_ZONE_FROM_SEC(sbi, cs_section))) {
unsigned int old_segno = cs->segno, old_blkoff = cs->next_blkoff;

f2fs_allocate_new_section(sbi, type, true);
--
2.40.1


2024-06-12 15:56:21

by patchwork-bot+f2fs

[permalink] [raw]
Subject: Re: [f2fs-dev] [PATCH v2] f2fs: alloc new section if curseg is not the first seg in its zone

Hello:

This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <[email protected]>:

On Thu, 30 May 2024 18:01:58 +0800 you wrote:
> If curseg is not the first segment in its zone, the zone is not empty.
> A new section should be allocated and avoid resetting the old zone.
>
> Reviewed-by: Chao Yu <[email protected]>
> Signed-off-by: Sheng Yong <[email protected]>
> ---
> v2: remove and update inaccurate commit msg
>
> [...]

Here is the summary with links:
- [f2fs-dev,v2] f2fs: alloc new section if curseg is not the first seg in its zone
https://git.kernel.org/jaegeuk/f2fs/c/76da333f4b93

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



2024-06-12 15:56:38

by patchwork-bot+f2fs

[permalink] [raw]
Subject: Re: [f2fs-dev] [PATCH] f2fs: avoid resetting non empty zone

Hello:

This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <[email protected]>:

On Wed, 29 May 2024 19:24:11 +0800 you wrote:
> If curseg is not the first segment in its zone, the zone is not empty,
> and it should not be reset. This issue could be reproduced by:
>
> modprobe null_blk nr_devices=1 zoned=1 zone_max_open=6 zone_max_active=6 zone_size=1024 gb=30
> # /dev/vda is 4G
> mkfs.f2fs -m -c /dev/nullb0 /dev/vda -f
>
> [...]

Here is the summary with links:
- [f2fs-dev] f2fs: avoid resetting non empty zone
https://git.kernel.org/jaegeuk/f2fs/c/76da333f4b93

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html