diff mbox

[1/2] libceph: add osd_req_op_extent_osd_data_bvecs()

Message ID 1525446256-1882-2-git-send-email-idryomov@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ilya Dryomov May 4, 2018, 3:04 p.m. UTC
... and store num_bvecs for client code's convenience.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
---
 drivers/block/rbd.c             |  4 +++-
 include/linux/ceph/osd_client.h | 12 ++++++++++--
 net/ceph/osd_client.c           | 27 +++++++++++++++++++++++----
 3 files changed, 36 insertions(+), 7 deletions(-)

Comments

Jeff Layton May 4, 2018, 3:54 p.m. UTC | #1
On Fri, 2018-05-04 at 17:04 +0200, Ilya Dryomov wrote:
> ... and store num_bvecs for client code's convenience.
> 
> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
> ---
>  drivers/block/rbd.c             |  4 +++-
>  include/linux/ceph/osd_client.h | 12 ++++++++++--
>  net/ceph/osd_client.c           | 27 +++++++++++++++++++++++----
>  3 files changed, 36 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index 50b9d0f8ac0b..2b4e90d06822 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -2369,7 +2369,9 @@ static int rbd_obj_issue_copyup(struct rbd_obj_request *obj_req, u32 bytes)
>  		bytes = 0;
>  	}
>  	osd_req_op_cls_request_data_bvecs(obj_req->osd_req, 0,
> -					  obj_req->copyup_bvecs, bytes);
> +					  obj_req->copyup_bvecs,
> +					  obj_req->copyup_bvec_count,
> +					  bytes);
>  
>  	switch (obj_req->img_request->op_type) {
>  	case OBJ_OP_WRITE:
> diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h
> index ba3d8c262f8d..b73dd7ebe585 100644
> --- a/include/linux/ceph/osd_client.h
> +++ b/include/linux/ceph/osd_client.h
> @@ -77,7 +77,10 @@ struct ceph_osd_data {
>  			u32			bio_length;
>  		};
>  #endif /* CONFIG_BLOCK */
> -		struct ceph_bvec_iter	bvec_pos;
> +		struct {
> +			struct ceph_bvec_iter	bvec_pos;
> +			u32			num_bvecs;
> +		};

Does the above struct add anything of value? Maybe just add a new
num_bvecs member there?

>  	};
>  };
>  
> @@ -412,6 +415,10 @@ void osd_req_op_extent_osd_data_bio(struct ceph_osd_request *osd_req,
>  				    struct ceph_bio_iter *bio_pos,
>  				    u32 bio_length);
>  #endif /* CONFIG_BLOCK */
> +void osd_req_op_extent_osd_data_bvecs(struct ceph_osd_request *osd_req,
> +				      unsigned int which,
> +				      struct bio_vec *bvecs, u32 num_bvecs,
> +				      u32 bytes);
>  void osd_req_op_extent_osd_data_bvec_pos(struct ceph_osd_request *osd_req,
>  					 unsigned int which,
>  					 struct ceph_bvec_iter *bvec_pos);
> @@ -426,7 +433,8 @@ extern void osd_req_op_cls_request_data_pages(struct ceph_osd_request *,
>  					bool own_pages);
>  void osd_req_op_cls_request_data_bvecs(struct ceph_osd_request *osd_req,
>  				       unsigned int which,
> -				       struct bio_vec *bvecs, u32 bytes);
> +				       struct bio_vec *bvecs, u32 num_bvecs,
> +				       u32 bytes);
>  extern void osd_req_op_cls_response_data_pages(struct ceph_osd_request *,
>  					unsigned int which,
>  					struct page **pages, u64 length,
> diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
> index a2e2c366e063..08b5fc1f90cc 100644
> --- a/net/ceph/osd_client.c
> +++ b/net/ceph/osd_client.c
> @@ -157,10 +157,12 @@ static void ceph_osd_data_bio_init(struct ceph_osd_data *osd_data,
>  #endif /* CONFIG_BLOCK */
>  
>  static void ceph_osd_data_bvecs_init(struct ceph_osd_data *osd_data,
> -				     struct ceph_bvec_iter *bvec_pos)
> +				     struct ceph_bvec_iter *bvec_pos,
> +				     u32 num_bvecs)
>  {
>  	osd_data->type = CEPH_OSD_DATA_TYPE_BVECS;
>  	osd_data->bvec_pos = *bvec_pos;
> +	osd_data->num_bvecs = num_bvecs;
>  }
>  
>  #define osd_req_op_data(oreq, whch, typ, fld)				\
> @@ -237,6 +239,22 @@ void osd_req_op_extent_osd_data_bio(struct ceph_osd_request *osd_req,
>  EXPORT_SYMBOL(osd_req_op_extent_osd_data_bio);
>  #endif /* CONFIG_BLOCK */
>  
> +void osd_req_op_extent_osd_data_bvecs(struct ceph_osd_request *osd_req,
> +				      unsigned int which,
> +				      struct bio_vec *bvecs, u32 num_bvecs,
> +				      u32 bytes)
> +{
> +	struct ceph_osd_data *osd_data;
> +	struct ceph_bvec_iter it = {
> +		.bvecs = bvecs,
> +		.iter = { .bi_size = bytes },
> +	};
> +
> +	osd_data = osd_req_op_data(osd_req, which, extent, osd_data);
> +	ceph_osd_data_bvecs_init(osd_data, &it, num_bvecs);
> +}
> +EXPORT_SYMBOL(osd_req_op_extent_osd_data_bvecs);
> +
>  void osd_req_op_extent_osd_data_bvec_pos(struct ceph_osd_request *osd_req,
>  					 unsigned int which,
>  					 struct ceph_bvec_iter *bvec_pos)
> @@ -244,7 +262,7 @@ void osd_req_op_extent_osd_data_bvec_pos(struct ceph_osd_request *osd_req,
>  	struct ceph_osd_data *osd_data;
>  
>  	osd_data = osd_req_op_data(osd_req, which, extent, osd_data);
> -	ceph_osd_data_bvecs_init(osd_data, bvec_pos);
> +	ceph_osd_data_bvecs_init(osd_data, bvec_pos, 0);
>  }
>  EXPORT_SYMBOL(osd_req_op_extent_osd_data_bvec_pos);
>  
> @@ -287,7 +305,8 @@ EXPORT_SYMBOL(osd_req_op_cls_request_data_pages);
>  
>  void osd_req_op_cls_request_data_bvecs(struct ceph_osd_request *osd_req,
>  				       unsigned int which,
> -				       struct bio_vec *bvecs, u32 bytes)
> +				       struct bio_vec *bvecs, u32 num_bvecs,
> +				       u32 bytes)
>  {
>  	struct ceph_osd_data *osd_data;
>  	struct ceph_bvec_iter it = {
> @@ -296,7 +315,7 @@ void osd_req_op_cls_request_data_bvecs(struct ceph_osd_request *osd_req,
>  	};
>  
>  	osd_data = osd_req_op_data(osd_req, which, cls, request_data);
> -	ceph_osd_data_bvecs_init(osd_data, &it);
> +	ceph_osd_data_bvecs_init(osd_data, &it, num_bvecs);
>  	osd_req->r_ops[which].cls.indata_len += bytes;
>  	osd_req->r_ops[which].indata_len += bytes;
>  }

Looks good otherwise.

Reviewed-by: Jeff Layton <jlayton@redhat.com>
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ilya Dryomov May 4, 2018, 4:53 p.m. UTC | #2
On Fri, May 4, 2018 at 5:54 PM, Jeff Layton <jlayton@redhat.com> wrote:
> On Fri, 2018-05-04 at 17:04 +0200, Ilya Dryomov wrote:
>> ... and store num_bvecs for client code's convenience.
>>
>> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
>> ---
>>  drivers/block/rbd.c             |  4 +++-
>>  include/linux/ceph/osd_client.h | 12 ++++++++++--
>>  net/ceph/osd_client.c           | 27 +++++++++++++++++++++++----
>>  3 files changed, 36 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
>> index 50b9d0f8ac0b..2b4e90d06822 100644
>> --- a/drivers/block/rbd.c
>> +++ b/drivers/block/rbd.c
>> @@ -2369,7 +2369,9 @@ static int rbd_obj_issue_copyup(struct rbd_obj_request *obj_req, u32 bytes)
>>               bytes = 0;
>>       }
>>       osd_req_op_cls_request_data_bvecs(obj_req->osd_req, 0,
>> -                                       obj_req->copyup_bvecs, bytes);
>> +                                       obj_req->copyup_bvecs,
>> +                                       obj_req->copyup_bvec_count,
>> +                                       bytes);
>>
>>       switch (obj_req->img_request->op_type) {
>>       case OBJ_OP_WRITE:
>> diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h
>> index ba3d8c262f8d..b73dd7ebe585 100644
>> --- a/include/linux/ceph/osd_client.h
>> +++ b/include/linux/ceph/osd_client.h
>> @@ -77,7 +77,10 @@ struct ceph_osd_data {
>>                       u32                     bio_length;
>>               };
>>  #endif /* CONFIG_BLOCK */
>> -             struct ceph_bvec_iter   bvec_pos;
>> +             struct {
>> +                     struct ceph_bvec_iter   bvec_pos;
>> +                     u32                     num_bvecs;
>> +             };
>
> Does the above struct add anything of value? Maybe just add a new
> num_bvecs member there?

Yes, that struct makes up a union member.

Thanks,

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

Patch

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 50b9d0f8ac0b..2b4e90d06822 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -2369,7 +2369,9 @@  static int rbd_obj_issue_copyup(struct rbd_obj_request *obj_req, u32 bytes)
 		bytes = 0;
 	}
 	osd_req_op_cls_request_data_bvecs(obj_req->osd_req, 0,
-					  obj_req->copyup_bvecs, bytes);
+					  obj_req->copyup_bvecs,
+					  obj_req->copyup_bvec_count,
+					  bytes);
 
 	switch (obj_req->img_request->op_type) {
 	case OBJ_OP_WRITE:
diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h
index ba3d8c262f8d..b73dd7ebe585 100644
--- a/include/linux/ceph/osd_client.h
+++ b/include/linux/ceph/osd_client.h
@@ -77,7 +77,10 @@  struct ceph_osd_data {
 			u32			bio_length;
 		};
 #endif /* CONFIG_BLOCK */
-		struct ceph_bvec_iter	bvec_pos;
+		struct {
+			struct ceph_bvec_iter	bvec_pos;
+			u32			num_bvecs;
+		};
 	};
 };
 
