mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-30 22:03:17 +01:00
block: fix adding folio to bio
>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: ed9832bc08 ("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]>
This commit is contained in:
1 parent
61667cb664
commit
26064d3e2b
1 file changed
+7
-4
+7
-4
@@ -1026,9 +1026,10 @@ EXPORT_SYMBOL(bio_add_page);
|
||||
void bio_add_folio_nofail(struct bio *bio, struct folio *folio, size_t len,
|
||||
size_t off)
|
||||
{
|
||||
unsigned long nr = off / PAGE_SIZE;
|
||||
|
||||
WARN_ON_ONCE(len > UINT_MAX);
|
||||
WARN_ON_ONCE(off > UINT_MAX);
|
||||
__bio_add_page(bio, &folio->page, len, off);
|
||||
__bio_add_page(bio, folio_page(folio, nr), len, off % PAGE_SIZE);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(bio_add_folio_nofail);
|
||||
|
||||
@@ -1049,9 +1050,11 @@ EXPORT_SYMBOL_GPL(bio_add_folio_nofail);
|
||||
bool bio_add_folio(struct bio *bio, struct folio *folio, size_t len,
|
||||
size_t off)
|
||||
{
|
||||
if (len > UINT_MAX || off > UINT_MAX)
|
||||
unsigned long nr = off / PAGE_SIZE;
|
||||
|
||||
if (len > UINT_MAX)
|
||||
return false;
|
||||
return bio_add_page(bio, &folio->page, len, off) > 0;
|
||||
return bio_add_page(bio, folio_page(folio, nr), len, off % PAGE_SIZE) > 0;
|
||||
}
|
||||
EXPORT_SYMBOL(bio_add_folio);
|
||||
|
||||
|
||||
Reference in new issue
Block a user