Skip to content

Commit 2a1dab7

Browse files
Naman Jainkawasaki
authored andcommitted
block: add pgmap check to biovec_phys_mergeable
biovec_phys_mergeable() is used by the request merge, DMA mapping, and integrity merge paths to decide if two physically contiguous bvec segments can be coalesced into one. It currently has no check for whether the segments belong to different dev_pagemaps. When zone device memory is registered in multiple chunks, each chunk gets its own dev_pagemap. A single bio can legitimately contain bvecs from different pgmaps -- iov_iter_extract_bvecs() breaks at pgmap boundaries but the outer loop in bio_iov_iter_get_pages() continues filling the same bio. If such bvecs are physically contiguous, biovec_phys_mergeable() will coalesce them, making it impossible to recover the correct pgmap for the merged segment via page_pgmap(). Add a zone_device_pages_have_same_pgmap() check to prevent merging bvec segments that span different pgmaps. Fixes: 49580e6 ("block: add check when merging zone device pages") Cc: stable@vger.kernel.org Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Naman Jain <namjain@linux.microsoft.com>
1 parent 6b4d829 commit 2a1dab7

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

block/blk.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ static inline bool biovec_phys_mergeable(struct request_queue *q,
127127

128128
if (addr1 + vec1->bv_len != addr2)
129129
return false;
130+
if (!zone_device_pages_have_same_pgmap(vec1->bv_page, vec2->bv_page))
131+
return false;
130132
if (xen_domain() && !xen_biovec_phys_mergeable(vec1, vec2->bv_page))
131133
return false;
132134
if ((addr1 | mask) != ((addr2 + vec2->bv_len - 1) | mask))

0 commit comments

Comments
 (0)