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

(cherry picked from commit 6663f8a23e)
This commit is contained in:
John Baldwin 2021-05-25 16:59:18 -07:00
parent 8460b90d28
commit 60b9ce7245
4 changed files with 28 additions and 1 deletions

View File

@ -1946,6 +1946,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);