libceph: fix a compile warning

I plan to roll this into the original patch that created this code
before I commit.

Signed-off-by: Alex Elder <elder@inktank.com>
libceph: rearrange generic cursor functions

This patch rearranges the generic cursor functions slightly
in preparation for some upcoming changes to them.

I still haven't committed the patches that created these functions,
so I expect to roll these changes into those patches rather than
commit them separately.

Signed-off-by: Alex Elder <elder@inktank.com>
libceph: make last_piece argument be optional

Allow supplying the "last_piece" parameter to ceph_msg_data_next()
to be optional, allowing a null pointer to be provided if the caller
doesn't need to know.

Have ceph_msg_data_next() handle setting the passed-in "last_piece"
address, filling it in (if provided) with the cursor->last_piece
value recorded by the type-specific ceph_msg_data_*_next() function.
This allows the "last_piece" parameter from those type-specific
functions to be dropped.

Signed-off-by: Alex Elder <elder@inktank.com>
libceph: drop pages parameter

The "pages" parameter in read_partial_message_pages() is
unused, so get rid of it.

Signed-off-by: Alex Elder <elder@inktank.com>
libceph: no outbound zero data

There is handling in write_partial_message_data() for the case where
only the length of--and no other information about--the data to be
sent has been specified.  This case doesn't occur.  All message
senders set up a page array, pagelist, or bio describing the data
to be sent.  So eliminate the block of code that handles this (but
check and issue a warning in case it occurs).

Signed-off-by: Alex Elder <elder@inktank.com>
libceph: record residual bytes for all message data types

All of the data types can use this, not just the page array.  Until
now, only the bio type doesn't have it available, and only the
initiator of the request (the rbd client) is able to supply the
length of the full request without re-scanning the bio list.  Change
the cursor init routines so the length is supplied based on the
message header "data_len" field, and use that length to intiialize
the "resid" field of the cursor.

Signed-off-by: Alex Elder <elder@inktank.com>
libceph: use cursor for bio reads

Replace the use of the information in con->in_msg_pos for incoming
bio data.  The old in_msg_pos and the new cursor mechanism do
basically the same thing, just slightly differently.

The main functional difference is that in_msg_pos keeps track of the
length of the complete bio list, and assumed it was fully consumed
when that many bytes had been transferred.  The cursor does not assume
a length, it simply consumes all bytes in the bio list.  Because the
only user of bio data is the rbd client, and because the length of a
bio list provided by rbd client always matches the number of bytes
in the list, both ways of tracking length are equivalent.

In addition, for in_msg_pos the initial bio vector is selected as
the initial value of the bio->bi_idx, while the cursor assumes this
is zero.  Again, the rbd client always passes 0 as the initial index
so the effect is the same.

Other than that, they basically match:
    in_msg_pos      cursor
    ----------      ------
    bio_iter        bio
    bio_seg         vec_index
    page_pos        page_offset

The in_msg_pos field is initialized by a call to init_bio_iter().
The bio cursor is initialized by ceph_msg_data_cursor_init().
Both now happen in the same spot, in prepare_message_data().

The in_msg_pos field is advanced by a call to in_msg_pos_next(),
which updates page_pos and calls iter_bio_next() to move to the next
bio vector, or to the next bio in the list.  The cursor is advanced
by ceph_msg_data_advance().  That isn't currently happening so
add a call to that in in_msg_pos_next().

Finally, the next piece of data to use for a read is determined
by a bunch of lines in read_partial_message_bio().  Those can be
replaced by an equivalent ceph_msg_data_bio_next() call.

Since the read path has no need to know whether the next piece of a
bio to use is the last, allow it to pass a null pointer as its
last_piece argument to ceph_msg_data_bio_next().

Signed-off-by: Alex Elder <elder@inktank.com>
libceph: kill ceph message bio_iter, bio_seg

They're no longer use, we use the cursor instead.

Signed-off-by: Alex Elder <elder@inktank.com>
libceph: use cursor for inbound data pages

Use the cursor for this too.

Signed-off-by: Alex Elder <elder@inktank.com>
libceph: get rid of read helpers

Now that read_partial_message_pages() and read_partial_message_bio()
are literally identical functions we can factor them out.  They're
pretty simple as well, so just move their content into
read_partial_msg_data().

Signed-off-by: Alex Elder <elder@inktank.com>
libceph: collapse all data items into one

Only one is ever used at a time, so just use a single generic data
item (named "data") and get rid of the separate pages, pagelist, and
bio items.

Signed-off-by: Alex Elder <elder@inktank.com>
libceph: use cursor resid for loop condition

Use the "resid" field of a cursor to determine when all data has
been sent or received.

Signed-off-by: Alex Elder <elder@inktank.com>
libceph: kill most of ceph_msg_pos

All but one of the fields are now unused, so get rid of them.

Signed-off-by: Alex Elder <elder@inktank.com>
libceph: kill last of ceph_msg_pos

The only field left is did_page_crc.  So get rid of it, and move the
flag determining whether crc is deeded into the cursor structure.

Signed-off-by: Alex Elder <elder@inktank.com>
libceph: use advance, not pos_next

The *_msg_pos_next() functions do little more than call
ceph_msg_data_advance(), so just call that and get rid of the
wrapper functions.

Signed-off-by: Alex Elder <elder@inktank.com>
libceph: tiny crc optimization

Pretty unimportant.

Signed-off-by: Alex Elder <elder@inktank.com>
libceph: make message data be a pointer

That.

Signed-off-by: Alex Elder <elder@inktank.com>