Commit bd610c0
btrfs: only unlock the to-be-submitted ranges inside a folio
[SUBPAGE COMPRESSION LIMITS]
Currently inside writepage_delalloc(), if a delalloc range is going to
be submitted asynchronously (inline or compression, the page
dirty/writeback/unlock are all handled in at different time, not at the
submission time), then we return 1 and extent_writepage() will skip the
submission.
This is fine if every sector matches page size, but if a sector is
smaller than page size (aka, subpage case), then it can be very
problematic, for example for the following 64K page:
0 16K 32K 48K 64K
|/| |///////| |/|
| |
4K 52K
Where |/| is the dirty range we need to submit.
In the above case, we need the following different handling for the 3
ranges:
- [0, 4K) needs to be submitted for regular write
A single sector cannot be compressed.
- [16K, 32K) needs to be submitted for compressed write
- [48K, 52K) needs to be submitted for regular write.
Above, if we try to submit [16K, 32K) for compressed write, we will
return 1 and immediately, and without submitting the remaining
[48K, 52K) range.
Furthermore, since extent_writepage() will exit without unlocking any
sectors, the submitted range [0, 4K) will not have sector unlocked.
That's the reason why for now subpage is only allowed for full page
range.
[ENHANCEMENT]
- Introduce a submission bitmap at btrfs_bio_ctrl::submit_bitmap
This records which sectors will be submitted by extent_writepage_io().
This allows us to track which sectors needs to be submitted thus later
to be properly unlocked.
For asynchronously submitted range (inline/compression), the
corresponding bits will be cleared from that bitmap.
- Only return 1 if no sector needs to be submitted in
writepage_delalloc()
- Only submit sectors marked by submission bitmap inside
extent_writepage_io()
So we won't touch the asynchronously submitted part.
- Introduce btrfs_folio_end_writer_lock_bitmap() helper
This will only unlock the involved sectors specified by @bitmap
parameter, to avoid touching the range asynchronously submitted.
Please note that, since subpage compression is still limited to page
aligned range, this change is only a preparation for future sector
perfect compression support for subpage.
Signed-off-by: Qu Wenruo <[email protected]>
Reviewed-by: David Sterba <[email protected]>
Signed-off-by: David Sterba <[email protected]>1 parent 49a9907 commit bd610c0
3 files changed
+86
-38
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
104 | 111 | | |
105 | 112 | | |
106 | 113 | | |
| |||
1106 | 1113 | | |
1107 | 1114 | | |
1108 | 1115 | | |
1109 | | - | |
| 1116 | + | |
1110 | 1117 | | |
1111 | 1118 | | |
| 1119 | + | |
1112 | 1120 | | |
1113 | 1121 | | |
1114 | 1122 | | |
| |||
1123 | 1131 | | |
1124 | 1132 | | |
1125 | 1133 | | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
1126 | 1142 | | |
1127 | 1143 | | |
1128 | 1144 | | |
| |||
1190 | 1206 | | |
1191 | 1207 | | |
1192 | 1208 | | |
1193 | | - | |
1194 | | - | |
1195 | | - | |
1196 | | - | |
1197 | | - | |
1198 | | - | |
1199 | | - | |
1200 | | - | |
1201 | | - | |
1202 | | - | |
1203 | | - | |
1204 | | - | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
1205 | 1213 | | |
1206 | | - | |
1207 | | - | |
1208 | | - | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
1209 | 1221 | | |
1210 | 1222 | | |
1211 | 1223 | | |
| |||
1230 | 1242 | | |
1231 | 1243 | | |
1232 | 1244 | | |
1233 | | - | |
1234 | | - | |
| 1245 | + | |
| 1246 | + | |
1235 | 1247 | | |
1236 | | - | |
| 1248 | + | |
1237 | 1249 | | |
1238 | 1250 | | |
1239 | 1251 | | |
| |||
1331 | 1343 | | |
1332 | 1344 | | |
1333 | 1345 | | |
1334 | | - | |
1335 | | - | |
1336 | | - | |
1337 | | - | |
1338 | | - | |
1339 | | - | |
1340 | | - | |
1341 | | - | |
1342 | | - | |
1343 | 1346 | | |
1344 | 1347 | | |
1345 | 1348 | | |
| |||
1357 | 1360 | | |
1358 | 1361 | | |
1359 | 1362 | | |
1360 | | - | |
1361 | | - | |
1362 | | - | |
1363 | | - | |
1364 | | - | |
1365 | 1363 | | |
1366 | 1364 | | |
1367 | | - | |
| 1365 | + | |
| 1366 | + | |
1368 | 1367 | | |
1369 | 1368 | | |
1370 | 1369 | | |
1371 | | - | |
| 1370 | + | |
1372 | 1371 | | |
1373 | 1372 | | |
1374 | 1373 | | |
| |||
1421 | 1420 | | |
1422 | 1421 | | |
1423 | 1422 | | |
| 1423 | + | |
1424 | 1424 | | |
1425 | 1425 | | |
1426 | 1426 | | |
| |||
1442 | 1442 | | |
1443 | 1443 | | |
1444 | 1444 | | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
1445 | 1450 | | |
1446 | 1451 | | |
1447 | 1452 | | |
1448 | 1453 | | |
1449 | | - | |
| 1454 | + | |
1450 | 1455 | | |
1451 | 1456 | | |
1452 | 1457 | | |
| |||
1466 | 1471 | | |
1467 | 1472 | | |
1468 | 1473 | | |
1469 | | - | |
1470 | | - | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
1471 | 1479 | | |
1472 | 1480 | | |
1473 | 1481 | | |
| |||
2210 | 2218 | | |
2211 | 2219 | | |
2212 | 2220 | | |
| 2221 | + | |
| 2222 | + | |
| 2223 | + | |
| 2224 | + | |
| 2225 | + | |
2213 | 2226 | | |
2214 | 2227 | | |
2215 | 2228 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
424 | 424 | | |
425 | 425 | | |
426 | 426 | | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
427 | 460 | | |
428 | 461 | | |
429 | 462 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| 109 | + | |
| 110 | + | |
109 | 111 | | |
110 | 112 | | |
111 | 113 | | |
| |||
0 commit comments