Re: [f2fs-dev] [PATCH 03/14] f2fs: support regular file buffered writes
From: Chao Yu
Date: Wed Sep 09 2026 - 04:45:19 EST
On 9/7/26 21:03, Nanzhe Zhao wrote:
> On Thu, 27 Aug 2026 16:56:53 +0800, Chao Yu wrote:
>> + /* Wait for pending drops back to bias which indicates all bio have completed. */
>> + while (READ_ONCE(ffs->read_pages_pending) != 1)
>> + f2fs_io_schedule_timeout(DEFAULT_SCHEDULE_TIMEOUT);
>>
>> Suspect there will be potential performance issue, as timeout interval
>> is large.
>>
>> Looks hacky.
>
> Thanks for the review.
>
> Maybe we can switch this to an event-driven wait instead:
>
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ includes
> #include <linux/fiemap.h>
> + #include <linux/wait_bit.h> /* wait_var_event_io / wake_up_var */
> #include <linux/iomap.h>
> @@ f2fs_submit_page_read_sync()
> - /* Wait for pending drops back to bias which indicates all bio have completed. */
> - while (READ_ONCE(ffs->read_pages_pending) != 1)
> - f2fs_io_schedule_timeout(DEFAULT_SCHEDULE_TIMEOUT);
> + /* Wait until all bios have completed (pending drops back to our bias). */
> + wait_var_event_io(&ffs->read_pages_pending,
> + READ_ONCE(ffs->read_pages_pending) == 1);
> @@ f2fs_finish_read_bio()
> ffs->read_pages_pending -= nr_pages;
> finished = !ffs->read_pages_pending;
> spin_unlock_irqrestore(&ffs->state_lock, flags);
> +
> + /* Wake f2fs_submit_page_read_sync() waiters (if any). */
> + wake_up_var(&ffs->read_pages_pending);
> }
>
> However, this requires an extra wake_up_var(&ffs->read_pages_pending)
> in f2fs_finish_read_bio(). I'm not sure whether adding an extra
> wake-up in the completion callback is a good practice - what do you
> think?
Sure, IMO, stability has higher priority, we can tune this later if it
takes much time.
Thanks,
>
> Thanks,
> Nanzhe