[snip] >> The cause sounds valid, however would you please explain more about how >> such cleaning on unrelated delalloc range happens? > > So in my case the following happened - 2 block groups were created as > delalloc ranges in the - 0-1m and 1m-128m. Their respective pages were > dirtied, so when page 0 - 0-4k when into writepage_delalloc, > find_lock_delalloc_range would return the range 0-1m. So the call to > fill_delalloc instantiates OE 0-1m and writeback continues as expected. > > Now, when the 2nd page from range 0-1m is again set for writeback and > find_lock_delalloc_range is called with delalloc_start == 4096 it will > actually return the range 1m-128m.
IMHO this looks strange and may need extra investigation. Normally I would expect it returns the range 0~1M or 4K~1M. But that doesn't affect the fix patch anyway. Thanks, Qu > Then fill_delalloc is called with > locked_page belonging to the range which was already instantiated and > the start/end arguments pointing to 1m-128m if an error occurred in > run_delalloc_range in this case then btrfs_cleanup_ordered_extents will > be called which will clear Private2 bit for pages belonging to 1m-128m > range and the OE will be cleared of all but the first page (since the > code wrongly assumed locked_page always belongs to the range currently > being instantiated). >