mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 12:57:53 +00:00
bio-integrity: create multi-page bvecs in bio_integrity_add_page()
[ Upstream commit0ece1d649b
] 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:783b94bd92
("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
618bd48d0f
commit
14a1b55482
1 changed files with 24 additions and 7 deletions
|
@ -123,17 +123,34 @@ void bio_integrity_free(struct bio *bio)
|
||||||
int bio_integrity_add_page(struct bio *bio, struct page *page,
|
int bio_integrity_add_page(struct bio *bio, struct page *page,
|
||||||
unsigned int len, unsigned int offset)
|
unsigned int len, unsigned int offset)
|
||||||
{
|
{
|
||||||
|
struct request_queue *q = bdev_get_queue(bio->bi_bdev);
|
||||||
struct bio_integrity_payload *bip = bio_integrity(bio);
|
struct bio_integrity_payload *bip = bio_integrity(bio);
|
||||||
|
|
||||||
if (bip->bip_vcnt >= bip->bip_max_vcnt) {
|
if (((bip->bip_iter.bi_size + len) >> SECTOR_SHIFT) >
|
||||||
printk(KERN_ERR "%s: bip_vec full\n", __func__);
|
queue_max_hw_sectors(q))
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
if (bip->bip_vcnt &&
|
if (bip->bip_vcnt > 0) {
|
||||||
bvec_gap_to_prev(&bdev_get_queue(bio->bi_bdev)->limits,
|
struct bio_vec *bv = &bip->bip_vec[bip->bip_vcnt - 1];
|
||||||
&bip->bip_vec[bip->bip_vcnt - 1], offset))
|
bool same_page = false;
|
||||||
return 0;
|
|
||||||
|
if (bvec_try_merge_hw_page(q, bv, page, len, offset,
|
||||||
|
&same_page)) {
|
||||||
|
bip->bip_iter.bi_size += len;
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bip->bip_vcnt >=
|
||||||
|
min(bip->bip_max_vcnt, queue_max_integrity_segments(q)))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the queue doesn't support SG gaps and adding this segment
|
||||||
|
* would create a gap, disallow it.
|
||||||
|
*/
|
||||||
|
if (bvec_gap_to_prev(&q->limits, bv, offset))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
bvec_set_page(&bip->bip_vec[bip->bip_vcnt], page, len, offset);
|
bvec_set_page(&bip->bip_vec[bip->bip_vcnt], page, len, offset);
|
||||||
bip->bip_vcnt++;
|
bip->bip_vcnt++;
|
||||||
|
|
Loading…
Reference in a new issue