On Thu, Jun 27, 2024 at 04:15:50PM +0530, Kundan Kumar wrote: > Added new bio_add_hw_folio() function. This is a prep patch. > > Signed-off-by: Kundan Kumar <kundan.kumar@xxxxxxxxxxx> > --- > block/bio.c | 33 ++++++++++++++++++++++++++++----- > block/blk.h | 4 ++++ > 2 files changed, 32 insertions(+), 5 deletions(-) > > diff --git a/block/bio.c b/block/bio.c > index e9e809a63c59..6c2db8317ae5 100644 > --- a/block/bio.c > +++ b/block/bio.c > @@ -979,6 +979,31 @@ bool bvec_try_merge_hw_page(struct request_queue *q, struct bio_vec *bv, > int bio_add_hw_page(struct request_queue *q, struct bio *bio, > struct page *page, unsigned int len, unsigned int offset, > unsigned int max_sectors, bool *same_page) > +{ > + struct folio *folio = page_folio(page); > + size_t folio_offset = (folio_page_idx(folio, page) << PAGE_SHIFT) + > + offset; Probably purely subjective, but I find this more readable: size_t folio_offset = (folio_page_idx(folio, page) << PAGE_SHIFT) + offset; > + return bio_add_hw_folio(q, bio, folio, len, folio_offset, max_sectors, > + same_page); ... or just open code it here: return bio_add_hw_folio(q, bio, folio, len, (folio_page_idx(folio, page) << PAGE_SHIFT) + offset, max_sectors, same_page); > + if (bvec_try_merge_hw_page(q, bv, folio_page(folio, 0), len, > + offset, same_page)) { Eventually bvec_try_merge_hw_page should be folio-ized as well. But we can do this separately if you don't want to take it on.