Skip to content

Commit 7c6f353

Browse files
dhowellsbrauner
authored andcommitted
iov_iter, net: Merge csum_and_copy_from_iter{,_full}() together
Move csum_and_copy_from_iter_full() out of line and then merge csum_and_copy_from_iter() into its only caller. Signed-off-by: David Howells <dhowells@redhat.com> Link: https://lore.kernel.org/r/20230925120309.1731676-12-dhowells@redhat.com cc: Alexander Viro <viro@zeniv.linux.org.uk> cc: Jens Axboe <axboe@kernel.dk> cc: Christoph Hellwig <hch@lst.de> cc: Christian Brauner <christian@brauner.io> cc: Matthew Wilcox <willy@infradead.org> cc: Linus Torvalds <torvalds@linux-foundation.org> cc: David Laight <David.Laight@ACULAB.COM> cc: "David S. Miller" <davem@davemloft.net> cc: Eric Dumazet <edumazet@google.com> cc: Jakub Kicinski <kuba@kernel.org> cc: Paolo Abeni <pabeni@redhat.com> cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org cc: netdev@vger.kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent dc32bff commit 7c6f353

3 files changed

Lines changed: 20 additions & 24 deletions

File tree

include/linux/skbuff.h

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3679,23 +3679,8 @@ static inline int __must_check skb_put_padto(struct sk_buff *skb, unsigned int l
36793679
return __skb_put_padto(skb, len, true);
36803680
}
36813681

3682-
struct csum_state {
3683-
__wsum csum;
3684-
size_t off;
3685-
};
3686-
3687-
size_t csum_and_copy_from_iter(void *addr, size_t bytes, __wsum *csum, struct iov_iter *i);
3688-
3689-
static __always_inline __must_check
3690-
bool csum_and_copy_from_iter_full(void *addr, size_t bytes,
3691-
__wsum *csum, struct iov_iter *i)
3692-
{
3693-
size_t copied = csum_and_copy_from_iter(addr, bytes, csum, i);
3694-
if (likely(copied == bytes))
3695-
return true;
3696-
iov_iter_revert(i, copied);
3697-
return false;
3698-
}
3682+
bool csum_and_copy_from_iter_full(void *addr, size_t bytes, __wsum *csum, struct iov_iter *i)
3683+
__must_check;
36993684

37003685
static inline int skb_add_data(struct sk_buff *skb,
37013686
struct iov_iter *from, int copy)

net/core/datagram.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,11 @@ size_t memcpy_to_iter_csum(void *iter_to, size_t progress,
738738
return 0;
739739
}
740740

741+
struct csum_state {
742+
__wsum csum;
743+
size_t off;
744+
};
745+
741746
static size_t csum_and_copy_to_iter(const void *addr, size_t bytes, void *_csstate,
742747
struct iov_iter *i)
743748
{

net/core/skbuff.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6955,13 +6955,19 @@ size_t copy_from_user_iter_csum(void __user *iter_from, size_t progress,
69556955
return next ? 0 : len;
69566956
}
69576957

6958-
size_t csum_and_copy_from_iter(void *addr, size_t bytes, __wsum *csum,
6959-
struct iov_iter *i)
6958+
bool csum_and_copy_from_iter_full(void *addr, size_t bytes,
6959+
__wsum *csum, struct iov_iter *i)
69606960
{
6961+
size_t copied;
6962+
69616963
if (WARN_ON_ONCE(!i->data_source))
6962-
return 0;
6963-
return iterate_and_advance2(i, bytes, addr, csum,
6964-
copy_from_user_iter_csum,
6965-
memcpy_from_iter_csum);
6964+
return false;
6965+
copied = iterate_and_advance2(i, bytes, addr, csum,
6966+
copy_from_user_iter_csum,
6967+
memcpy_from_iter_csum);
6968+
if (likely(copied == bytes))
6969+
return true;
6970+
iov_iter_revert(i, copied);
6971+
return false;
69666972
}
6967-
EXPORT_SYMBOL(csum_and_copy_from_iter);
6973+
EXPORT_SYMBOL(csum_and_copy_from_iter_full);

0 commit comments

Comments
 (0)