Re: [f2fs-dev] [PATCH v2 1/2] f2fs: complete dropbehind write bios in safe task context

Wenjie Qi <[email protected]>
Newsgroups net.sourceforge.lists.linux-f2fs-devel,org.kernel.vger.linux-kernel
Message-ID <CAGFpFsRXX33j9uxpoVpS9CWQkPh=ijrDSBh=qCxFS1RABG8xDg@mail.gmail.com>
  Hi Barry,

  bio_in_atomic() is not in the current f2fs dev-test base yet, so v2
  carries the same predicate locally. I will replace it with
  bio_in_atomic() once the block pull is merged into the base.

  I also checked Alexandre's v3 series. Its deferred path is currently
  specific to swap-cache folios. folio_end_writeback() detects a
  dropbehind swap-cache folio and calls swap_writeback_dropbehind_folio(),
  while the per-CPU lists and swap_dropbehind_wq live in mm/swap_state.c.
  The non-swap path still calls folio_end_dropbehind() directly, so the
  series does not yet provide a common deferred path for file-backed
  folios.

  This F2FS patch reuses the existing sbi->wq rather than allocating a new
  workqueue, although the completion deferral remains F2FS-specific.

  Regards,
  Wenjie

On Thu, Aug 20, 2026 at 7:45 PM Barry Song <[email protected]> wrote:
>
> On Thu, Aug 20, 2026 at 3:21 PM Wenjie Qi <[email protected]> wrote:
> >
> > Buffered RWF_DONTCACHE writes invalidate dropbehind folios from writeback
> > completion. Keep normal and dropbehind folios in separate write bios, and
> > defer a dropbehind bio to sbi->wq unless completion runs in
> > preemptible task context.
> >
> > Use the same eligibility conditions as the proposed bio_in_atomic() helper.
> > Unlike !in_task(), this also covers disabled preemption and preemptible RCU
> > read-side critical sections.
> >
> > Keep the existing large-ATC deferral unchanged.
> >
> > Link: https://lore.kernel.org/linux-mm/[email protected]/
> > Signed-off-by: Wenjie Qi <[email protected]>
> > ---
> >  fs/f2fs/data.c | 50 ++++++++++++++++++++++++++++++++++++++++++--------
> >  1 file changed, 42 insertions(+), 8 deletions(-)
> >
> > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> > index 6ae0eb37d20..774a3e2d8e3 100644
> > --- a/fs/f2fs/data.c
> > +++ b/fs/f2fs/data.c
> > @@ -21,6 +21,7 @@
> >  #include <linux/fiemap.h>
> >  #include <linux/iomap.h>
> >  #include <linux/fserror.h>
> > +#include <linux/rcupdate.h>
> >
> >  #include "f2fs.h"
> >  #include "node.h"
> > @@ -43,9 +44,29 @@ struct f2fs_folio_state {
> >
> >  struct f2fs_bio {
> >         struct work_struct work;
> > +       bool dropbehind;
> >         struct bio bio;
> >  };
> >
> > +static struct f2fs_bio *to_f2fs_bio(struct bio *bio)
> > +{
> > +       return container_of(bio, struct f2fs_bio, bio);
> > +}
> > +
> > +/* Keep in sync with the proposed block-layer bio_in_atomic(). */
> > +static bool f2fs_bio_in_atomic(void)
> > +{
> > +#ifdef CONFIG_PREEMPTION
> > +       if (rcu_preempt_depth())
> > +               return true;
> > +#endif
> > +#ifndef CONFIG_PREEMPT_COUNT
> > +       return true;
> > +#else
> > +       return !preemptible();
> > +#endif
> > +}
> > +
>
> Hi Wenjie,
>
> I see that this [1] has already been included in the pull request [2],
> so perhaps you can use bio_in_atomic() directly once it lands.
>
> Also, I feel that something is quite odd with mm/filemap.c.
> It shouldn't require everyone to reinvent their own workqueues, as I
> mentioned here [3]. I also noticed that Alexandre is adding a workqueue
> in filemap.c[4], which might be extended to file page cache handling as
> well in the future.
>
> [1] https://lore.kernel.org/all/[email protected]/
> [2] https://lore.kernel.org/all/[email protected]/
> [3] https://lore.kernel.org/all/CAGsJ_4wUvLoKGafR3U-ji1kUUaz6K_QdN6QxMT-apSaO5tXp0A@mail.gmail.com/
> [4] https://lore.kernel.org/all/[email protected]/
>
> Thanks
> Barry


_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.