On Fri, May 27, 2022 at 05:26:32PM -0700, Jaegeuk Kim wrote: > On 05/28, Dave Chinner wrote: > > On Fri, May 27, 2022 at 09:33:55PM +0000, Eric Biggers wrote: > > > [+Cc linux-block for FUA, and linux-xfs for iomap] > > > > linux-fsdevel should really be used for iomap stuff... > > > > > > > > On Fri, May 27, 2022 at 01:59:55PM -0700, Jaegeuk Kim wrote: > > > > Some UFS storage gives slower performance on FUA than write+cache_flush. > > > > Let's give a way to manage it. > > > > > > > > Signed-off-by: Jaegeuk Kim <jaegeuk@xxxxxxxxxx> > > > > > > Should the driver even be saying that it has FUA support in this case? If the > > > driver didn't claim FUA support, that would also solve this problem. > > > > Agreed, this is a hardware problem that need to addressed with a > > driver quirk to stop it advertising FUA support. The high level > > fs/iomap code should always issue FUA writes where possible and > > the lower layers tell the block layer whether to issue the FUA as > > a FUA or write+cache flush pair. > > I was thinking to turn off FUA in driver side quickly tho, one concern > was the bandwidth vs. latency. What if the device can support FUA having > short latency while giving low bandwidth? Seriously, how is a user supposed to know this sort of thing about the hardware they are using? They don't, and to expect them to not only know about the existing of a weird sysfs knob, let alone how it applies to their hardware and their workload is totally unreasonable. If the hardware has non-deterministic FUA write performance, or requires very careful switch over between cache flushes and FUA to get the most out of the hardware, then that's not something we can tune or optimise for - that's just broken hardware and the drive should quirk the brokeness away so nobody has to care about it. Tell the hardware manufacturer to fix their hardware, don't try to hack around it in software and then expect the user to know how to tune for that broken hardware. > In that case, we still have > a room to utilize FUA for small-sized writes such as filesystem metadata > writes, but avoid DIO w/ FUA for sequential write stream. Strawman. We don't use FUA for normal DIO writes - they only get used for O_DSYNC writes, in which case we either use FUA if the device supports it, or we do a normal write followed by a cache flush. If there are metadata updates that the O_DSYNC needs to also flush, we don't use FUA by let the fileystem issue a cache flush in the most optimal possible after the write completes. Either way, using O_DSYNC DIO writes for streaming, sequential data is a really poor choice for an application to make. Normal DIO writes followed by fdatasync() to flush the metadata and caches once will be much faster and far more efficient than a metadata and cache flush after every single data write, FUA or not. -Dave. -- Dave Chinner david@xxxxxxxxxxxxx