@@ -412,6 +415,10 @@  void osd_req_op_extent_osd_data_bio(struct ceph_osd_request *osd_req,
 				    struct ceph_bio_iter *bio_pos,
 				    u32 bio_length);
 #endif /* CONFIG_BLOCK */
+void osd_req_op_extent_osd_data_bvecs(struct ceph_osd_request *osd_req,
+				      unsigned int which,
+				      struct bio_vec *bvecs, u32 num_bvecs,
+				      u32 bytes);
 void osd_req_op_extent_osd_data_bvec_pos(struct ceph_osd_request *osd_req,
 					 unsigned int which,
 					 struct ceph_bvec_iter *bvec_pos);
@@ -426,7 +433,8 @@  extern void osd_req_op_cls_request_data_pages(struct ceph_osd_request *,
 					bool own_pages);
 void osd_req_op_cls_request_data_bvecs(struct ceph_osd_request *osd_req,
 				       unsigned int which,
-				       struct bio_vec *bvecs, u32 bytes);
+				       struct bio_vec *bvecs, u32 num_bvecs,
+				       u32 bytes);
 extern void osd_req_op_cls_response_data_pages(struct ceph_osd_request *,
 					unsigned int which,
 					struct page **pages, u64 length,
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index a2e2c366e063..08b5fc1f90cc 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -157,10 +157,12 @@  static void ceph_osd_data_bio_init(struct ceph_osd_data *osd_data,
 #endif /* CONFIG_BLOCK */
 
 static void ceph_osd_data_bvecs_init(struct ceph_osd_data *osd_data,
-				     struct ceph_bvec_iter *bvec_pos)
+				     struct ceph_bvec_iter *bvec_pos,
+				     u32 num_bvecs)
 {
 	osd_data->type = CEPH_OSD_DATA_TYPE_BVECS;
 	osd_data->bvec_pos = *bvec_pos;
+	osd_data->num_bvecs = num_bvecs;
 }
 
 #define osd_req_op_data(oreq, whch, typ, fld)				\
@@ -237,6 +239,22 @@  void osd_req_op_extent_osd_data_bio(struct ceph_osd_request *osd_req,
 EXPORT_SYMBOL(osd_req_op_extent_osd_data_bio);
 #endif /* CONFIG_BLOCK */
 
+void osd_req_op_extent_osd_data_bvecs(struct ceph_osd_request *osd_req,
+				      unsigned int which,
+				      struct bio_vec *bvecs, u32 num_bvecs,
+				      u32 bytes)
+{
+	struct ceph_osd_data *osd_data;
+	struct ceph_bvec_iter it = {
+		.bvecs = bvecs,
+		.iter = { .bi_size = bytes },
+	};
+
+	osd_data = osd_req_op_data(osd_req, which, extent, osd_data);
+	ceph_osd_data_bvecs_init(osd_data, &it, num_bvecs);
+}
+EXPORT_SYMBOL(osd_req_op_extent_osd_data_bvecs);
+
 void osd_req_op_extent_osd_data_bvec_pos(struct ceph_osd_request *osd_req,
 					 unsigned int which,
 					 struct ceph_bvec_iter *bvec_pos)
@@ -244,7 +262,7 @@  void osd_req_op_extent_osd_data_bvec_pos(struct ceph_osd_request *osd_req,
 	struct ceph_osd_data *osd_data;
 
 	osd_data = osd_req_op_data(osd_req, which, extent, osd_data);
-	ceph_osd_data_bvecs_init(osd_data, bvec_pos);
+	ceph_osd_data_bvecs_init(osd_data, bvec_pos, 0);
 }
 EXPORT_SYMBOL(osd_req_op_extent_osd_data_bvec_pos);
 
@@ -287,7 +305,8 @@  EXPORT_SYMBOL(osd_req_op_cls_request_data_pages);
 
 void osd_req_op_cls_request_data_bvecs(struct ceph_osd_request *osd_req,
 				       unsigned int which,
-				       struct bio_vec *bvecs, u32 bytes)
+				       struct bio_vec *bvecs, u32 num_bvecs,
+				       u32 bytes)
 {
 	struct ceph_osd_data *osd_data;
 	struct ceph_bvec_iter it = {
@@ -296,7 +315,7 @@  void osd_req_op_cls_request_data_bvecs(struct ceph_osd_request *osd_req,
 	};
 
 	osd_data = osd_req_op_data(osd_req, which, cls, request_data);
-	ceph_osd_data_bvecs_init(osd_data, &it);
+	ceph_osd_data_bvecs_init(osd_data, &it, num_bvecs);
 	osd_req->r_ops[which].cls.indata_len += bytes;
 	osd_req->r_ops[which].indata_len += bytes;
 }