Skip to content

Commit 54db0b3

Browse files
committed
Merge: block: fix adding folio to bio
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/6649 JIRA: https://issues.redhat.com/browse/RHEL-79410 Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=67144184 Upstream Status: v6.15.rc1 Tested: Guest can boot with 16GB huge pages and none disk cache mode It's possible a folio's size exceeds 4GB. For example, 16GB huge page is available when the base page size is 64KB. In this case, the offset of a folio can't be held in a 'unsigned int' variable. Otherwise, it causes warning in bio_add_folio_nofail() and IO failure because of overflowing, and eventually leads to guest booting failure when the disk cache mode is none. Pick up upstream commit 26064d3 ("block: fix adding folio to bio") to fix the issue. Signed-off-by: Gavin Shan <[email protected]> Approved-by: Ming Lei <[email protected]> Approved-by: Jeff Moyer <[email protected]> Approved-by: CKI KWF Bot <[email protected]> Merged-by: Augusto Caringi <[email protected]>
2 parents 789d60b + 5b11565 commit 54db0b3

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
@@ -1026,9 +1026,10 @@ EXPORT_SYMBOL(bio_add_page);
10261026
void bio_add_folio_nofail(struct bio *bio, struct folio *folio, size_t len,
10271027
size_t off)
10281028
{
1029+
unsigned long nr = off / PAGE_SIZE;
1030+
10291031
WARN_ON_ONCE(len > UINT_MAX);
1030-
WARN_ON_ONCE(off > UINT_MAX);
1031-
__bio_add_page(bio, &folio->page, len, off);
1032+
__bio_add_page(bio, folio_page(folio, nr), len, off % PAGE_SIZE);
10321033
}
10331034

10341035
/**
@@ -1048,9 +1049,11 @@ void bio_add_folio_nofail(struct bio *bio, struct folio *folio, size_t len,
10481049
bool bio_add_folio(struct bio *bio, struct folio *folio, size_t len,
10491050
size_t off)
10501051
{
1051-
if (len > UINT_MAX || off > UINT_MAX)
1052+
unsigned long nr = off / PAGE_SIZE;
1053+
1054+
if (len > UINT_MAX)
10521055
return false;
1053-
return bio_add_page(bio, &folio->page, len, off) > 0;
1056+
return bio_add_page(bio, folio_page(folio, nr), len, off % PAGE_SIZE) > 0;
10541057
}
10551058

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

0 commit comments

Comments
 (0)