Re: [PATCH 3/7] btrfs: Use ihold instead of igrab in cow_file_range_async

David Sterba
2019-01-04T15:29:50Z

On Thu, Jan 03, 2019 at 10:50:01AM +0200, Nikolay Borisov wrote:
> ihold is supposed to be used when the caller already has a reference to
> the inode. In the case of cow_file_range_async this invariants holds,
> since the 3 call chains leading to this function all take a reference:
>
> btrfs_writepage <--- does igrab
> extent_write_full_page
> __extent_writepage
> writepage_delalloc
> btrfs_run_delalloc_range
> cow_file_range_async
>
> extent_write_cache_pages <--- does igrab
> __extent_writepage (same callchain as above)
>
> and
>
> submit_compressed_extents <-- already called from async CoW submit path,
> which would have done ihold.
> extent_write_locked_range
> __extent_writepage

So by the logic the inode reference needs to be taken early, eg. in
btrfs_writepage and all low-level callbacks or helpers are fine with
ihold.

Reviewed-by: David Sterba <dsterba@suse.com>