Skip to content

Commit

Permalink
libceph: use kernel_sendpage() for sending zeroes
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Sage Weil <[email protected]>
  • Loading branch information
Alex Elder committed Mar 22, 2012
1 parent 37675b0 commit 3173913
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions net/ceph/messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,19 @@ 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, int 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;
}


/*
* Shutdown/close the socket for the given connection.
Expand Down Expand Up @@ -944,12 +957,9 @@ static int write_partial_skip(struct ceph_connection *con)
int ret;

while (con->out_skip > 0) {
struct kvec iov = {
.iov_base = zero_page_address,
.iov_len = min(con->out_skip, (int)PAGE_CACHE_SIZE)
};
size_t size = min(con->out_skip, (int) PAGE_CACHE_SIZE);

ret = ceph_tcp_sendmsg(con->sock, &iov, 1, iov.iov_len, 1);
ret = ceph_tcp_sendpage(con->sock, zero_page, 0, size, 1);
if (ret <= 0)
goto out;
con->out_skip -= ret;
Expand Down

0 comments on commit 3173913

Please sign in to comment.