Re: [PATCH v3 5/5] btrfs: rst: don't print tree dump in case lookup fails

Johannes Thumshirn
2024-07-01T15:04:07Z

On 01.07.24 16:13, Josef Bacik wrote:
> On Mon, Jul 01, 2024 at 12:25:19PM +0200, Johannes Thumshirn wrote:
>> From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
>>
>> Don't print tree dump in case a raid-stripe-tree lookup fails.
>>
>> Dumping the stripe tree in case of a lookup failure was originally
>> intended to be a debug feature, but it turned out to be a problem, in case
>> of i.e. readahead.
>>
>
> I have no objection to the change but I'm curious how readahead triggered this?
> Is there a problem here, or is it just when there is a problem readahead makes
> it particularly noisy? Thanks,

There still is a bug in conjunction with RST and relocation's readahead.
But as I've stated in the cover letter, it is know, trivial to trigger,
but I haven't fully root caused it yet.

All I can say is, that we're doing a use-after-free triggered by:

relocate_data_extent()
`-> relocate_file_extent_cluster()
`-> relocate_one_folio()
`-> page_cache_sync_readahead()
`-> read_pages()

This most likely comes due to readahead requesting a l2p mapping that
RST is unaware of, then splits the read bio (that I can see in my
debugging) and the endio handler frees the original bio because of an
error while the lower layer block driver still uses it.