Skip to content

Commit dc97391

Browse files
dhowellskuba-moo
authored andcommitted
sock: Remove ->sendpage*() in favour of sendmsg(MSG_SPLICE_PAGES)
Remove ->sendpage() and ->sendpage_locked(). sendmsg() with MSG_SPLICE_PAGES should be used instead. This allows multiple pages and multipage folios to be passed through. Signed-off-by: David Howells <[email protected]> Acked-by: Marc Kleine-Budde <[email protected]> # for net/can cc: Jens Axboe <[email protected]> cc: Matthew Wilcox <[email protected]> cc: [email protected] cc: [email protected] cc: [email protected] cc: [email protected] cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent e52828c commit dc97391

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+20
-442
lines changed

Documentation/bpf/map_sockmap.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,11 @@ offsets into ``msg``, respectively.
240240
If a program of type ``BPF_PROG_TYPE_SK_MSG`` is run on a ``msg`` it can only
241241
parse data that the (``data``, ``data_end``) pointers have already consumed.
242242
For ``sendmsg()`` hooks this is likely the first scatterlist element. But for
243-
calls relying on the ``sendpage`` handler (e.g., ``sendfile()``) this will be
244-
the range (**0**, **0**) because the data is shared with user space and by
245-
default the objective is to avoid allowing user space to modify data while (or
246-
after) BPF verdict is being decided. This helper can be used to pull in data
247-
and to set the start and end pointers to given values. Data will be copied if
243+
calls relying on MSG_SPLICE_PAGES (e.g., ``sendfile()``) this will be the
244+
range (**0**, **0**) because the data is shared with user space and by default
245+
the objective is to avoid allowing user space to modify data while (or after)
246+
BPF verdict is being decided. This helper can be used to pull in data and to
247+
set the start and end pointers to given values. Data will be copied if
248248
necessary (i.e., if data was not linear and if start and end pointers do not
249249
point to the same chunk).
250250

Documentation/filesystems/locking.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,6 @@ prototypes::
521521
int (*fsync) (struct file *, loff_t start, loff_t end, int datasync);
522522
int (*fasync) (int, struct file *, int);
523523
int (*lock) (struct file *, int, struct file_lock *);
524-
ssize_t (*sendpage) (struct file *, struct page *, int, size_t,
525-
loff_t *, int);
526524
unsigned long (*get_unmapped_area)(struct file *, unsigned long,
527525
unsigned long, unsigned long, unsigned long);
528526
int (*check_flags)(int);

Documentation/filesystems/vfs.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,6 @@ This describes how the VFS can manipulate an open file. As of kernel
10861086
int (*fsync) (struct file *, loff_t, loff_t, int datasync);
10871087
int (*fasync) (int, struct file *, int);
10881088
int (*lock) (struct file *, int, struct file_lock *);
1089-
ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
10901089
unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
10911090
int (*check_flags)(int);
10921091
int (*flock) (struct file *, int, struct file_lock *);

Documentation/networking/scaling.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ a single application thread handles flows with many different flow hashes.
269269
rps_sock_flow_table is a global flow table that contains the *desired* CPU
270270
for flows: the CPU that is currently processing the flow in userspace.
271271
Each table value is a CPU index that is updated during calls to recvmsg
272-
and sendmsg (specifically, inet_recvmsg(), inet_sendmsg(), inet_sendpage()
273-
and tcp_splice_read()).
272+
and sendmsg (specifically, inet_recvmsg(), inet_sendmsg() and
273+
tcp_splice_read()).
274274

275275
When the scheduler moves a thread to a new CPU while it has outstanding
276276
receive packets on the old CPU, packets may arrive out of order. To

crypto/af_alg.c

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,6 @@ static const struct proto_ops alg_proto_ops = {
482482
.listen = sock_no_listen,
483483
.shutdown = sock_no_shutdown,
484484
.mmap = sock_no_mmap,
485-
.sendpage = sock_no_sendpage,
486485
.sendmsg = sock_no_sendmsg,
487486
.recvmsg = sock_no_recvmsg,
488487

@@ -1106,33 +1105,6 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size,
11061105
}
11071106
EXPORT_SYMBOL_GPL(af_alg_sendmsg);
11081107

1109-
/**
1110-
* af_alg_sendpage - sendpage system call handler
1111-
* @sock: socket of connection to user space to write to
1112-
* @page: data to send
1113-
* @offset: offset into page to begin sending
1114-
* @size: length of data
1115-
* @flags: message send/receive flags
1116-
*
1117-
* This is a generic implementation of sendpage to fill ctx->tsgl_list.
1118-
*/
1119-
ssize_t af_alg_sendpage(struct socket *sock, struct page *page,
1120-
int offset, size_t size, int flags)
1121-
{
1122-
struct bio_vec bvec;
1123-
struct msghdr msg = {
1124-
.msg_flags = flags | MSG_SPLICE_PAGES,
1125-
};
1126-
1127-
if (flags & MSG_SENDPAGE_NOTLAST)
1128-
msg.msg_flags |= MSG_MORE;
1129-
1130-
bvec_set_page(&bvec, page, size, offset);
1131-
iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, size);
1132-
return sock_sendmsg(sock, &msg);
1133-
}
1134-
EXPORT_SYMBOL_GPL(af_alg_sendpage);
1135-
11361108
/**
11371109
* af_alg_free_resources - release resources required for crypto request
11381110
* @areq: Request holding the TX and RX SGL

crypto/algif_aead.c

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
* The following concept of the memory management is used:
1010
*
1111
* The kernel maintains two SGLs, the TX SGL and the RX SGL. The TX SGL is
12-
* filled by user space with the data submitted via sendpage. Filling up
13-
* the TX SGL does not cause a crypto operation -- the data will only be
14-
* tracked by the kernel. Upon receipt of one recvmsg call, the caller must
15-
* provide a buffer which is tracked with the RX SGL.
12+
* filled by user space with the data submitted via sendmsg (maybe with
13+
* MSG_SPLICE_PAGES). Filling up the TX SGL does not cause a crypto operation
14+
* -- the data will only be tracked by the kernel. Upon receipt of one recvmsg
15+
* call, the caller must provide a buffer which is tracked with the RX SGL.
1616
*
1717
* During the processing of the recvmsg operation, the cipher request is
1818
* allocated and prepared. As part of the recvmsg operation, the processed
@@ -370,7 +370,6 @@ static struct proto_ops algif_aead_ops = {
370370

371371
.release = af_alg_release,
372372
.sendmsg = aead_sendmsg,
373-
.sendpage = af_alg_sendpage,
374373
.recvmsg = aead_recvmsg,
375374
.poll = af_alg_poll,
376375
};
@@ -422,18 +421,6 @@ static int aead_sendmsg_nokey(struct socket *sock, struct msghdr *msg,
422421
return aead_sendmsg(sock, msg, size);
423422
}
424423

425-
static ssize_t aead_sendpage_nokey(struct socket *sock, struct page *page,
426-
int offset, size_t size, int flags)
427-
{
428-
int err;
429-
430-
err = aead_check_key(sock);
431-
if (err)
432-
return err;
433-
434-
return af_alg_sendpage(sock, page, offset, size, flags);
435-
}
436-
437424
static int aead_recvmsg_nokey(struct socket *sock, struct msghdr *msg,
438425
size_t ignored, int flags)
439426
{
@@ -461,7 +448,6 @@ static struct proto_ops algif_aead_ops_nokey = {
461448

462449
.release = af_alg_release,
463450
.sendmsg = aead_sendmsg_nokey,
464-
.sendpage = aead_sendpage_nokey,
465451
.recvmsg = aead_recvmsg_nokey,
466452
.poll = af_alg_poll,
467453
};

crypto/algif_rng.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ static struct proto_ops algif_rng_ops = {
174174
.bind = sock_no_bind,
175175
.accept = sock_no_accept,
176176
.sendmsg = sock_no_sendmsg,
177-
.sendpage = sock_no_sendpage,
178177

179178
.release = af_alg_release,
180179
.recvmsg = rng_recvmsg,
@@ -192,7 +191,6 @@ static struct proto_ops __maybe_unused algif_rng_test_ops = {
192191
.mmap = sock_no_mmap,
193192
.bind = sock_no_bind,
194193
.accept = sock_no_accept,
195-
.sendpage = sock_no_sendpage,
196194

197195
.release = af_alg_release,
198196
.recvmsg = rng_test_recvmsg,

crypto/algif_skcipher.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ static struct proto_ops algif_skcipher_ops = {
194194

195195
.release = af_alg_release,
196196
.sendmsg = skcipher_sendmsg,
197-
.sendpage = af_alg_sendpage,
198197
.recvmsg = skcipher_recvmsg,
199198
.poll = af_alg_poll,
200199
};
@@ -246,18 +245,6 @@ static int skcipher_sendmsg_nokey(struct socket *sock, struct msghdr *msg,
246245
return skcipher_sendmsg(sock, msg, size);
247246
}
248247

249-
static ssize_t skcipher_sendpage_nokey(struct socket *sock, struct page *page,
250-
int offset, size_t size, int flags)
251-
{
252-
int err;
253-
254-
err = skcipher_check_key(sock);
255-
if (err)
256-
return err;
257-
258-
return af_alg_sendpage(sock, page, offset, size, flags);
259-
}
260-
261248
static int skcipher_recvmsg_nokey(struct socket *sock, struct msghdr *msg,
262249
size_t ignored, int flags)
263250
{
@@ -285,7 +272,6 @@ static struct proto_ops algif_skcipher_ops_nokey = {
285272

286273
.release = af_alg_release,
287274
.sendmsg = skcipher_sendmsg_nokey,
288-
.sendpage = skcipher_sendpage_nokey,
289275
.recvmsg = skcipher_recvmsg_nokey,
290276
.poll = af_alg_poll,
291277
};

drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,8 +569,6 @@ int chtls_sendmsg(struct sock *sk, struct msghdr *msg, size_t size);
569569
int chtls_recvmsg(struct sock *sk, struct msghdr *msg,
570570
size_t len, int flags, int *addr_len);
571571
void chtls_splice_eof(struct socket *sock);
572-
int chtls_sendpage(struct sock *sk, struct page *page,
573-
int offset, size_t size, int flags);
574572
int send_tx_flowc_wr(struct sock *sk, int compl,
575573
u32 snd_nxt, u32 rcv_nxt);
576574
void chtls_tcp_push(struct sock *sk, int flags);

drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_io.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,20 +1246,6 @@ void chtls_splice_eof(struct socket *sock)
12461246
release_sock(sk);
12471247
}
12481248

1249-
int chtls_sendpage(struct sock *sk, struct page *page,
1250-
int offset, size_t size, int flags)
1251-
{
1252-
struct msghdr msg = { .msg_flags = flags | MSG_SPLICE_PAGES, };
1253-
struct bio_vec bvec;
1254-
1255-
if (flags & MSG_SENDPAGE_NOTLAST)
1256-
msg.msg_flags |= MSG_MORE;
1257-
1258-
bvec_set_page(&bvec, page, size, offset);
1259-
iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, size);
1260-
return chtls_sendmsg(sk, &msg, size);
1261-
}
1262-
12631249
static void chtls_select_window(struct sock *sk)
12641250
{
12651251
struct chtls_sock *csk = rcu_dereference_sk_user_data(sk);

0 commit comments

Comments
 (0)