Commit ffb21ea
ext4: restart handle if credits are insufficient during allocating blocks
commit e2c4c49 upstream.
After large folios are supported on ext4, writing back a sufficiently
large and discontinuous folio may consume a significant number of
journal credits, placing considerable strain on the journal. For
example, in a 20GB filesystem with 1K block size and 1MB journal size,
writing back a 2MB folio could require thousands of credits in the
worst-case scenario (when each block is discontinuous and distributed
across different block groups), potentially exceeding the journal size.
This issue can also occur in ext4_write_begin() and ext4_page_mkwrite()
when delalloc is not enabled.
Fix this by ensuring that there are sufficient journal credits before
allocating an extent in mpage_map_one_extent() and
ext4_block_write_begin(). If there are not enough credits, return
-EAGAIN, exit the current mapping loop, restart a new handle and a new
transaction, and allocating blocks on this folio again in the next
iteration.
Suggested-by: Jan Kara <[email protected]>
Signed-off-by: Zhang Yi <[email protected]>
Reviewed-by: Jan Kara <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Theodore Ts'o <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>1 parent ab13e8c commit ffb21ea
1 file changed
Lines changed: 36 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
877 | 877 | | |
878 | 878 | | |
879 | 879 | | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
880 | 900 | | |
881 | 901 | | |
882 | 902 | | |
| |||
1175 | 1195 | | |
1176 | 1196 | | |
1177 | 1197 | | |
1178 | | - | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
1179 | 1201 | | |
1180 | 1202 | | |
1181 | 1203 | | |
| |||
1374 | 1396 | | |
1375 | 1397 | | |
1376 | 1398 | | |
1377 | | - | |
1378 | | - | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
1379 | 1402 | | |
1380 | 1403 | | |
1381 | 1404 | | |
| |||
2324 | 2347 | | |
2325 | 2348 | | |
2326 | 2349 | | |
| 2350 | + | |
| 2351 | + | |
| 2352 | + | |
| 2353 | + | |
| 2354 | + | |
2327 | 2355 | | |
2328 | 2356 | | |
2329 | 2357 | | |
| |||
2451 | 2479 | | |
2452 | 2480 | | |
2453 | 2481 | | |
2454 | | - | |
| 2482 | + | |
2455 | 2483 | | |
2456 | 2484 | | |
2457 | 2485 | | |
| |||
2957 | 2985 | | |
2958 | 2986 | | |
2959 | 2987 | | |
| 2988 | + | |
| 2989 | + | |
2960 | 2990 | | |
2961 | 2991 | | |
2962 | 2992 | | |
| |||
6751 | 6781 | | |
6752 | 6782 | | |
6753 | 6783 | | |
6754 | | - | |
| 6784 | + | |
| 6785 | + | |
6755 | 6786 | | |
6756 | 6787 | | |
6757 | 6788 | | |
| |||
0 commit comments