Re: [PATCH] block: fix splitting segments

Christoph Hellwig
2020-01-08T14:02:50Z

> +static inline unsigned get_max_segment_size(const struct request_queue *q,
> + const struct page *start_page,
> + unsigned long offset)
> {
> unsigned long mask = queue_segment_boundary(q);
>
> - /* default segment boundary mask means no boundary limit */
> - if (mask == BLK_SEG_BOUNDARY_MASK)
> - return queue_max_segment_size(q);
> -
> - return min_t(unsigned long, mask - (mask & offset) + 1,
> + offset = mask & (page_to_phys(start_page) + offset);

This looks weird and potentionaly incorrect - once you add the offset
to page_phys it really isn't an offset anymore and should be in a
variable named paddr or similar. And that needs to use a phys_addr_t
as we can have 32-bit architectures that use 64-bit physical addresses.

I'd also pass in the actual phys_addr_t instead of the page and offset.