Skip to content

Commit 45a267d

Browse files
committed
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: Ilya Dryomov <idryomov@gmail.com> Reviewed-by: Alex Elder <elder@linaro.org>
1 parent 7e07efb commit 45a267d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

net/ceph/messenger.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,13 +1605,18 @@ static int write_partial_message_data(struct ceph_connection *con)
16051605
* been revoked, so use the zero page.
16061606
*/
16071607
crc = do_datacrc ? le32_to_cpu(msg->footer.data_crc) : 0;
1608-
while (cursor->resid) {
1608+
while (cursor->total_resid) {
16091609
struct page *page;
16101610
size_t page_offset;
16111611
size_t length;
16121612
bool last_piece;
16131613
int ret;
16141614

1615+
if (!cursor->resid) {
1616+
ceph_msg_data_advance(cursor, 0);
1617+
continue;
1618+
}
1619+
16151620
page = ceph_msg_data_next(cursor, &page_offset, &length,
16161621
&last_piece);
16171622
ret = ceph_tcp_sendpage(con->sock, page, page_offset,
@@ -2327,7 +2332,12 @@ static int read_partial_msg_data(struct ceph_connection *con)
23272332

23282333
if (do_datacrc)
23292334
crc = con->in_data_crc;
2330-
while (cursor->resid) {
2335+
while (cursor->total_resid) {
2336+
if (!cursor->resid) {
2337+
ceph_msg_data_advance(cursor, 0);
2338+
continue;
2339+
}
2340+
23312341
page = ceph_msg_data_next(cursor, &page_offset, &length, NULL);
23322342
ret = ceph_tcp_recvpage(con->sock, page, page_offset, length);
23332343
if (ret <= 0) {

0 commit comments

Comments
 (0)