Skip to content

Commit 7de9895

Browse files
Kundan Kumaraxboe
authored andcommitted
block: Added folio-ized version of bio_add_hw_page()
Added new bio_add_hw_folio() function as a wrapper around bio_add_hw_page(). This is a prep patch. Signed-off-by: Kundan Kumar <[email protected]> Tested-by: Luis Chamberlain <[email protected]> Reviewed-by: Matthew Wilcox (Oracle) <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent a7609d2 commit 7de9895

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

block/bio.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,29 @@ int bio_add_hw_page(struct request_queue *q, struct bio *bio,
10161016
return len;
10171017
}
10181018

1019+
/**
1020+
* bio_add_hw_folio - attempt to add a folio to a bio with hw constraints
1021+
* @q: the target queue
1022+
* @bio: destination bio
1023+
* @folio: folio to add
1024+
* @len: vec entry length
1025+
* @offset: vec entry offset in the folio
1026+
* @max_sectors: maximum number of sectors that can be added
1027+
* @same_page: return if the segment has been merged inside the same folio
1028+
*
1029+
* Add a folio to a bio while respecting the hardware max_sectors, max_segment
1030+
* and gap limitations.
1031+
*/
1032+
int bio_add_hw_folio(struct request_queue *q, struct bio *bio,
1033+
struct folio *folio, size_t len, size_t offset,
1034+
unsigned int max_sectors, bool *same_page)
1035+
{
1036+
if (len > UINT_MAX || offset > UINT_MAX)
1037+
return 0;
1038+
return bio_add_hw_page(q, bio, folio_page(folio, 0), len, offset,
1039+
max_sectors, same_page);
1040+
}
1041+
10191042
/**
10201043
* bio_add_pc_page - attempt to add page to passthrough bio
10211044
* @q: the target queue

block/blk.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,10 @@ int bio_add_hw_page(struct request_queue *q, struct bio *bio,
574574
struct page *page, unsigned int len, unsigned int offset,
575575
unsigned int max_sectors, bool *same_page);
576576

577+
int bio_add_hw_folio(struct request_queue *q, struct bio *bio,
578+
struct folio *folio, size_t len, size_t offset,
579+
unsigned int max_sectors, bool *same_page);
580+
577581
/*
578582
* Clean up a page appropriately, where the page may be pinned, may have a
579583
* ref taken on it or neither.

0 commit comments

Comments
 (0)