On Thu, Jan 02, 2020 at 12:01:27PM -0600, Goldwyn Rodrigues wrote: > On 6:42 21/12, Christoph Hellwig wrote: > > So Ilooked into the "unlocked" direct I/O case, and I think the current > > code using dio_sem is really sketchy. What btrfs really needs to do is > > take i_rwsem shared by default for direct writes, and only upgrade to > > the exclusive lock when needed, similar to xfs and the WIP ext4 code. > > Sketchy in what sense? I am not trying to second-guess, but I want to > know where it could fail. I would want it to be simpler as well, but if > we can perform direct writes without locking, why should we introduce > locks. In that it needs yet another lock which doesn't really provide exclusion guarantees in its own. In many ways this lock plus the historic i_mutex were abused to provide the shared/exclusiv lock that now exists natively with i_rwsem.