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

Johannes Thumshirn
2020-09-01T14:45:19Z

On 01/09/2020 16:37, Filipe Manana wrote:
>> + iocb->ki_flags |= IOCB_DSYNC;
>
> This should be set before calling generic_write_sync() above,
> otherwise we don't do the persistence required by dsync.
>
> I have to be honest, I don't like this approach that much, it's a bit
> fragile - what if some other code, invoked in between clearing and
> setting back the flag, needs that flag to operate correctly?

Yes I don't like it either.

I've compared btrfs to ext4 and xfs and both don't hold on the inode
lock for (nearly) the whole xxx_file_write_iter() time, so I think
the correct fix would be to relax this time. But I haven't found any
documentation yet on which functions need to be under the inode_lock
and which not.

Any input is appreciated here.