[PATCH] block: fix adding folio to bio

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>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' & 'offset' so that 'offset' can be stored
in 'unsigned int'.

Fixes: ed9832bc08db ("block: introduce folio awareness and add a bigger size from folio")
Cc: Kundan Kumar <kundan.kumar@xxxxxxxxxxx>
Cc: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
Cc: Christoph Hellwig <hch@xxxxxx>
Cc: Luis Chamberlain <mcgrof@xxxxxxxxxx>
Cc: Gavin Shan <gshan@xxxxxxxxxx>
Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx>
---
 block/bio.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index f0c416e5931d..dd61d783717f 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1026,9 +1026,17 @@ EXPORT_SYMBOL(bio_add_page);
 void bio_add_folio_nofail(struct bio *bio, struct folio *folio, size_t len,
 			  size_t off)
 {
+	struct page *page = &folio->page;
+
 	WARN_ON_ONCE(len > UINT_MAX);
-	WARN_ON_ONCE(off > UINT_MAX);
-	__bio_add_page(bio, &folio->page, len, off);
+	if (unlikely(off > UINT_MAX)) {
+		unsigned long nr = off / PAGE_SIZE;
+
+		page = folio_page(folio, nr);
+		off -= nr * PAGE_SIZE;
+	}
+
+	__bio_add_page(bio, page, len, off);
 }
 EXPORT_SYMBOL_GPL(bio_add_folio_nofail);
 
-- 
2.47.1





[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux