Commit 24763c9c authored by David Howells's avatar David Howells Committed by Jakub Kicinski

tls/device: Support MSG_SPLICE_PAGES

Make TLS's device sendmsg() support MSG_SPLICE_PAGES.  This causes pages to
be spliced from the source iterator if possible.

This allows ->sendpage() to be replaced by something that can handle
multiple multipage folios in a single transaction.
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Reviewed-by: default avatarJakub Kicinski <kuba@kernel.org>
cc: Chuck Lever <chuck.lever@oracle.com>
cc: Boris Pismenny <borisp@nvidia.com>
cc: John Fastabend <john.fastabend@gmail.com>
cc: Jens Axboe <axboe@kernel.dk>
cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 45e5be84
...@@ -509,6 +509,29 @@ static int tls_push_data(struct sock *sk, ...@@ -509,6 +509,29 @@ static int tls_push_data(struct sock *sk,
tls_append_frag(record, &zc_pfrag, copy); tls_append_frag(record, &zc_pfrag, copy);
iter_offset.offset += copy; iter_offset.offset += copy;
} else if (copy && (flags & MSG_SPLICE_PAGES)) {
struct page_frag zc_pfrag;
struct page **pages = &zc_pfrag.page;
size_t off;
rc = iov_iter_extract_pages(iter_offset.msg_iter,
&pages, copy, 1, 0, &off);
if (rc <= 0) {
if (rc == 0)
rc = -EIO;
goto handle_error;
}
copy = rc;
if (WARN_ON_ONCE(!sendpage_ok(zc_pfrag.page))) {
iov_iter_revert(iter_offset.msg_iter, copy);
rc = -EIO;
goto handle_error;
}
zc_pfrag.offset = off;
zc_pfrag.size = copy;
tls_append_frag(record, &zc_pfrag, copy);
} else if (copy) { } else if (copy) {
copy = min_t(size_t, copy, pfrag->size - pfrag->offset); copy = min_t(size_t, copy, pfrag->size - pfrag->offset);
...@@ -572,6 +595,9 @@ int tls_device_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) ...@@ -572,6 +595,9 @@ int tls_device_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
union tls_iter_offset iter; union tls_iter_offset iter;
int rc; int rc;
if (!tls_ctx->zerocopy_sendfile)
msg->msg_flags &= ~MSG_SPLICE_PAGES;
mutex_lock(&tls_ctx->tx_lock); mutex_lock(&tls_ctx->tx_lock);
lock_sock(sk); lock_sock(sk);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment