aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAlex Elder <elder@dreamhost.com>2012-03-07 12:40:08 -0500
committerAlex Elder <elder@dreamhost.com>2012-03-22 11:47:51 -0400
commit31739139f3ed7be802dd9019ec8d8cc910e3d241 (patch)
tree3182393002d7a8e29d230e30aa4920d7de737530 /net
parent37675b0f42a8f7699c3602350d1c3b2a1698a3d3 (diff)
libceph: use kernel_sendpage() for sending zeroes
If a message queued for send gets revoked, zeroes are sent over the wire instead of any unsent data. This is done by constructing a message and passing it to kernel_sendmsg() via ceph_tcp_sendmsg(). Since we are already working with a page in this case we can use the sendpage interface instead. Create a new ceph_tcp_sendpage() helper that sets up flags to match the way ceph_tcp_sendmsg() does now. Signed-off-by: Alex Elder <elder@dreamhost.com> Reviewed-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'net')
-rw-r--r--net/ceph/messenger.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 589b7689d31..9207a8c0b21 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -321,6 +321,19 @@ static int ceph_tcp_sendmsg(struct socket *sock, struct kvec *iov,
321 return r; 321 return r;
322} 322}
323 323
324static int ceph_tcp_sendpage(struct socket *sock, struct page *page,
325 int offset, size_t size, int more)
326{
327 int flags = MSG_DONTWAIT | MSG_NOSIGNAL | (more ? MSG_MORE : MSG_EOR);
328 int ret;
329
330 ret = kernel_sendpage(sock, page, offset, size, flags);
331 if (ret == -EAGAIN)
332 ret = 0;
333
334 return ret;
335}
336
324 337
325/* 338/*
326 * Shutdown/close the socket for the given connection. 339 * Shutdown/close the socket for the given connection.
@@ -944,12 +957,9 @@ static int write_partial_skip(struct ceph_connection *con)
944 int ret; 957 int ret;
945 958
946 while (con->out_skip > 0) { 959 while (con->out_skip > 0) {
947 struct kvec iov = { 960 size_t size = min(con->out_skip, (int) PAGE_CACHE_SIZE);
948 .iov_base = zero_page_address,
949 .iov_len = min(con->out_skip, (int)PAGE_CACHE_SIZE)
950 };
951 961
952 ret = ceph_tcp_sendmsg(con->sock, &iov, 1, iov.iov_len, 1); 962 ret = ceph_tcp_sendpage(con->sock, zero_page, 0, size, 1);
953 if (ret <= 0) 963 if (ret <= 0)
954 goto out; 964 goto out;
955 con->out_skip -= ret; 965 con->out_skip -= ret;