feat(ublk): optional Discarder and ZeroWriter capabilities#33
feat(ublk): optional Discarder and ZeroWriter capabilities#33ValentaTomas wants to merge 1 commit into
Conversation
PR SummaryMedium Risk Overview
Reviewed by Cursor Bugbot for commit ebd5deb. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
Refactored per feedback:
|
## Summary
- `New(backend, size)` becomes `New(backend, Config{...})`. Required
field: `Size`. Optional and defaulted on zero: `BlockSize` (512),
`QueueDepth` (128), `MaxIOSize` (128 KiB).
- Lets callers (e2b orchestrator) wire ublk with explicit knobs without
forking the library or recompiling.
- Breaking change — every example and test callsite updated.
Stacked on top of #33 (ZeroWriter) because both PRs touch \`setParams\`.
Will rebase on main once #33 lands.
## Test plan
- [x] Unit: `TestConfigValidate` covers good/bad shapes.
- [x] Integration: \`BlockSize=4096\` reaches the kernel (verified via
\`BLKBSZGET\`), custom \`QueueDepth\` propagates to the worker, custom
\`MaxIOSize\` clamps the block-layer request size (verified via
\`BLKSECTGET\`).
- [x] Full integration suite still green; \`make lint\` clean.
0f2ddbf to
b901422
Compare
6271089 to
2e64e54
Compare
DISCARD and WRITE_ZEROES are different ops in the block layer (discard = data undefined; write-zeroes = reads must return zeros), so they're separate optional interfaces — implement either or both. ZeroFlags carries ZeroNoUnmap (UBLK_IO_F_NOUNMAP, bit 15) so the backend can choose whether to keep the range physically allocated. UBLK_PARAM_TYPE_DISCARD is advertised per capability, so the kernel never issues an op the backend can't serve. The DISCARD/WRITE_ZEROES path bypasses the data-plane buffer and isn't capped by MaxIOBytes.
2e64e54 to
ebd5deb
Compare
|
Both points in the Bugbot summary are intentional:
|
DISCARD and WRITE_ZEROES are distinct in the block layer (discard leaves the range undefined; write-zeroes must read back as zeros), so they're exposed as separate optional
Backendcapabilities — implement either or both:ZeroFlagscarriesZeroNoUnmap(UBLK_IO_F_NOUNMAP, kernel bit 15) so backends that want to keep the range physically allocated can do so.UBLK_PARAM_TYPE_DISCARD(max_discard_sectors/max_write_zeroes_sectors) is advertised per capability, so the kernel only issues an op the backend can serve. The DISCARD / WRITE_ZEROES path bypasses the data-plane buffer and isn't capped byWithMaxIOSizesince neither op transfers user data.