Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions block/bio-integrity.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ int bio_integrity_add_page(struct bio *bio, struct page *page,
if (bip->bip_vcnt > 0) {
struct bio_vec *bv = &bip->bip_vec[bip->bip_vcnt - 1];

if (!zone_device_pages_have_same_pgmap(bv->bv_page, page))
if (!zone_device_pages_compatible(bv->bv_page, page))
return 0;

if (bvec_try_merge_hw_page(q, bv, page, len, offset)) {
if (zone_device_pages_have_same_pgmap(bv->bv_page, page) &&
bvec_try_merge_hw_page(q, bv, page, len, offset)) {
bip->bip_iter.bi_size += len;
return len;
}
Expand Down
6 changes: 3 additions & 3 deletions block/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1070,10 +1070,10 @@ int bio_add_page(struct bio *bio, struct page *page,
if (bio->bi_vcnt > 0) {
struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt - 1];

if (!zone_device_pages_have_same_pgmap(bv->bv_page, page))
if (!zone_device_pages_compatible(bv->bv_page, page))
return 0;

if (bvec_try_merge_page(bv, page, len, offset)) {
if (zone_device_pages_have_same_pgmap(bv->bv_page, page) &&
bvec_try_merge_page(bv, page, len, offset)) {
bio->bi_iter.bi_size += len;
return len;
}
Expand Down
21 changes: 21 additions & 0 deletions block/blk.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,34 @@ static inline bool biovec_phys_mergeable(struct request_queue *q,

if (addr1 + vec1->bv_len != addr2)
return false;
if (!zone_device_pages_have_same_pgmap(vec1->bv_page, vec2->bv_page))
return false;
if (xen_domain() && !xen_biovec_phys_mergeable(vec1, vec2->bv_page))
return false;
if ((addr1 | mask) != ((addr2 + vec2->bv_len - 1) | mask))
return false;
return true;
}

/*
* Check if two pages from potentially different zone device pgmaps can
* coexist as separate bvec entries in the same bio.
*
* The block DMA iterator (blk_dma_map_iter_start) caches the P2PDMA mapping
* state from the first segment and applies it to all subsequent segments, so
* P2PDMA pages from different pgmaps must not be mixed in the same bio.
*
* Other zone device types (FS_DAX, GENERIC) use the same dma_map_phys() path
* as normal RAM. PRIVATE and COHERENT pages never appear in bios.
*/
static inline bool zone_device_pages_compatible(const struct page *a,
const struct page *b)
{
if (is_pci_p2pdma_page(a) || is_pci_p2pdma_page(b))
return zone_device_pages_have_same_pgmap(a, b);
return true;
}

static inline bool __bvec_gap_to_prev(const struct queue_limits *lim,
struct bio_vec *bprv, unsigned int offset)
{
Expand Down