diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2016-01-09 20:55:45 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2016-12-26 21:35:41 -0500 |
commit | 61ff6e9b452d6158e0fd659c6d987f47cfcfbd7b (patch) | |
tree | 2b37dddc0968d59fca2c22ca7299ca8c22fb8857 /net | |
parent | 39c6aceae961776a11a3767553b0e295fc9d413b (diff) |
ceph_tcp_sendpage(): use ITER_BVEC sendmsg
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'net')
-rw-r--r-- | net/ceph/messenger.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 9e46db7e5968..6f3b5754cc7e 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c | |||
@@ -583,18 +583,28 @@ static int __ceph_tcp_sendpage(struct socket *sock, struct page *page, | |||
583 | static int ceph_tcp_sendpage(struct socket *sock, struct page *page, | 583 | static int ceph_tcp_sendpage(struct socket *sock, struct page *page, |
584 | int offset, size_t size, bool more) | 584 | int offset, size_t size, bool more) |
585 | { | 585 | { |
586 | struct msghdr msg = { .msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL }; | ||
587 | struct bio_vec bvec; | ||
586 | int ret; | 588 | int ret; |
587 | struct kvec iov; | ||
588 | 589 | ||
589 | /* sendpage cannot properly handle pages with page_count == 0, | 590 | /* sendpage cannot properly handle pages with page_count == 0, |
590 | * we need to fallback to sendmsg if that's the case */ | 591 | * we need to fallback to sendmsg if that's the case */ |
591 | if (page_count(page) >= 1) | 592 | if (page_count(page) >= 1) |
592 | return __ceph_tcp_sendpage(sock, page, offset, size, more); | 593 | return __ceph_tcp_sendpage(sock, page, offset, size, more); |
593 | 594 | ||
594 | iov.iov_base = kmap(page) + offset; | 595 | bvec.bv_page = page; |
595 | iov.iov_len = size; | 596 | bvec.bv_offset = offset; |
596 | ret = ceph_tcp_sendmsg(sock, &iov, 1, size, more); | 597 | bvec.bv_len = size; |
597 | kunmap(page); | 598 | |
599 | if (more) | ||
600 | msg.msg_flags |= MSG_MORE; | ||
601 | else | ||
602 | msg.msg_flags |= MSG_EOR; /* superfluous, but what the hell */ | ||
603 | |||
604 | iov_iter_bvec(&msg.msg_iter, WRITE | ITER_BVEC, &bvec, 1, size); | ||
605 | ret = sock_sendmsg(sock, &msg); | ||
606 | if (ret == -EAGAIN) | ||
607 | ret = 0; | ||
598 | 608 | ||
599 | return ret; | 609 | return ret; |
600 | } | 610 | } |