Re: [PATCH] ocfs2: fix stale extent map cache during COW operations
From: Deepanshu Kartikey
Date: Sat Oct 11 2025 - 03:42:42 EST
Hi Heming,
Thank you for the detailed analysis and feedback.
I appreciate your review. However, I'm trying to understand your explanation
better. You mentioned that step 5 (write with zeros) cleans the file data
and causes the refcount flag mismatch.
Looking at the C reproducer, I see:
- Step 7: copy_file_range() creates reflinked extent (flags=0x2)
- Step 8: ioctl(fd, 0x40406f06, ...) which is FITRIM
- Step 9: write() triggers the BUG_ON
In my analysis, step 8 (FITRIM) calls ocfs2_move_extents() ->
__ocfs2_move_extents_range() -> ocfs2_move_extent() -> __ocfs2_move_extent().
Inside __ocfs2_move_extent() at line 50, I found:
replace_rec.e_flags = ext_flags & ~OCFS2_EXT_REFCOUNTED;
This explicitly clears the OCFS2_EXT_REFCOUNTED flag when writing to disk,
but the extent cache is not invalidated afterward.
Could you help me understand:
1. How does the write operation in step 5 clear the refcount flag on disk?
2. Are you suggesting there might be two separate bugs - one in the FITRIM
path (which v2 fixes) and another in a different path (which v1 would fix)?
My v2 patch has been merged into linux-next. If you believe v1 addresses a
different bug scenario, I'm happy to submit it as an additional patch.
Thanks for your time and expertise!
Best regards,
Deepanshu