]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commit
libceph: define and use in_msg_pos_next()
authorAlex Elder <elder@inktank.com>
Sat, 9 Mar 2013 00:51:04 +0000 (18:51 -0600)
committerGreg Farnum <greg@inktank.com>
Wed, 13 Mar 2013 00:45:05 +0000 (17:45 -0700)
commita285d9ee815406ecc888a7bc3dd86fbf5dd0c949
treeb32bf79aa5a408daa5234a2b0ef01a364421b707
parent6c5f6120f32df00b7c4b025093d5485a860b3396
libceph: define and use in_msg_pos_next()

Define a new function in_msg_pos_next() to match out_msg_pos_next(),
and use it in place of code at the end of read_partial_message_pages()
and read_partial_message_bio().

Note that the page number is incremented and offset reset under
slightly different conditions from before.  The result is
equivalent, however, as explained below.

Each time an incoming message is going to arrive, we find out how
much room is left--not surpassing the current page--and provide that
as the number of bytes to receive.  So the amount we'll use is the
lesser of:  all that's left of the entire request; and all that's
left in the current page.

If we received exactly how many were requested, we either reached
the end of the request or the end of the page.  In the first case,
we're done, in the second, we move onto the next page in the array.

In all cases but (possibly) on the last page, after adding the
number of bytes received, page_pos == PAGE_SIZE.  On the last page,
it doesn't really matter whether we increment the page number and
reset the page position, because we're done and we won't come back
here again.  The code previously skipped over that last case,
basically.  The new code handles that case the same as the others,
incrementing and resetting.

Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
net/ceph/messenger.c