Re: [PATCH 4/8] btrfs: Switch to iomap_dio_rw() for dio

Goldwyn Rodrigues
2020-01-07T11:59:15Z

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.
>
> While looking for that I also noticed two other things:
>
> - check_direct_IO looks pretty bogus
> - btrfs_direct_IO really should be split and folded into the two
> callers
>
> Untested patches attached. The first should probably go into a prep
> patch, and the second could be folded into this one.

Testing revealed that removing check_direct_IO will not work. We try and
reserve space as a whole for the entire direct write. These checks
safeguard from requests unaligned to fs_info->sectorsize.

I liked the patch to split and fold the direct_IO code. However to merge
it into this will make it difficult to understand the changes since we
are moving it to a different file rather than changing in-place. A
separate patch would better serve as a cleanup.

--
Goldwyn