On Tue, Jul 27, 2021 at 11:23:03AM +0800, Chao Yu wrote:
> > >
> > > Do you have a proper explanation for why preallocations shouldn't be done
> > > in
>
> See commit f847c699cff3 ("f2fs: allow out-place-update for direct IO in LFS
> mode"),
> f2fs_map_blocks() logic was changed to force allocating a new block address
> no matter
> previous block address was existed if it is called from write path of DIO.
> So, in such
> condition, if we preallocate new block address in f2fs_file_write_iter(), we
> will
> suffer the problem which my trace indicates.
>
> > > this case? Note that preallocations are still done for buffered writes,
> > > which
> > > may be out-of-place as well; how are those different?
> Got your concern.
>
> For buffered IO, we use F2FS_GET_BLOCK_PRE_AIO, in this mode, we just preserve
> filesystem block count and tag NEW_ADDR in dnode block, so, it's fine, double
> new block address allocation won't happen during data page writeback.
>
> For direct IO, we use F2FS_GET_BLOCK_PRE_DIO, in this mode, we will allocate
> physical block address, after preallocation, if we fallback to buffered IO, we
> may suffer double new block address allocation issue... IIUC.
>
> Well, can we relocate preallocation into f2fs_direct_IO() after all cases
> which
> may cause fallbacking DIO to buffered IO?
>
That's somewhat helpful, but I've been doing some more investigation and now I'm
even more confused. How can f2fs support non-overwrite DIO writes at all
(meaning DIO writes in LFS mode as well as DIO writes to holes in non-LFS mode),
given that it has no support for unwritten extents? AFAICS, as-is users can
easily leak uninitialized disk contents on f2fs by issuing a DIO write that
won't complete fully (or might not complete fully), then reading back the blocks
that got allocated but not written to.
I think that f2fs will have to take the ext2 approach of not allowing
non-overwrite DIO writes at all...
- Eric
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel