Commit 45a267db authored by Ilya Dryomov's avatar Ilya Dryomov

libceph: handle zero-length data items

rbd needs this for null copyups -- if copyup data is all zeroes, we
want to save some I/O and network bandwidth.  See rbd_obj_issue_copyup()
in the next commit.
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
Reviewed-by: default avatarAlex Elder <elder@linaro.org>
parent 7e07efb1
...@@ -1605,13 +1605,18 @@ static int write_partial_message_data(struct ceph_connection *con) ...@@ -1605,13 +1605,18 @@ static int write_partial_message_data(struct ceph_connection *con)
* been revoked, so use the zero page. * been revoked, so use the zero page.
*/ */
crc = do_datacrc ? le32_to_cpu(msg->footer.data_crc) : 0; crc = do_datacrc ? le32_to_cpu(msg->footer.data_crc) : 0;
while (cursor->resid) { while (cursor->total_resid) {
struct page *page; struct page *page;
size_t page_offset; size_t page_offset;
size_t length; size_t length;
bool last_piece; bool last_piece;
int ret; int ret;
if (!cursor->resid) {
ceph_msg_data_advance(cursor, 0);
continue;
}
page = ceph_msg_data_next(cursor, &page_offset, &length, page = ceph_msg_data_next(cursor, &page_offset, &length,
&last_piece); &last_piece);
ret = ceph_tcp_sendpage(con->sock, page, page_offset, ret = ceph_tcp_sendpage(con->sock, page, page_offset,
...@@ -2327,7 +2332,12 @@ static int read_partial_msg_data(struct ceph_connection *con) ...@@ -2327,7 +2332,12 @@ static int read_partial_msg_data(struct ceph_connection *con)
if (do_datacrc) if (do_datacrc)
crc = con->in_data_crc; crc = con->in_data_crc;
while (cursor->resid) { while (cursor->total_resid) {
if (!cursor->resid) {
ceph_msg_data_advance(cursor, 0);
continue;
}
page = ceph_msg_data_next(cursor, &page_offset, &length, NULL); page = ceph_msg_data_next(cursor, &page_offset, &length, NULL);
ret = ceph_tcp_recvpage(con->sock, page, page_offset, length); ret = ceph_tcp_recvpage(con->sock, page, page_offset, length);
if (ret <= 0) { if (ret <= 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment