diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2016-09-17 21:02:10 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2016-10-03 20:40:56 -0400 |
commit | 25869262ef7af24ccde988867ac3eb1c3d4b88d4 (patch) | |
tree | b625a7350e316e4fe2033e5689fb0bbc6b3e2973 | |
parent | 79fddc4efd5d4de5cf210fe5ecf4d2734140849a (diff) |
skb_splice_bits(): get rid of callback
since pipe_lock is the outermost now, we don't need to drop/regain
socket locks around the call of splice_to_pipe() from skb_splice_bits(),
which kills the need to have a socket-specific callback; we can just
call splice_to_pipe() and be done with that.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | include/linux/skbuff.h | 8 | ||||
-rw-r--r-- | net/core/skbuff.c | 28 | ||||
-rw-r--r-- | net/ipv4/tcp.c | 3 | ||||
-rw-r--r-- | net/kcm/kcmsock.c | 16 | ||||
-rw-r--r-- | net/unix/af_unix.c | 17 |
5 files changed, 6 insertions, 66 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 0f665cb26b50..f520251ec43f 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
@@ -3021,15 +3021,9 @@ int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len); | |||
3021 | int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len); | 3021 | int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len); |
3022 | __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, u8 *to, | 3022 | __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, u8 *to, |
3023 | int len, __wsum csum); | 3023 | int len, __wsum csum); |
3024 | ssize_t skb_socket_splice(struct sock *sk, | ||
3025 | struct pipe_inode_info *pipe, | ||
3026 | struct splice_pipe_desc *spd); | ||
3027 | int skb_splice_bits(struct sk_buff *skb, struct sock *sk, unsigned int offset, | 3024 | int skb_splice_bits(struct sk_buff *skb, struct sock *sk, unsigned int offset, |
3028 | struct pipe_inode_info *pipe, unsigned int len, | 3025 | struct pipe_inode_info *pipe, unsigned int len, |
3029 | unsigned int flags, | 3026 | unsigned int flags); |
3030 | ssize_t (*splice_cb)(struct sock *, | ||
3031 | struct pipe_inode_info *, | ||
3032 | struct splice_pipe_desc *)); | ||
3033 | void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to); | 3027 | void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to); |
3034 | unsigned int skb_zerocopy_headlen(const struct sk_buff *from); | 3028 | unsigned int skb_zerocopy_headlen(const struct sk_buff *from); |
3035 | int skb_zerocopy(struct sk_buff *to, struct sk_buff *from, | 3029 | int skb_zerocopy(struct sk_buff *to, struct sk_buff *from, |
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 3864b4b68fa1..208a9bc4af74 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c | |||
@@ -1962,37 +1962,13 @@ static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info *pipe, | |||
1962 | return false; | 1962 | return false; |
1963 | } | 1963 | } |
1964 | 1964 | ||
1965 | ssize_t skb_socket_splice(struct sock *sk, | ||
1966 | struct pipe_inode_info *pipe, | ||
1967 | struct splice_pipe_desc *spd) | ||
1968 | { | ||
1969 | int ret; | ||
1970 | |||
1971 | /* Drop the socket lock, otherwise we have reverse | ||
1972 | * locking dependencies between sk_lock and i_mutex | ||
1973 | * here as compared to sendfile(). We enter here | ||
1974 | * with the socket lock held, and splice_to_pipe() will | ||
1975 | * grab the pipe inode lock. For sendfile() emulation, | ||
1976 | * we call into ->sendpage() with the i_mutex lock held | ||
1977 | * and networking will grab the socket lock. | ||
1978 | */ | ||
1979 | release_sock(sk); | ||
1980 | ret = splice_to_pipe(pipe, spd); | ||
1981 | lock_sock(sk); | ||
1982 | |||
1983 | return ret; | ||
1984 | } | ||
1985 | |||
1986 | /* | 1965 | /* |
1987 | * Map data from the skb to a pipe. Should handle both the linear part, | 1966 | * Map data from the skb to a pipe. Should handle both the linear part, |
1988 | * the fragments, and the frag list. | 1967 | * the fragments, and the frag list. |
1989 | */ | 1968 | */ |
1990 | int skb_splice_bits(struct sk_buff *skb, struct sock *sk, unsigned int offset, | 1969 | int skb_splice_bits(struct sk_buff *skb, struct sock *sk, unsigned int offset, |
1991 | struct pipe_inode_info *pipe, unsigned int tlen, | 1970 | struct pipe_inode_info *pipe, unsigned int tlen, |
1992 | unsigned int flags, | 1971 | unsigned int flags) |
1993 | ssize_t (*splice_cb)(struct sock *, | ||
1994 | struct pipe_inode_info *, | ||
1995 | struct splice_pipe_desc *)) | ||
1996 | { | 1972 | { |
1997 | struct partial_page partial[MAX_SKB_FRAGS]; | 1973 | struct partial_page partial[MAX_SKB_FRAGS]; |
1998 | struct page *pages[MAX_SKB_FRAGS]; | 1974 | struct page *pages[MAX_SKB_FRAGS]; |
@@ -2009,7 +1985,7 @@ int skb_splice_bits(struct sk_buff *skb, struct sock *sk, unsigned int offset, | |||
2009 | __skb_splice_bits(skb, pipe, &offset, &tlen, &spd, sk); | 1985 | __skb_splice_bits(skb, pipe, &offset, &tlen, &spd, sk); |
2010 | 1986 | ||
2011 | if (spd.nr_pages) | 1987 | if (spd.nr_pages) |
2012 | ret = splice_cb(sk, pipe, &spd); | 1988 | ret = splice_to_pipe(pipe, &spd); |
2013 | 1989 | ||
2014 | return ret; | 1990 | return ret; |
2015 | } | 1991 | } |
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index ffbb218de520..ddd2179538f7 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -688,8 +688,7 @@ static int tcp_splice_data_recv(read_descriptor_t *rd_desc, struct sk_buff *skb, | |||
688 | int ret; | 688 | int ret; |
689 | 689 | ||
690 | ret = skb_splice_bits(skb, skb->sk, offset, tss->pipe, | 690 | ret = skb_splice_bits(skb, skb->sk, offset, tss->pipe, |
691 | min(rd_desc->count, len), tss->flags, | 691 | min(rd_desc->count, len), tss->flags); |
692 | skb_socket_splice); | ||
693 | if (ret > 0) | 692 | if (ret > 0) |
694 | rd_desc->count -= ret; | 693 | rd_desc->count -= ret; |
695 | return ret; | 694 | return ret; |
diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c index 411693288648..8a720ba50061 100644 --- a/net/kcm/kcmsock.c +++ b/net/kcm/kcmsock.c | |||
@@ -1462,19 +1462,6 @@ out: | |||
1462 | return copied ? : err; | 1462 | return copied ? : err; |
1463 | } | 1463 | } |
1464 | 1464 | ||
1465 | static ssize_t kcm_sock_splice(struct sock *sk, | ||
1466 | struct pipe_inode_info *pipe, | ||
1467 | struct splice_pipe_desc *spd) | ||
1468 | { | ||
1469 | int ret; | ||
1470 | |||
1471 | release_sock(sk); | ||
1472 | ret = splice_to_pipe(pipe, spd); | ||
1473 | lock_sock(sk); | ||
1474 | |||
1475 | return ret; | ||
1476 | } | ||
1477 | |||
1478 | static ssize_t kcm_splice_read(struct socket *sock, loff_t *ppos, | 1465 | static ssize_t kcm_splice_read(struct socket *sock, loff_t *ppos, |
1479 | struct pipe_inode_info *pipe, size_t len, | 1466 | struct pipe_inode_info *pipe, size_t len, |
1480 | unsigned int flags) | 1467 | unsigned int flags) |
@@ -1504,8 +1491,7 @@ static ssize_t kcm_splice_read(struct socket *sock, loff_t *ppos, | |||
1504 | if (len > rxm->full_len) | 1491 | if (len > rxm->full_len) |
1505 | len = rxm->full_len; | 1492 | len = rxm->full_len; |
1506 | 1493 | ||
1507 | copied = skb_splice_bits(skb, sk, rxm->offset, pipe, len, flags, | 1494 | copied = skb_splice_bits(skb, sk, rxm->offset, pipe, len, flags); |
1508 | kcm_sock_splice); | ||
1509 | if (copied < 0) { | 1495 | if (copied < 0) { |
1510 | err = copied; | 1496 | err = copied; |
1511 | goto err_out; | 1497 | goto err_out; |
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 8309687a56b0..145082e2ba36 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -2475,28 +2475,13 @@ static int unix_stream_recvmsg(struct socket *sock, struct msghdr *msg, | |||
2475 | return unix_stream_read_generic(&state); | 2475 | return unix_stream_read_generic(&state); |
2476 | } | 2476 | } |
2477 | 2477 | ||
2478 | static ssize_t skb_unix_socket_splice(struct sock *sk, | ||
2479 | struct pipe_inode_info *pipe, | ||
2480 | struct splice_pipe_desc *spd) | ||
2481 | { | ||
2482 | int ret; | ||
2483 | struct unix_sock *u = unix_sk(sk); | ||
2484 | |||
2485 | mutex_unlock(&u->iolock); | ||
2486 | ret = splice_to_pipe(pipe, spd); | ||
2487 | mutex_lock(&u->iolock); | ||
2488 | |||
2489 | return ret; | ||
2490 | } | ||
2491 | |||
2492 | static int unix_stream_splice_actor(struct sk_buff *skb, | 2478 | static int unix_stream_splice_actor(struct sk_buff *skb, |
2493 | int skip, int chunk, | 2479 | int skip, int chunk, |
2494 | struct unix_stream_read_state *state) | 2480 | struct unix_stream_read_state *state) |
2495 | { | 2481 | { |
2496 | return skb_splice_bits(skb, state->socket->sk, | 2482 | return skb_splice_bits(skb, state->socket->sk, |
2497 | UNIXCB(skb).consumed + skip, | 2483 | UNIXCB(skb).consumed + skip, |
2498 | state->pipe, chunk, state->splice_flags, | 2484 | state->pipe, chunk, state->splice_flags); |
2499 | skb_unix_socket_splice); | ||
2500 | } | 2485 | } |
2501 | 2486 | ||
2502 | static ssize_t unix_stream_splice_read(struct socket *sock, loff_t *ppos, | 2487 | static ssize_t unix_stream_splice_read(struct socket *sock, loff_t *ppos, |