]> Pileus Git - ~andy/linux/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)
committerSage Weil <sage@inktank.com>
Thu, 2 May 2013 04:16:33 +0000 (21:16 -0700)
commite788182fa6c1a400076278a75d0efa0a8a08e4ec
treeae827f745b808a42c20761be12ac5bb435d109e9
parentb3d56fab333bbb3ac7300843d69e52d7bd8a016b
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