Page MenuHomeFreeBSD

Break down the sglist if VIRTIO_BLK_F_SIZE_MAX is on
Needs ReviewPublic

Authored by khng on Nov 18 2020, 3:14 AM.
Referenced Files
Unknown Object (File)
Dec 20 2023, 7:02 AM
Unknown Object (File)
Dec 13 2023, 3:32 AM
Unknown Object (File)
Nov 14 2023, 11:35 PM
Unknown Object (File)
Oct 22 2023, 7:40 AM
Unknown Object (File)
Oct 19 2023, 9:36 PM
Unknown Object (File)
Aug 15 2023, 2:41 AM
Unknown Object (File)
Aug 15 2023, 1:08 AM
Unknown Object (File)
Aug 13 2023, 1:23 AM



This change introduce a mechanism to break down the sglist used in
virtio_blk. If VIRTIO_BLK_F_SIZE_MAX is advertised by the host, the
maximum size of each segments in the scatter/gather should be
limited to the size advertised by the host.

Reported by: Yuan Rui <>
MFC after: 2 weeks

Diff Detail

Lint Passed
No Test Coverage
Build Status
Buildable 34883
Build 31904: arc lint + arc unit

Event Timeline

khng requested review of this revision.Nov 18 2020, 3:14 AM
khng created this revision.
  • Change wordings of comment a bit
  • Fix some weird lines in vtblk_sg_split_append
khng planned changes to this revision.Nov 18 2020, 6:16 AM
  • Aggregation of all versions
  • Remove the unnecessary PAGE_SIZE vs size_max checking
  • Rename vtblk_max_size to vtblk_size_max to match the spec more
  • Make vtblk_size_max size_t to match sglist(9) more
  • Remove an unnecessary short path for vtblk_sg_split

Could you please rebase this to latest main?


(Please rebase with the MAXPHYS -> maxphys conversion)


Based on the context, it appears to me that d_maxsize should be determined by the smaller of maxphys and blkcfg.size_max (we could potentially break atomic semantics if we have to split an I/O request into smaller chunks without upper layers knowing) after this change, so maybe it's time to make the adjustment here?


We should probably assert that d_maxsize is always greater than PAGE_SIZE here, and fail attachment when this can't be satisfied. See the proposed "fewer than minimum number of segments" change above.


Now support aliyun update to FreeBSD 13.0 ? But I see it still needs review.