diff options
author | Ilya Dryomov <idryomov@gmail.com> | 2018-11-16 11:58:19 +0100 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2018-12-26 15:56:04 +0100 |
commit | 3239eb5215ebdef593a79316c9dbbdf8849166ec (patch) | |
tree | f76919e91cc7fcc004eac6a4c9364c110338e3c5 /net/ceph | |
parent | 1f6b821aef78e3d79e8d598ae59fc7e23fb6c563 (diff) | |
download | linux-3239eb5215ebdef593a79316c9dbbdf8849166ec.tar.bz2 |
libceph: use sock_no_sendpage() as a fallback in ceph_tcp_sendpage()
sock_no_sendpage() makes the code cleaner.
Also, don't set MSG_EOR. sendpage doesn't act on MSG_EOR on its own,
it just honors the setting from the preceding sendmsg call by looking
at ->eor in tcp_skb_can_collapse_to().
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'net/ceph')
-rw-r--r-- | net/ceph/messenger.c | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index cca96d32ac64..21a743a3bd29 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -560,24 +560,12 @@ static int ceph_tcp_sendmsg(struct socket *sock, struct kvec *iov, return r; } -static int __ceph_tcp_sendpage(struct socket *sock, struct page *page, - int offset, size_t size, bool more) -{ - int flags = MSG_DONTWAIT | MSG_NOSIGNAL | (more ? MSG_MORE : MSG_EOR); - int ret; - - ret = kernel_sendpage(sock, page, offset, size, flags); - if (ret == -EAGAIN) - ret = 0; - - return ret; -} - static int ceph_tcp_sendpage(struct socket *sock, struct page *page, int offset, size_t size, bool more) { - struct msghdr msg = { .msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL }; - struct bio_vec bvec; + ssize_t (*sendpage)(struct socket *sock, struct page *page, + int offset, size_t size, int flags); + int flags = MSG_DONTWAIT | MSG_NOSIGNAL | (more ? MSG_MORE : 0); int ret; /* @@ -589,19 +577,11 @@ static int ceph_tcp_sendpage(struct socket *sock, struct page *page, * triggers one of hardened usercopy checks. */ if (page_count(page) >= 1 && !PageSlab(page)) - return __ceph_tcp_sendpage(sock, page, offset, size, more); - - bvec.bv_page = page; - bvec.bv_offset = offset; - bvec.bv_len = size; - - if (more) - msg.msg_flags |= MSG_MORE; + sendpage = sock->ops->sendpage; else - msg.msg_flags |= MSG_EOR; /* superfluous, but what the hell */ + sendpage = sock_no_sendpage; - iov_iter_bvec(&msg.msg_iter, WRITE, &bvec, 1, size); - ret = sock_sendmsg(sock, &msg); + ret = sendpage(sock, page, offset, size, flags); if (ret == -EAGAIN) ret = 0; |