diff mbox series

[3/5] block: move the call to get_max_io_size out of blk_bio_segment_split

Message ID 20220720142456.1414262-4-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [1/5] block: move ->bio_split to the gendisk | expand

Commit Message

Christoph Hellwig July 20, 2022, 2:24 p.m. UTC
Prepare for reusing blk_bio_segment_split for (file system controlled)
splits of REQ_OP_ZONE_APPEND bios by letting the caller control the
maximum size of the bio.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-merge.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Damien Le Moal July 22, 2022, 6:09 a.m. UTC | #1
On 7/20/22 23:24, Christoph Hellwig wrote:
> Prepare for reusing blk_bio_segment_split for (file system controlled)
> splits of REQ_OP_ZONE_APPEND bios by letting the caller control the
> maximum size of the bio.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks good. Though I think this patch could wait for the actual users of
this change.

Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>

> ---
>  block/blk-merge.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/block/blk-merge.c b/block/blk-merge.c
> index e657f1dc824cb..1676a835b16e7 100644
> --- a/block/blk-merge.c
> +++ b/block/blk-merge.c
> @@ -252,11 +252,12 @@ static bool bvec_split_segs(const struct request_queue *q,
>   * @bio:  [in] bio to be split
>   * @bs:	  [in] bio set to allocate the clone from
>   * @segs: [out] number of segments in the bio with the first half of the sectors
> + * @max_bytes: [in] maximum number of bytes per bio
>   *
>   * Clone @bio, update the bi_iter of the clone to represent the first sectors
>   * of @bio and update @bio->bi_iter to represent the remaining sectors. The
>   * following is guaranteed for the cloned bio:
> - * - That it has at most get_max_io_size(@q, @bio) sectors.
> + * - That it has at most @max_bytes worth of data
>   * - That it has at most queue_max_segments(@q) segments.
>   *
>   * Except for discard requests the cloned bio will point at the bi_io_vec of
> @@ -266,14 +267,12 @@ static bool bvec_split_segs(const struct request_queue *q,
>   * split bio has finished.
>   */
>  static struct bio *blk_bio_segment_split(struct request_queue *q,
> -					 struct bio *bio,
> -					 struct bio_set *bs,
> -					 unsigned *segs)
> +		struct bio *bio, struct bio_set *bs, unsigned *segs,
> +		unsigned max_bytes)
>  {
>  	struct bio_vec bv, bvprv, *bvprvp = NULL;
>  	struct bvec_iter iter;
>  	unsigned nsegs = 0, bytes = 0;
> -	const unsigned max_bytes = get_max_io_size(q, bio) << 9;
>  	const unsigned max_segs = queue_max_segments(q);
>  
>  	bio_for_each_bvec(bv, bio, iter) {
> @@ -347,7 +346,8 @@ void __blk_queue_split(struct request_queue *q, struct bio **bio,
>  		split = blk_bio_write_zeroes_split(q, *bio, bs, nr_segs);
>  		break;
>  	default:
> -		split = blk_bio_segment_split(q, *bio, bs, nr_segs);
> +		split = blk_bio_segment_split(q, *bio, bs, nr_segs,
> +				get_max_io_size(q, *bio) << SECTOR_SHIFT);
>  		break;
>  	}
>
Christoph Hellwig July 22, 2022, 6:11 a.m. UTC | #2
On Fri, Jul 22, 2022 at 03:09:57PM +0900, Damien Le Moal wrote:
> On 7/20/22 23:24, Christoph Hellwig wrote:
> > Prepare for reusing blk_bio_segment_split for (file system controlled)
> > splits of REQ_OP_ZONE_APPEND bios by letting the caller control the
> > maximum size of the bio.
> > 
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> Looks good. Though I think this patch could wait for the actual users of
> this change.

I don't think passing an additional argument is in any way harmful
even now, and I'd like to reduce the cross-tree dependencies for
the next cycle.  With this series in I just need to an an export
in the btrfs series, which would be great.
Damien Le Moal July 22, 2022, 6:12 a.m. UTC | #3
On 7/22/22 15:11, Christoph Hellwig wrote:
> On Fri, Jul 22, 2022 at 03:09:57PM +0900, Damien Le Moal wrote:
>> On 7/20/22 23:24, Christoph Hellwig wrote:
>>> Prepare for reusing blk_bio_segment_split for (file system controlled)
>>> splits of REQ_OP_ZONE_APPEND bios by letting the caller control the
>>> maximum size of the bio.
>>>
>>> Signed-off-by: Christoph Hellwig <hch@lst.de>
>>
>> Looks good. Though I think this patch could wait for the actual users of
>> this change.
> 
> I don't think passing an additional argument is in any way harmful
> even now, and I'd like to reduce the cross-tree dependencies for
> the next cycle.  With this series in I just need to an an export
> in the btrfs series, which would be great.

Works for me !
diff mbox series

Patch

diff --git a/block/blk-merge.c b/block/blk-merge.c
index e657f1dc824cb..1676a835b16e7 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -252,11 +252,12 @@  static bool bvec_split_segs(const struct request_queue *q,
  * @bio:  [in] bio to be split
  * @bs:	  [in] bio set to allocate the clone from
  * @segs: [out] number of segments in the bio with the first half of the sectors
+ * @max_bytes: [in] maximum number of bytes per bio
  *
  * Clone @bio, update the bi_iter of the clone to represent the first sectors
  * of @bio and update @bio->bi_iter to represent the remaining sectors. The
  * following is guaranteed for the cloned bio:
- * - That it has at most get_max_io_size(@q, @bio) sectors.
+ * - That it has at most @max_bytes worth of data
  * - That it has at most queue_max_segments(@q) segments.
  *
  * Except for discard requests the cloned bio will point at the bi_io_vec of
@@ -266,14 +267,12 @@  static bool bvec_split_segs(const struct request_queue *q,
  * split bio has finished.
  */
 static struct bio *blk_bio_segment_split(struct request_queue *q,
-					 struct bio *bio,
-					 struct bio_set *bs,
-					 unsigned *segs)
+		struct bio *bio, struct bio_set *bs, unsigned *segs,
+		unsigned max_bytes)
 {
 	struct bio_vec bv, bvprv, *bvprvp = NULL;
 	struct bvec_iter iter;
 	unsigned nsegs = 0, bytes = 0;
-	const unsigned max_bytes = get_max_io_size(q, bio) << 9;
 	const unsigned max_segs = queue_max_segments(q);
 
 	bio_for_each_bvec(bv, bio, iter) {
@@ -347,7 +346,8 @@  void __blk_queue_split(struct request_queue *q, struct bio **bio,
 		split = blk_bio_write_zeroes_split(q, *bio, bs, nr_segs);
 		break;
 	default:
-		split = blk_bio_segment_split(q, *bio, bs, nr_segs);
+		split = blk_bio_segment_split(q, *bio, bs, nr_segs,
+				get_max_io_size(q, *bio) << SECTOR_SHIFT);
 		break;
 	}