btrfs: vairous bug fixes related to generic/475 failure with subpage cases
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest3 patches 11 repliesIn review
- v14 patches 11 repliesSuperseded
Changes in v2 from the cover letter
- Make submit_one_bio() to return void just in the same patch
- Update the commit message the for 2nd patch
To mention remaining error path (which is not really possible to trigger), to prove the first patch is already fixing all involved error paths.
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | btrfs: avoid double clean up when submit_one_bio() failedfs/ fs/ fs/ | +44 | 9 replies | |
| 2/3 | btrfs: fix the error handling for submit_extent_page() for btrfs_do_readpage()fs/ | +6 | 0 replies | |
| 3/3 | btrfs: return correct error number for __extent_writepage_io()fs/ | +12 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.
Cover letter [PATCH v2 0/3] btrfs: vairous bug fixes related to generic/475 failure with subpage cases
[CHANGELOG]
v2:
- Make submit_one_bio() to return void just in the same patch
- Update the commit message the for 2nd patch
To mention remaining error path (which is not really possible to trigger), to prove the first patch is already fixing all involved error paths.
[DESCRIPTION]
When testing my subpage raid56 support, generic/475 is always hanging with some data page unable to be unlocked.
It turns out that, the hang is not related to the raid56 subpage support (obviously, as the test case is not utilizing RAID56 at all), but a recent commit 1784b7d502a9 ("btrfs: handle csum lookup errors properly on reads") introduced a new error path, and it caught us by surprise.
The new error path is from btrfs_lookup_bio_sums(), which can now return error if the csum search failed.
This new error path exposed several problems:
- Double cleanup for submit_one_bio() and its callers Bio submission hooks, btrfs_submit_data_bio() and btrfs_submit_metadata_bio() will call endio to cleanup on errors.
But those bio submission hooks will also return error, and finally callers of submit_extent_page() will also try to do cleanup.
This will be fixed by the first patch, by always returning 0 for submit_one_bio().
This fix is kept as minimal as possible, to make backport easier. The proper conversion to return void will be done in the last patch.
- btrfs_do_readpage() can leave page locked on error If submit_extent_page() failed in btrfs_do_readpage(), we only cleanup the current range, and leaving the remaining subpage range locked.
This bug is subpage specific, and will not affect regular cases.
Fix it by cleaning up all the remaining subpage range before exiting.
- __extent_writepage_io() can return 0 even it hit some error Although we continue writing the remaining ranges, we didn't save the first error, causing @ret to be overwritten.
This bug is subpage specific, as for regular cases we only have one sector inside the page.
Fix it by introducing @has_error and @saved_ret.
I manually checked all other submit_extent_page() callers, they all look fine and won't cause problems like the above.
Finally since submit_one_bio() will always return 0, the final patch will make it return void, which greatly makes our code cleaner.
But that patch is introducing quite some modifications, not a candidate for backport, unlike the first 3 patches.
Special thanks to Josef, as my initial bisection points to his patch and I have no clue why it can cause problems at all.
His hints immediately solved all my questions, and lead to this patchset.
Qu Wenruo (3):
btrfs: avoid double clean up when submit_one_bio() failed
btrfs: fix the error handling for submit_extent_page() for
btrfs_do_readpage()
btrfs: return correct error number for __extent_writepage_io()
fs/btrfs/extent_io.c | 135 ++++++++++++++++++------------------------- fs/btrfs/extent_io.h | 3 +- fs/btrfs/inode.c | 13 ++--- 3 files changed, 62 insertions(+), 89 deletions(-)
Signature · 1 line
2.35.1