Re: [PATCH 11/32] libceph: handle zero-length data items

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03/16/2018 07:37 AM, Alex Elder wrote:
> From: Ilya Dryomov <idryomov@xxxxxxxxx>
> 
> 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@xxxxxxxxx>

I don't think I realized you could advance a message by 0 bytes.
I think it's not really intuitive, although I do think that
encoding a 0-byte data item to mean implicitly zero-filled is
a good convention.  Anyway, I feel like there should be an
explicit comment above ceph_msg_data_advance() to explain that
would be good.  (Maybe I've just forgotten about this, or maybe
it's explained elsewhere...)

Anwyay, this looks fine to me.

Reviewed-by: Alex Elder <elder@xxxxxxxxxx>

> ---
>  net/ceph/messenger.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
> index 91a57857cf11..cee4b3d307de 100644
> --- a/net/ceph/messenger.c
> +++ b/net/ceph/messenger.c
> @@ -1605,13 +1605,18 @@ static int write_partial_message_data(struct ceph_connection *con)
>  	 * been revoked, so use the zero page.
>  	 */
>  	crc = do_datacrc ? le32_to_cpu(msg->footer.data_crc) : 0;
> -	while (cursor->resid) {
> +	while (cursor->total_resid) {
>  		struct page *page;
>  		size_t page_offset;
>  		size_t length;
>  		bool last_piece;
>  		int ret;
>  
> +		if (!cursor->resid) {
> +			ceph_msg_data_advance(cursor, 0);
> +			continue;
> +		}
> +
>  		page = ceph_msg_data_next(cursor, &page_offset, &length,
>  					  &last_piece);
>  		ret = ceph_tcp_sendpage(con->sock, page, page_offset,
> @@ -2327,7 +2332,12 @@ static int read_partial_msg_data(struct ceph_connection *con)
>  
>  	if (do_datacrc)
>  		crc = con->in_data_crc;
> -	while (cursor->resid) {
> +	while (cursor->total_resid) {
> +		if (!cursor->resid) {
> +			ceph_msg_data_advance(cursor, 0);
> +			continue;
> +		}
> +
>  		page = ceph_msg_data_next(cursor, &page_offset, &length, NULL);
>  		ret = ceph_tcp_recvpage(con->sock, page, page_offset, length);
>  		if (ret <= 0) {
> 

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux