Re: [RFC PATCH] f2fs: preserve direct write semantics when buffering is forced

From: Hans Holmberg
Date: Mon Jun 05 2023 - 07:57:04 EST



On Sun, Mar 26, 2023 at 04:39:10PM -0700, hch@xxxxxxxxxxxxx wrote:
> On Thu, Mar 23, 2023 at 05:46:37PM -0700, Jaegeuk Kim wrote:
> > > Yes, and that was exactly my point: with LFS mode, O_DIRECT write
> > > should never overwrite anything. So I do not see why direct writes
> > > should be handled as buffered writes with zoned devices. Am I missing
> > > something here ?
> >
> > That's an easiest way to serialize block allocation and submit_bio when users
> > are calling buffered writes and direct writes in parallel. :)
> > I just felt that if we can manage both of them in direct write path along with
> > buffered write path, we may be able to avoid memcpy.
>
> Yes. Note that right now f2fs doesn't really support proper O_DIRECT
> for buffered I/O either, as non-overwrites require a feature similar
> to unwritten extents, or a split of the allocation phase and the record
> metdata phase. If we'd go for the second choice for f2fs, which is the
> more elegant thing to do, you'll get the zoned direct I/O write support
> almost for free.

So, Jaegeuk, do you think suporting direct io proper is the way to do to fix this
issue? That looks like a better solution to me (at least long term).

Until that would be put into place, do you want my fix (with your code
style fixes) rebased and resent?

Cheers,
Hans