Skip to content

Commit

Permalink
squashfs: avoid bio_alloc() failure with 1Mbyte blocks
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
plougher authored and torvalds committed Aug 21, 2020
1 parent c17c3dc commit f26044c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fs/squashfs/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ static int squashfs_bio_read(struct super_block *sb, u64 index, int length,
int error, i;
struct bio *bio;

bio = bio_alloc(GFP_NOIO, page_count);
if (page_count <= BIO_MAX_PAGES)
bio = bio_alloc(GFP_NOIO, page_count);
else
bio = bio_kmalloc(GFP_NOIO, page_count);

if (!bio)
return -ENOMEM;

Expand Down

0 comments on commit f26044c

Please sign in to comment.