Re: [PATCH 01/17] block: export bio_split_rw

Qu Wenruo
2022-09-05T06:51:48Z

On 2022/9/5 14:44, Christoph Hellwig wrote:
> On Thu, Sep 01, 2022 at 04:54:32PM +0800, Qu Wenruo wrote:
>> I found the queue_limits structure pretty scary, while we only have very
>> limited members used in this case:
>>
>> - lim->virt_boundary_mask
>> Used in bvec_gap_to_prev()
>>
>> - lim->max_segments
>>
>> - lim->seg_boundary_mask
>> - lim->max_segment_size
>> Used in bvec_split_segs()
>>
>> - lim->logical_block_size
>>
>> Not familiar with block layer, thus I'm wondering do btrfs really need a
>> full queue_limits structure to call bio_split_rw().
>
> Well, the queue limits is what the block layer uses for communicating
> the I/O size limitations, and thus both bio_split_rw and the stacking
> layer helpers operate on it.
>
>> Or can we have a simplified wrapper?
>
> I don't think we can simplify anything here. The alternative would
> be to open code the I/O path logic, which means a lot more code that
> needs to be maintained and has a high probability to get out of sync
> with the block layer logic. So I'd much rather share this code
> between everything that stacks block devices, be that to represent
> another block device on the top like dm/md or for a 'direct' stacking
> in the file system like btrfs does.
>
>> IIRC inside btrfs we only need two cases for bio split:
>>
>> - Split for stripe boundary
>>
>> - Split for OE/zoned boundary
>
> No. For zoned devices we all limitations for bio, basically all that
> you mentioned above.

OK, that explains the reason for the full queue_limits exported.

Then it makes sense to me now.

Thanks,
Qu