Re: [PATCH 2/3] libceph: save and covert sr_datalen to host-endian

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

 



On Tue, 2023-10-24 at 13:00 +0800, xiubli@xxxxxxxxxx wrote:
> From: Xiubo Li <xiubli@xxxxxxxxxx>
> 
> We need to save the real data length to determine exactly how many
> data we can parse later.
> 
> URL: https://tracker.ceph.com/issues/62081
> Signed-off-by: Xiubo Li <xiubli@xxxxxxxxxx>
> ---
>  include/linux/ceph/osd_client.h | 3 ++-
>  net/ceph/osd_client.c           | 7 ++++++-
>  2 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h
> index bf9823956758..f703fb8030de 100644
> --- a/include/linux/ceph/osd_client.h
> +++ b/include/linux/ceph/osd_client.h
> @@ -45,6 +45,7 @@ enum ceph_sparse_read_state {
>  	CEPH_SPARSE_READ_HDR	= 0,
>  	CEPH_SPARSE_READ_EXTENTS,
>  	CEPH_SPARSE_READ_DATA_LEN,
> +	CEPH_SPARSE_READ_DATA_PRE,
>  	CEPH_SPARSE_READ_DATA,
>  };
>  
> @@ -64,7 +65,7 @@ struct ceph_sparse_read {
>  	u64				sr_req_len;  /* orig request length */
>  	u64				sr_pos;      /* current pos in buffer */
>  	int				sr_index;    /* current extent index */
> -	__le32				sr_datalen;  /* length of actual data */
> +	u32				sr_datalen;  /* length of actual data */
>  	u32				sr_count;    /* extent count in reply */
>  	int				sr_ext_len;  /* length of extent array */
>  	struct ceph_sparse_extent	*sr_extent;  /* extent array */
> diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
> index d3a759e052c8..800a2acec069 100644
> --- a/net/ceph/osd_client.c
> +++ b/net/ceph/osd_client.c
> @@ -5912,8 +5912,13 @@ static int osd_sparse_read(struct ceph_connection *con,
>  		convert_extent_map(sr);
>  		ret = sizeof(sr->sr_datalen);
>  		*pbuf = (char *)&sr->sr_datalen;
> -		sr->sr_state = CEPH_SPARSE_READ_DATA;
> +		sr->sr_state = CEPH_SPARSE_READ_DATA_PRE;
>  		break;
> +	case CEPH_SPARSE_READ_DATA_PRE:
> +		/* Convert sr_datalen to host-endian */
> +		sr->sr_datalen = le32_to_cpu((__force __le32)sr->sr_datalen);
> +		sr->sr_state = CEPH_SPARSE_READ_DATA;
> +		fallthrough;
>  	case CEPH_SPARSE_READ_DATA:
>  		if (sr->sr_index >= count) {
>  			sr->sr_state = CEPH_SPARSE_READ_HDR;


Reviewed-by: Jeff Layton <jlayton@xxxxxxxxxx>





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

  Powered by Linux