On Thu, Dec 12, 2019 at 01:50:44AM -0800, Christoph Hellwig wrote: > On Wed, Dec 11, 2019 at 06:30:39PM -0600, Goldwyn Rodrigues wrote: > > From: Goldwyn Rodrigues <rgoldwyn@xxxxxxxx> > > > > Filesystems such as btrfs can perform direct I/O without holding the > > inode->i_rwsem in some of the cases like writing within i_size. > > How is that safe? > > > + lockdep_assert_held(&file_inode(file)->i_rwsem); > > Having the asserts in the callers is pointless. The assert is inside > the iomap helper to ensure the expected calling conventions, as the > code is written under the assumption that we have i_rwsem. It's written under the assumption that the caller has already performed the appropriate locking they require for serialisation against other operations on that inode. The fact that the filesystems up to this point all used the i_rwsem is largely irrelevant, and filesystems don't have to use the i_rwsem to serialise their IO. e.g. go back a handful of years and this would have needed to take into account an XFS specific rwsem, not the VFS inode mutex... Indeed, the IO range locking patches I have for XFS get rid of this lockdep assert in iomap because we no longer use the i_rwsem for IO serialisation in XFS - we go back to using an internal XFS construct for IO serialisation and don't use the i_rwsem at all. Cheers, Dave. -- Dave Chinner david@xxxxxxxxxxxxx