Skip to content

Commit f26044c

Browse files
ploughertorvalds
authored andcommitted
squashfs: avoid bio_alloc() failure with 1Mbyte blocks
This is a regression introduced by the patch "migrate from ll_rw_block usage to BIO". Bio_alloc() is limited to 256 pages (1 Mbyte). This can cause a failure when reading 1 Mbyte block filesystems. The problem is a datablock can be fully (or almost uncompressed), requiring 256 pages, but, because blocks are not aligned to page boundaries, it may require 257 pages to read. Bio_kmalloc() can handle 1024 pages, and so use this for the edge condition. Fixes: 93e72b3 ("squashfs: migrate from ll_rw_block usage to BIO") Reported-by: Nicolas Prochazka <[email protected]> Reported-by: Tomoatsu Shimada <[email protected]> Signed-off-by: Phillip Lougher <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Cc: Philippe Liard <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Adrien Schildknecht <[email protected]> Cc: Daniel Rosenberg <[email protected]> Cc: <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent c17c3dc commit f26044c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

fs/squashfs/block.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ static int squashfs_bio_read(struct super_block *sb, u64 index, int length,
8787
int error, i;
8888
struct bio *bio;
8989

90-
bio = bio_alloc(GFP_NOIO, page_count);
90+
if (page_count <= BIO_MAX_PAGES)
91+
bio = bio_alloc(GFP_NOIO, page_count);
92+
else
93+
bio = bio_kmalloc(GFP_NOIO, page_count);
94+
9195
if (!bio)
9296
return -ENOMEM;
9397

0 commit comments

Comments
 (0)