Skip to content

Commit

Permalink
libceph: small refactor in write_partial_kvec()
Browse files Browse the repository at this point in the history
Make a small change in the code that counts down kvecs consumed by
a ceph_tcp_sendmsg() call.  Same functionality, just blocked out
a little differently.

Signed-off-by: Alex Elder <elder@dreamhost.com>
Signed-off-by: Sage Weil <sage@newdream.net>
  • Loading branch information
Alex Elder committed Mar 22, 2012
1 parent fe3ad59 commit f42299e
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions net/ceph/messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -747,17 +747,18 @@ static int write_partial_kvec(struct ceph_connection *con)
con->out_kvec_bytes -= ret;
if (con->out_kvec_bytes == 0)
break; /* done */
while (ret > 0) {
if (ret >= con->out_kvec_cur->iov_len) {
ret -= con->out_kvec_cur->iov_len;
con->out_kvec_cur++;
con->out_kvec_left--;
} else {
con->out_kvec_cur->iov_len -= ret;
con->out_kvec_cur->iov_base += ret;
ret = 0;
break;
}

/* account for full iov entries consumed */
while (ret >= con->out_kvec_cur->iov_len) {
BUG_ON(!con->out_kvec_left);
ret -= con->out_kvec_cur->iov_len;
con->out_kvec_cur++;
con->out_kvec_left--;
}
/* and for a partially-consumed entry */
if (ret) {
con->out_kvec_cur->iov_len -= ret;
con->out_kvec_cur->iov_base += ret;
}
}
con->out_kvec_left = 0;
Expand Down

0 comments on commit f42299e

Please sign in to comment.