btrfs: reflink: undo delalloc if inline extent decompression fails
copy_inline_to_page() marks the destination block delalloc with
btrfs_reset_extent_delalloc() before it copies or decompresses the inline
data into the folio, and dirties the folio only once the data is there.
If btrfs_decompress() fails, the error path releases the space reserved
for the block but leaves EXTENT_DELALLOC (and EXTENT_DELALLOC_NEW, if the
block had no extent) set on a block whose folio is not dirty. Writeback
never visits it, so the bit stays, and with it an outstanding extent, the
inode's delalloc_bytes and new_delalloc_bytes and its place on the root's
delalloc list. When the folio is invalidated or the inode evicted, the
stale bit is cleared with EXTENT_DO_ACCOUNTING, which releases the block's
data and metadata reservation a second time.
The decompressors also write the destination range on failure (zeroes, or
part of the data), so a block that was uptodate in the page cache no
longer matches what is on disk, and reads keep returning it.
On a decompression failure, clear the delalloc bits, without
EXTENT_DO_ACCOUNTING or the reservation release bits since the error path
releases the reservation, and clear the block's uptodate state so the next
read gets it from disk.
Fixes: 05a5a7621ce6 ("Btrfs: implement full reflink support for inline extents") Assisted-by: Claude:claude-opus-5-5