Skip to content

Commit 0c60158

Browse files
Ming Leigregkh
authored andcommitted
block: fix adding folio to bio
commit 26064d3 upstream. >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]> [ The follow-up fix fbecd73 ("xfs: fix zoned GC data corruption due to wrong bv_offset") addresses issues in the file fs/xfs/xfs_zone_gc.c. This file was first introduced in version v6.15-rc1. So don't backport the follow up fix to 6.12.y. ] Signed-off-by: Alva Lan <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 3c4fed9 commit 0c60158

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
@@ -1156,9 +1156,10 @@ EXPORT_SYMBOL(bio_add_page);
11561156
void bio_add_folio_nofail(struct bio *bio, struct folio *folio, size_t len,
11571157
size_t off)
11581158
{
1159+
unsigned long nr = off / PAGE_SIZE;
1160+
11591161
WARN_ON_ONCE(len > UINT_MAX);
1160-
WARN_ON_ONCE(off > UINT_MAX);
1161-
__bio_add_page(bio, &folio->page, len, off);
1162+
__bio_add_page(bio, folio_page(folio, nr), len, off % PAGE_SIZE);
11621163
}
11631164
EXPORT_SYMBOL_GPL(bio_add_folio_nofail);
11641165

@@ -1179,9 +1180,11 @@ EXPORT_SYMBOL_GPL(bio_add_folio_nofail);
11791180
bool bio_add_folio(struct bio *bio, struct folio *folio, size_t len,
11801181
size_t off)
11811182
{
1182-
if (len > UINT_MAX || off > UINT_MAX)
1183+
unsigned long nr = off / PAGE_SIZE;
1184+
1185+
if (len > UINT_MAX)
11831186
return false;
1184-
return bio_add_page(bio, &folio->page, len, off) > 0;
1187+
return bio_add_page(bio, folio_page(folio, nr), len, off % PAGE_SIZE) > 0;
11851188
}
11861189
EXPORT_SYMBOL(bio_add_folio);
11871190

0 commit comments

Comments
 (0)