Re: [PATCH v6] f2fs: protect gc task pointer during teardown

From: Cen Zhang

Date: Tue Jun 30 2026 - 10:20:18 EST


Hi, Chao

Thanks a lot for your patient review and detailed suggestions.

> How about introduce f2fs_update_gc_task()?
>
> attach w/ f2fs_update_gc_task(, task), deattch w/ f2fs_update_gc_task(, NULL)?

I will introduce f2fs_update_gc_task(gc_th, task). The start path uses
f2fs_update_gc_task(gc_th, task), and the stop path uses
f2fs_update_gc_task(gc_th, NULL).

> + if (READ_ONCE(gc_th->f2fs_gc_task))
> + return 0;
>
> Why we need to check this?

Thanks, this check is unnecessary. I removed it.

> - task = xchg(&gc_th->f2fs_gc_task, NULL);
>
> I don't see this line in anywhere.

Sorry, this came from my local prerequisite tree, I will rebase the
change onto right commit.

> + if (!f2fs_cp_error(sbi) && READ_ONCE(gc_th->f2fs_gc_task)) {
>
> It's a corner case, I guess we can skip to check cp_error.

Agreed. I removed the added f2fs_cp_error() check and kept only the
f2fs_gc_task recheck after prepare_to_wait().

> Can we do like this?
>
> __sbi_store()
>
> spin_lock
> check f2fs_gc_task
> set_user_nice
> spin_unlock

Yes, will updated it this way.

I'll send v7 soon.

Thanks again.

Best regards,
Zhang Cen