On 14:13 15/12, Darrick J. Wong wrote: > On Tue, Dec 15, 2020 at 12:06:36PM -0600, Goldwyn Rodrigues wrote: > > From: Goldwyn Rodrigues <rgoldwyn@xxxxxxxx> > > > > btrfs_direct_write() fallsback to buffered write in case btrfs is not > > able to perform or complete a direct I/O. During the fallback > > inode lock is unlocked and relocked. This does not guarantee the > > atomicity of the entire write since the lock can be acquired by another > > write between unlock and relock. > > > > __btrfs_buffered_write() is used to perform the direct fallback write, > > which performs the write without acquiring the lock or checks. > > Er... can you grab the inode lock before deciding which of the IO > path(s) you're going to take? Then you'd always have an atomic write > even if fallback happens. No, since this is a fallback option which also works if the I/O is incomplete. > > (Also vaguely wondering why this needs even more slicing and dicing of > the iomap directio functions...) I would most likely go with Dave's method of storing the flag in the function and calling iomap dio functions without IOCB_DSYNC flag. This way we don't have to change iomap. -- Goldwyn