Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1385773pxa; Sat, 15 Aug 2020 18:45:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAb7oq8YbMRv8Y5B13ID1ymTx/Hg6S3u2chcjMHKwWs7w5cYL5s7T/2hrnzLEBex5kguHt X-Received: by 2002:aa7:db59:: with SMTP id n25mr8785539edt.276.1597542345655; Sat, 15 Aug 2020 18:45:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597542345; cv=none; d=google.com; s=arc-20160816; b=TC41TM1s4qd+AwZIGEzNI4gKYSWR25UCqZM713cgGGW9z8XlHsGU1lgnuyxluS3Zi4 l9nB6sSRygtEhjfSyYqiQ9tAEV/tUwRv6dSaPHjO9z4ZmpizEhkegdQ9M0RkgLBjG5xH pLIHyEd6xhLq8AgmaXXlyPH5lW/uVv8KjQ5sWYWHMdJ4xIMNTMt39ovIGHUDldHDnFzL kvwevOdQsgbQdJAQe9DEmoGHsSesBFN8VQd6vGXxyOs05GFohkBD42q4dH/+n7RQ4w5T bs4Gt2rdIpuPEgFRxHQwiwkRja+hj8o5JzZ7dviW2xprhIF0MoIDVvrvTx9dtLkaNLqm oS6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=B8hFqGgi3bQZQ1euyS6ai4tboC53ELWJOXqJtr0acco=; b=vIaDRc1dWw/qoKoIfVFCmbZEjuVpuzgaEMP7nnHDw462weIGSaX4e8CbOgshdfVgSt lGiohyhAOrhKXEiNqx4IzDSf6wFFEKcGybLHBtalvn3GxKopSrvcJ7ceSeCErYhxE0R7 SBrD7Bv5cRbaoW619vgT1Yic4+rksPmG/T6od86vp32AsYDY4aPVmuVrRMBFVzvbMCFD BZwojwCnrL8jNykrvXNHdPM4uMoat4Ezy7nsliJCBGnJPl/xhxbVJn0w9LHK7bdgZmpo 4YgxaLCRXp+EQdtrRTEMGW2nQbtVHCe/eBs81yQI80CSrbox2gmJ5ZD1i8zpg31amS3Z QdFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=mRenq4I9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id si17si7776550ejb.599.2020.08.15.18.45.18; Sat, 15 Aug 2020 18:45:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=mRenq4I9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729256AbgHOVxv (ORCPT + 99 others); Sat, 15 Aug 2020 17:53:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729147AbgHOVwl (ORCPT ); Sat, 15 Aug 2020 17:52:41 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFFF7C0612F9 for ; Fri, 14 Aug 2020 21:30:45 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id m22so11967082eje.10 for ; Fri, 14 Aug 2020 21:30:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=B8hFqGgi3bQZQ1euyS6ai4tboC53ELWJOXqJtr0acco=; b=mRenq4I9snynCGp0vxFPiCVDkCCQNDXc/K6ZtcuZ9aYc14T6j4LfGTSL76W2C78FHj 9ysuvUOmUjiz6BohSrUl1ZFUa5eGXkcM17ajneBnN2GAa8tE/1JmVhYYV003u/+TTXlB 5PU+3MglxIYB4bcsy4marQapECsWL/JhzjQFTsjsiIjNr+2mM/fMS3fgTZ0kx87G81nr hjMVVfartF1/UQxG7+kBiDSLzNx3mQzTl7LQp/ThZ+EpXQwIC8ZZshUemWWPYxo9Lkph mqfWKo204vTbKUXYyDAOADh51HQQv8HQtHAqQewO+eDfKQ2tz7ztXDxJow4nwiBB2oN+ R57g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=B8hFqGgi3bQZQ1euyS6ai4tboC53ELWJOXqJtr0acco=; b=O8SQG5kR6ECG3wV96iy5N7dwt8pUtDnPKyB5bxHQqd8T1ztGXSkT9pts34pNJWMcPp +zhptZL/NbW3b+q2Ydl3LzZWzyEBcSiz2oss1lUSfrUFbBTAryY3alQUe78/8tWws7PY 7VIZ+odWOJdpDR0BQlyn8m23CaOigp1dUw3BlYhCP1jIypkGEkFpH8G0tIzyjFcG3wvW AnGxkiQcAIB2Irbwb8+ftY0DjXS9C94cEKMb5FwFfPYx/hWQJU492Uisv4yva0Q1XoK4 po5NcYga8VTj0ZRdaBJuqfqCPtZTTkSL8TLnR5Fu23FCILIQFopFPAL7X5MDgU3OQu/+ +Adg== X-Gm-Message-State: AOAM533YiC4/0CahWBpcLg8i6xk7BjuNU1StVkrZqf4DJEZfhtX5msDt 10x5bjgb1+ZpkSR/H52o1I3O52G+0I2ny851bK7Bgc1qG8x8+A== X-Received: by 2002:a17:907:41dc:: with SMTP id og20mr5670047ejb.183.1597465844100; Fri, 14 Aug 2020 21:30:44 -0700 (PDT) MIME-Version: 1.0 References: <20200815035637.15319-1-phillip@squashfs.org.uk> In-Reply-To: <20200815035637.15319-1-phillip@squashfs.org.uk> From: Guenter Roeck Date: Fri, 14 Aug 2020 21:30:33 -0700 Message-ID: Subject: Re: [PATCH] squashfs: avoid bio_alloc() failure with 1Mbyte blocks To: Phillip Lougher Cc: linux-kernel , Andrew Morton , Philippe Liard , hch@lst.de, adrien+dev@schischi.me, Guenter Roeck , Daniel Rosenberg , Nicolas Prochazka , Tomoatsu Shimada Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 14, 2020 at 8:57 PM Phillip Lougher wrote: > > 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 > Reported-by: Tomoatsu Shimada > Signed-off-by: Phillip Lougher Fixes: 93e72b3c612a ("squashfs: migrate from ll_rw_block usage to BIO") Reviewed-by: Guenter Roeck > --- > 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 >