Re: [RFC PATCH] btrfs: don't call btrfs_sync_file from iomap context

Goldwyn Rodrigues
2020-09-15T21:49:48Z

On 10:04 07/09, Dave Chinner wrote:
> On Thu, Sep 03, 2020 at 06:32:36PM +0200, Christoph Hellwig wrote:
> > We could trivially do something like this to allow the file system
> > to call iomap_dio_complete without i_rwsem:
>
> That just exposes another deadlock vector:
>
> P0 P1
> inode_lock() fallocate(FALLOC_FL_ZERO_RANGE)
> __iomap_dio_rw() inode_lock()
> <block>
> <submits IO>
> <completes IO>
> inode_unlock()
> <gets inode_lock()>
> inode_dio_wait()
> iomap_dio_complete()
> generic_write_sync()
> btrfs_file_fsync()
> inode_lock()
> <deadlock>

Can inode_dio_end() be called before generic_write_sync(), as it is done
in fs/direct-io.c:dio_complete()?

Christoph's solution is a clean approach and would prefer to use it as
the final solution.

--
Goldwyn