Re: [PATCH v2] f2fs: migrate all curseg types when reserving device alias

From: Daeho Jeong

Date: Fri Dec 04 2026 - 14:09:10 EST


On Thu, Dec 3, 2026 at 9:08 PM Kyuwon Cho <kyuwon.cho@xxxxxxxx> wrote:
>
> F2FS_IOC_RESERVE_DEV_ALIAS moves persistent current segments out of the
> target range before garbage-collecting and reserving it, but leaves the
> ATGC current segment in place.
>
> f2fs_gc_range() skips a section containing a current segment. Valid
> blocks in the ATGC current segment can therefore remain in the alias
> range. f2fs_reserve_device_alias() then adds the whole range to the SIT,
> and update_sit_entry() sees more valid blocks than the segment can hold.
> This triggers f2fs_bug_on() from the reserve ioctl itself.
>
> Move every current segment type out of the target range so range GC can
> evacuate it before reservation.
>
> Fixes: eae3faf210bd ("f2fs: support dynamic reserve/release for device aliasing")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Kyuwon Cho <kyuwon.cho@xxxxxxxx>
> ---
> Changes in v2:
> - Describe why the reserve ioctl itself triggers the SIT assertion, as
> explained by Daeho Jeong.
> - Add Cc: stable@xxxxxxxxxxxxxxx and rebase onto f2fs dev-test.
>
> Link to v1: https://lore.kernel.org/all/179621419306.2665116.9781888624264863839@xxxxxxxx/
>
> The issue was found by an LLM-guided test generator that we are
> developing as a research prototype.
>
> A reproducer is available on request.
>
> fs/f2fs/file.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index ddf71ed6e41e..ce5b465f0640 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -4137,7 +4137,7 @@ static int f2fs_ioc_reserve_dev_alias(struct file *filp)
> }
>
> /* Move out cursegs from the target range */
> - for (type = CURSEG_HOT_DATA; type < NR_CURSEG_PERSIST_TYPE; type++) {
> + for (type = CURSEG_HOT_DATA; type < NR_CURSEG_TYPE; type++) {
> err = f2fs_allocate_segment_for_resize(sbi, type, start, end);
> if (err) {
> f2fs_unlock_op(sbi, &lc);
> --
> 2.43.0


Hi Kyuwon,

Thanks, the commit message looks good now.

Sorry for the churn, but dev-test was updated after my last mail. The
patch which moved this loop under f2fs_lock_op() was replaced by "f2fs:
cover the checkpoint of device aliasing ioctls with gc_lock", so the loop
is back where it was in v1, and this hunk doesn't apply to the current
dev-test (029b14ff22f2). Could you rebase it once more?

With that, feel free to add:

Reviewed-by: Daeho Jeong <daehojeong@xxxxxxxxxx>

Thanks,

>