From: Phillip Lougher <phillip@squashfs.org.uk>
To: linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, pliard@google.com, hch@lst.de,
adrien+dev@schischi.me, groeck@chromium.org, drosen@google.com,
Phillip Lougher <phillip@squashfs.org.uk>,
Nicolas Prochazka <nicolas.prochazka@gmail.com>,
Tomoatsu Shimada <shimada@walbrix.com>
Subject: [PATCH] squashfs: avoid bio_alloc() failure with 1Mbyte blocks
Date: Sat, 15 Aug 2020 04:56:37 +0100
Message-ID: <20200815035637.15319-1-phillip@squashfs.org.uk> (raw)
This is a regression introduced by the "migrate from ll_rw_block usage
to BIO" patch.
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.
Reported-by: Nicolas Prochazka <nicolas.prochazka@gmail.com>
Reported-by: Tomoatsu Shimada <shimada@walbrix.com>
Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
---
fs/squashfs/block.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/fs/squashfs/block.c b/fs/squashfs/block.c
index 76bb1c846845..8a19773b5a0b 100644
--- a/fs/squashfs/block.c
+++ b/fs/squashfs/block.c
@@ -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;
--
2.20.1
next reply index
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-15 3:56 Phillip Lougher [this message]
2020-08-15 4:30 ` Guenter Roeck
2020-08-19 3:13 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200815035637.15319-1-phillip@squashfs.org.uk \
--to=phillip@squashfs.org.uk \
--cc=adrien+dev@schischi.me \
--cc=akpm@linux-foundation.org \
--cc=drosen@google.com \
--cc=groeck@chromium.org \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolas.prochazka@gmail.com \
--cc=pliard@google.com \
--cc=shimada@walbrix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
LKML Archive on lore.kernel.org
Archives are clonable:
git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git
git clone --mirror https://lore.kernel.org/lkml/9 lkml/git/9.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
linux-kernel@vger.kernel.org
public-inbox-index lkml
Example config snippet for mirrors
Newsgroup available over NNTP:
nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git