Skip to content

Commit 5b11565

Browse files
author
Gavin Shan
committed
block: fix adding folio to bio
JIRA: https://issues.redhat.com/browse/RHEL-79410 >4GB folio is possible on some ARCHs, such as aarch64, 16GB hugepage is supported, then 'offset' of folio can't be held in 'unsigned int', cause warning in bio_add_folio_nofail() and IO failure. Fix it by adjusting 'page' & trimming 'offset' so that `->bi_offset` won't be overflow, and folio can be added to bio successfully. Fixes: ed9832b ("block: introduce folio awareness and add a bigger size from folio") Cc: Kundan Kumar <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Luis Chamberlain <[email protected]> Cc: Gavin Shan <[email protected]> Signed-off-by: Ming Lei <[email protected]> Reviewed-by: Matthew Wilcox (Oracle) <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]> (cherry picked from commit 26064d3) Signed-off-by: Gavin Shan <[email protected]>
1 parent ddd3653 commit 5b11565

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

block/bio.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,9 +1154,10 @@ EXPORT_SYMBOL(bio_add_page);
11541154
void bio_add_folio_nofail(struct bio *bio, struct folio *folio, size_t len,
11551155
size_t off)
11561156
{
1157+
unsigned long nr = off / PAGE_SIZE;
1158+
11571159
WARN_ON_ONCE(len > UINT_MAX);
1158-
WARN_ON_ONCE(off > UINT_MAX);
1159-
__bio_add_page(bio, &folio->page, len, off);
1160+
__bio_add_page(bio, folio_page(folio, nr), len, off % PAGE_SIZE);
11601161
}
11611162

11621163
/**
@@ -1176,9 +1177,11 @@ void bio_add_folio_nofail(struct bio *bio, struct folio *folio, size_t len,
11761177
bool bio_add_folio(struct bio *bio, struct folio *folio, size_t len,
11771178
size_t off)
11781179
{
1179-
if (len > UINT_MAX || off > UINT_MAX)
1180+
unsigned long nr = off / PAGE_SIZE;
1181+
1182+
if (len > UINT_MAX)
11801183
return false;
1181-
return bio_add_page(bio, &folio->page, len, off) > 0;
1184+
return bio_add_page(bio, folio_page(folio, nr), len, off % PAGE_SIZE) > 0;
11821185
}
11831186

11841187
void __bio_release_pages(struct bio *bio, bool mark_dirty)

0 commit comments

Comments
 (0)