Commit 2c033e4
committed
feat(block): handle VIRTIO_BLK_T_WRITE_ZEROES requests
Wire up Request::parse() validation and Request::process() handling
for write-zeroes requests, mirroring the discard path:
- parse(): reject write-only data descriptors and require data_len
to be a non-zero multiple of DISCARD_SEGMENT_SIZE (the
DiscardWriteZeroes struct is shared between both ops).
- parse_write_zeroes_segment(): validate flags (only bit 0,
VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP, is permitted), reject
num_sectors=0, check sector range, and return the unmap flag
so process() can pick the fallocate mode.
- process(): short-circuit to VIRTIO_BLK_S_UNSUPP if a previous
EOPNOTSUPP set disk.write_zeroes_unsupported; otherwise dispatch
to FileEngine::write_zeroes().
- the (Ok(_), RequestType::WriteZeroes) finish() arm now increments
the write_zeroes_count metric and returns VIRTIO_BLK_S_OK.
- the EOPNOTSUPP detection in the error path also handles
RequestType::WriteZeroes, setting the cache and returning
Status::WriteZeroesUnsupported (silent UNSUPP).
Add the write_zeroes_count metric and aggregate() line.
The feature flag is not yet advertised — that lands in the next
commit, after the request handling is fully in place.
Signed-off-by: Nikita Kalyazin <nikita.kalyazin@e2b.dev>1 parent cea19fe commit 2c033e4
3 files changed
Lines changed: 100 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
596 | 596 | | |
597 | 597 | | |
598 | 598 | | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
599 | 622 | | |
600 | 623 | | |
601 | 624 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
| 189 | + | |
| 190 | + | |
189 | 191 | | |
190 | 192 | | |
191 | 193 | | |
| |||
233 | 235 | | |
234 | 236 | | |
235 | 237 | | |
| 238 | + | |
| 239 | + | |
236 | 240 | | |
237 | 241 | | |
238 | 242 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
231 | | - | |
232 | | - | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
233 | 235 | | |
234 | 236 | | |
235 | 237 | | |
| |||
267 | 269 | | |
268 | 270 | | |
269 | 271 | | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
270 | 298 | | |
271 | 299 | | |
272 | 300 | | |
| |||
364 | 392 | | |
365 | 393 | | |
366 | 394 | | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
367 | 398 | | |
368 | 399 | | |
369 | 400 | | |
| |||
401 | 432 | | |
402 | 433 | | |
403 | 434 | | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
404 | 440 | | |
405 | 441 | | |
406 | 442 | | |
| |||
498 | 534 | | |
499 | 535 | | |
500 | 536 | | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
507 | 556 | | |
508 | 557 | | |
509 | 558 | | |
| |||
530 | 579 | | |
531 | 580 | | |
532 | 581 | | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
533 | 597 | | |
534 | 598 | | |
535 | 599 | | |
| |||
0 commit comments