Skip to content

Commit 0ece1d6

Browse files
ychoijyaxboe
authored andcommitted
bio-integrity: create multi-page bvecs in bio_integrity_add_page()
In general, the bvec data structure consists of one for physically continuous pages. But, in the bvec configuration for bip, physically continuous integrity pages are composed of each bvec. Allow bio_integrity_add_page() to create multi-page bvecs, just like the bio payloads. This simplifies adding larger payloads, and fixes support for non-tiny workloads with nvme, which stopped using scatterlist for metadata a while ago. Cc: Christoph Hellwig <hch@lst.de> Cc: Martin K. Petersen <martin.petersen@oracle.com> Fixes: 783b94b ("nvme-pci: do not build a scatterlist to map metadata") Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jinyoung Choi <j-young.choi@samsung.com> Tested-by: "Martin K. Petersen" <martin.petersen@oracle.com> Reviewed-by: "Martin K. Petersen" <martin.petersen@oracle.com> Link: https://lore.kernel.org/r/20230803025202epcms2p82f57cbfe32195da38c776377b55aed59@epcms2p8 Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent d1f04c2 commit 0ece1d6

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

block/bio-integrity.c

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,34 @@ void bio_integrity_free(struct bio *bio)
123123
int bio_integrity_add_page(struct bio *bio, struct page *page,
124124
unsigned int len, unsigned int offset)
125125
{
126+
struct request_queue *q = bdev_get_queue(bio->bi_bdev);
126127
struct bio_integrity_payload *bip = bio_integrity(bio);
127128

128-
if (bip->bip_vcnt >= bip->bip_max_vcnt) {
129-
printk(KERN_ERR "%s: bip_vec full\n", __func__);
129+
if (((bip->bip_iter.bi_size + len) >> SECTOR_SHIFT) >
130+
queue_max_hw_sectors(q))
130131
return 0;
131-
}
132132

133-
if (bip->bip_vcnt &&
134-
bvec_gap_to_prev(&bdev_get_queue(bio->bi_bdev)->limits,
135-
&bip->bip_vec[bip->bip_vcnt - 1], offset))
136-
return 0;
133+
if (bip->bip_vcnt > 0) {
134+
struct bio_vec *bv = &bip->bip_vec[bip->bip_vcnt - 1];
135+
bool same_page = false;
136+
137+
if (bvec_try_merge_hw_page(q, bv, page, len, offset,
138+
&same_page)) {
139+
bip->bip_iter.bi_size += len;
140+
return len;
141+
}
142+
143+
if (bip->bip_vcnt >=
144+
min(bip->bip_max_vcnt, queue_max_integrity_segments(q)))
145+
return 0;
146+
147+
/*
148+
* If the queue doesn't support SG gaps and adding this segment
149+
* would create a gap, disallow it.
150+
*/
151+
if (bvec_gap_to_prev(&q->limits, bv, offset))
152+
return 0;
153+
}
137154

138155
bvec_set_page(&bip->bip_vec[bip->bip_vcnt], page, len, offset);
139156
bip->bip_vcnt++;

0 commit comments

Comments
 (0)