Skip to content

Commit

Permalink
net: split __zerocopy_sg_from_iter()
Browse files Browse the repository at this point in the history
Split a function out of __zerocopy_sg_from_iter() that only cares about
the traditional path with refcounted pages and doesn't need to know
about ->sg_from_iter. A preparation patch, we'll improve on the function
later.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
Pavel Begunkov authored and Paolo Abeni committed Jul 2, 2024
1 parent 9e2db9d commit 7fb0542
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions net/core/datagram.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,16 +610,10 @@ int skb_copy_datagram_from_iter(struct sk_buff *skb, int offset,
}
EXPORT_SYMBOL(skb_copy_datagram_from_iter);

int __zerocopy_sg_from_iter(struct msghdr *msg, struct sock *sk,
struct sk_buff *skb, struct iov_iter *from,
size_t length)
static int zerocopy_fill_skb_from_iter(struct sock *sk, struct sk_buff *skb,
struct iov_iter *from, size_t length)
{
int frag;

if (msg && msg->msg_ubuf && msg->sg_from_iter)
return msg->sg_from_iter(sk, skb, from, length);

frag = skb_shinfo(skb)->nr_frags;
int frag = skb_shinfo(skb)->nr_frags;

while (length && iov_iter_count(from)) {
struct page *head, *last_head = NULL;
Expand Down Expand Up @@ -692,6 +686,16 @@ int __zerocopy_sg_from_iter(struct msghdr *msg, struct sock *sk,
}
return 0;
}

int __zerocopy_sg_from_iter(struct msghdr *msg, struct sock *sk,
struct sk_buff *skb, struct iov_iter *from,
size_t length)
{
if (msg && msg->msg_ubuf && msg->sg_from_iter)
return msg->sg_from_iter(sk, skb, from, length);
else
return zerocopy_fill_skb_from_iter(sk, skb, from, length);
}
EXPORT_SYMBOL(__zerocopy_sg_from_iter);

/**
Expand Down

0 comments on commit 7fb0542

Please sign in to comment.