sglist: Add sglist_append_single_mbuf().

This function appends the contents of a single mbuf to an sglist
rather than an entire mbuf chain.

Reviewed by:	gallatin, markj
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D30135
This commit is contained in:
John Baldwin 2021-05-25 16:59:18 -07:00
parent 1c8f4b3c9f
commit 6663f8a23e
4 changed files with 28 additions and 1 deletions

View File

@ -1941,6 +1941,7 @@ MLINKS+=sglist.9 sglist_alloc.9 \
sglist.9 sglist_append_mbuf_epg.9 \
sglist.9 sglist_append_phys.9 \
sglist.9 sglist_append_sglist.9 \
sglist.9 sglist_append_single_mbuf.9 \
sglist.9 sglist_append_uio.9 \
sglist.9 sglist_append_user.9 \
sglist.9 sglist_append_vmpages.9 \

View File

@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd April 24, 2020
.Dd May 25, 2021
.Dt SGLIST 9
.Os
.Sh NAME
@ -38,6 +38,7 @@
.Nm sglist_append_mbuf_epg,
.Nm sglist_append_phys ,
.Nm sglist_append_sglist ,
.Nm sglist_append_single_mbuf ,
.Nm sglist_append_uio ,
.Nm sglist_append_user ,
.Nm sglist_append_vmpages ,
@ -74,6 +75,8 @@
.Ft int
.Fn sglist_append_sglist "struct sglist *sg" "struct sglist *source" "size_t offset" "size_t len"
.Ft int
.Fn sglist_append_single_mbuf "struct sglist *sg" "struct mbuf *m"
.Ft int
.Fn sglist_append_uio "struct sglist *sg" "struct uio *uio"
.Ft int
.Fn sglist_append_user "struct sglist *sg" "void *buf" "size_t len" "struct thread *td"
@ -284,6 +287,13 @@ to the scatter/gather list
.Fa sg .
.Pp
The
.Nm sglist_append_mbuf
function appends the physical address ranges described by a single mbuf
.Fa m
to the scatter/gather list
.Fa sg .
.Pp
The
.Nm sglist_append_phys
function appends a single physical address range to the scatter/gather list
.Fa sg .

View File

@ -466,6 +466,21 @@ sglist_append_mbuf(struct sglist *sg, struct mbuf *m0)
return (0);
}
/*
* Append the segments that describe a single mbuf to a scatter/gather
* list. If there are insufficient segments, then this fails with
* EFBIG.
*/
int
sglist_append_single_mbuf(struct sglist *sg, struct mbuf *m)
{
if ((m->m_flags & M_EXTPG) != 0)
return (sglist_append_mbuf_epg(sg, m,
mtod(m, vm_offset_t), m->m_len));
else
return (sglist_append(sg, m->m_data, m->m_len));
}
/*
* Append the segments that describe a buffer spanning an array of VM
* pages. The buffer begins at an offset of 'pgoff' in the first

View File

@ -94,6 +94,7 @@ int sglist_append_phys(struct sglist *sg, vm_paddr_t paddr,
size_t len);
int sglist_append_sglist(struct sglist *sg, struct sglist *source,
size_t offset, size_t length);
int sglist_append_single_mbuf(struct sglist *sg, struct mbuf *m);
int sglist_append_uio(struct sglist *sg, struct uio *uio);
int sglist_append_user(struct sglist *sg, void *buf, size_t len,
struct thread *td);