From nobody Tue Apr 28 05:05:49 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 291E0CCA481 for ; Mon, 6 Jun 2022 15:03:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240286AbiFFPDT (ORCPT ); Mon, 6 Jun 2022 11:03:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240257AbiFFPDP (ORCPT ); Mon, 6 Jun 2022 11:03:15 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C254C194BFB for ; Mon, 6 Jun 2022 08:03:14 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id t2so12319496pld.4 for ; Mon, 06 Jun 2022 08:03:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wfh9GMNAtQ8X7OUdTqnBOAOW/iUKoStIjgn9vMh3x8A=; b=LaLT54OgNexxdzg/yLo+8HWrcnL5T3ORpjIOiHtIXU2JyIhOTdsGH+E15HjVrNeXQd /tSuP/hsZnGDYXMxqh3LOfmj2UIsf+95G6/X4WIBAAXMU4Oqy0mJzzinjNrg1YiDVsxp mJzADlX1yQqXsd9ypgmarYUEXLEkXxxB47+u0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wfh9GMNAtQ8X7OUdTqnBOAOW/iUKoStIjgn9vMh3x8A=; b=8JaKgbkR8EYqUwH2aqxx2AXhqy/w++IE2BYGQAbrLgvvUvkGcnubYdnVxMe1S2nSQz BIoxEatbr4d+xNuYOjDfWkJFKr4nEmWVM6+sY/5tTI04zWSlATcWhaJdsabep37p8Slb wTD1bCm+dzjci/z8VhQN1LHigItOc43UWRD/X5pJ0VGNJbauRYYepKSvRfTiCE5MQs7L U4j77twXrs6PuUY6TlnfXIdhj31co0DvPeIsiqt7LAqC+9+qIKxmjgUCxftVno8+f11M 3zybblSCEkCPk4/N/0WOS9uqlWhMvpTToTHrwm7AYOl5rxdBJjtg59QAE9nNZQTPhd/h ztcg== X-Gm-Message-State: AOAM530xnQJfL9y97j4d47u4oNZdVaxTjSQ0pORM+p93T8zVpsQJluLT Aj5m7QUfgCgODfyCl5u0t9CAepZfPup+lg== X-Google-Smtp-Source: ABdhPJxdTTxiaTKy/Feszuj1SsDP1FIjhPd7kiMqbWGTUZqv/v0u2v6oRGzVVWwnaSvf/uwM6Y6RRg== X-Received: by 2002:a17:902:cec8:b0:163:e4c1:b302 with SMTP id d8-20020a170902cec800b00163e4c1b302mr24732302plg.123.1654527794024; Mon, 06 Jun 2022 08:03:14 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:a0a:5e4:e24:c8c4]) by smtp.gmail.com with ESMTPSA id k13-20020aa7998d000000b0050dc76281ecsm7468864pfh.198.2022.06.06.08.03.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 08:03:13 -0700 (PDT) From: Hsin-Yi Wang To: Phillip Lougher , Matthew Wilcox , Xiongwei Song , Marek Szyprowski , Andrew Morton Cc: Zheng Liang , Zhang Yi , Hou Tao , Miao Xie , "linux-mm @ kvack . org" , "squashfs-devel @ lists . sourceforge . net" , linux-kernel@vger.kernel.org Subject: [PATCH v5 1/3] Revert "squashfs: provide backing_dev_info in order to disable read-ahead" Date: Mon, 6 Jun 2022 23:03:03 +0800 Message-Id: <20220606150305.1883410-2-hsinyi@chromium.org> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220606150305.1883410-1-hsinyi@chromium.org> References: <20220606150305.1883410-1-hsinyi@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This reverts commit 9eec1d897139e5de287af5d559a02b811b844d82. Revert closing the readahead to squashfs since the readahead callback for squashfs is implemented. Suggested-by: Xiongwei Song Signed-off-by: Hsin-Yi Wang --- fs/squashfs/super.c | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c index 6d594ba2ed28..32565dafa7f3 100644 --- a/fs/squashfs/super.c +++ b/fs/squashfs/super.c @@ -29,7 +29,6 @@ #include #include #include -#include =20 #include "squashfs_fs.h" #include "squashfs_fs_sb.h" @@ -113,24 +112,6 @@ static const struct squashfs_decompressor *supported_s= quashfs_filesystem( return decompressor; } =20 -static int squashfs_bdi_init(struct super_block *sb) -{ - int err; - unsigned int major =3D MAJOR(sb->s_dev); - unsigned int minor =3D MINOR(sb->s_dev); - - bdi_put(sb->s_bdi); - sb->s_bdi =3D &noop_backing_dev_info; - - err =3D super_setup_bdi_name(sb, "squashfs_%u_%u", major, minor); - if (err) - return err; - - sb->s_bdi->ra_pages =3D 0; - sb->s_bdi->io_pages =3D 0; - - return 0; -} =20 static int squashfs_fill_super(struct super_block *sb, struct fs_context *= fc) { @@ -146,20 +127,6 @@ static int squashfs_fill_super(struct super_block *sb,= struct fs_context *fc) =20 TRACE("Entered squashfs_fill_superblock\n"); =20 - /* - * squashfs provides 'backing_dev_info' in order to disable read-ahead. F= or - * squashfs, I/O is not deferred, it is done immediately in read_folio, - * which means the user would always have to wait their own I/O. So the e= ffect - * of readahead is very weak for squashfs. squashfs_bdi_init will set - * sb->s_bdi->ra_pages and sb->s_bdi->io_pages to 0 and close readahead f= or - * squashfs. - */ - err =3D squashfs_bdi_init(sb); - if (err) { - errorf(fc, "squashfs init bdi failed"); - return err; - } - sb->s_fs_info =3D kzalloc(sizeof(*msblk), GFP_KERNEL); if (sb->s_fs_info =3D=3D NULL) { ERROR("Failed to allocate squashfs_sb_info\n"); --=20 2.36.1.255.ge46751e96f-goog From nobody Tue Apr 28 05:05:49 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF9B8C43334 for ; Mon, 6 Jun 2022 15:03:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240283AbiFFPDX (ORCPT ); Mon, 6 Jun 2022 11:03:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240276AbiFFPDT (ORCPT ); Mon, 6 Jun 2022 11:03:19 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8EC61A43D0 for ; Mon, 6 Jun 2022 08:03:17 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id p8so12922104pfh.8 for ; Mon, 06 Jun 2022 08:03:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pVK/jozl1uAfEzK6vleMbKcySwChksKYsG5Iw08IS/c=; b=Oxd/anO5WtkVJUJUgToYwFGiGcM0uJJsObud5uRjsZD734hCJCXzwYzEeQISgp71My 3mGUbBcR7ZEpbzr4bYMhTomrpQoIarU3oHkHDIAQXTYdIneSuMqhogsSNW8tD2KxwBd8 V472zawpFjB3cIohTPsvNj9VlZyY94WZGKSYU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pVK/jozl1uAfEzK6vleMbKcySwChksKYsG5Iw08IS/c=; b=lhMfRjvRwDELU1zCeQi/Bu/m0AvhVidXo48HS8B1cnmUFbzDcYqb65ZRm1J1w2uRIp rQLyghJh8fWFYKT293y5+Kqd0PsA/vl7hYam5i10TAvsPCcJ05JKjPfmW2f0hRS/hPsg XtdRwGYzXSThDDdwfAR6oQOMvGpAzGCg1i5GlAiAx+WzEUTYLujieHemXKZNdYNXbAJz 4MAO3rMvzE/GsG0jDwe+vTRAqeOC58dtYKE8RawvGk/bywXQ2JNQeHj72nKyioLazu/+ 4V4ip9/Tueg/WeES3oSBQexhkpezJR0qI9MI/RQzgx1HjJyFhrZCisHYCLJ72HHtLsCJ xwvQ== X-Gm-Message-State: AOAM533kSzFxWplTCfU5b13pLa2q4HF+yjYUcGw5ll2ZrQdXoSqzzSAR 8tqc25esCWndC+0I0oMuDQnUNw== X-Google-Smtp-Source: ABdhPJzSAIABYaN16VMQB1hldKycOjrImKiWwTvNsL3jcjjJ0ONvT8gnKk77CzvvBg2ZGDkPEC9TGw== X-Received: by 2002:a63:fa15:0:b0:3fd:9170:9496 with SMTP id y21-20020a63fa15000000b003fd91709496mr7945484pgh.162.1654527796764; Mon, 06 Jun 2022 08:03:16 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:a0a:5e4:e24:c8c4]) by smtp.gmail.com with ESMTPSA id k13-20020aa7998d000000b0050dc76281ecsm7468864pfh.198.2022.06.06.08.03.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 08:03:16 -0700 (PDT) From: Hsin-Yi Wang To: Phillip Lougher , Matthew Wilcox , Xiongwei Song , Marek Szyprowski , Andrew Morton Cc: Zheng Liang , Zhang Yi , Hou Tao , Miao Xie , "linux-mm @ kvack . org" , "squashfs-devel @ lists . sourceforge . net" , linux-kernel@vger.kernel.org Subject: [PATCH v5 2/3] squashfs: always build "file direct" version of page actor Date: Mon, 6 Jun 2022 23:03:04 +0800 Message-Id: <20220606150305.1883410-3-hsinyi@chromium.org> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220606150305.1883410-1-hsinyi@chromium.org> References: <20220606150305.1883410-1-hsinyi@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Phillip Lougher Squashfs_readahead uses the "file direct" version of the page actor, and so build it unconditionally. Reported-by: kernel test robot Signed-off-by: Phillip Lougher Signed-off-by: Hsin-Yi Wang --- fs/squashfs/Makefile | 4 ++-- fs/squashfs/page_actor.h | 41 ---------------------------------------- 2 files changed, 2 insertions(+), 43 deletions(-) diff --git a/fs/squashfs/Makefile b/fs/squashfs/Makefile index 7bd9b8b856d0..477c89a519ee 100644 --- a/fs/squashfs/Makefile +++ b/fs/squashfs/Makefile @@ -5,9 +5,9 @@ =20 obj-$(CONFIG_SQUASHFS) +=3D squashfs.o squashfs-y +=3D block.o cache.o dir.o export.o file.o fragment.o id.o inod= e.o -squashfs-y +=3D namei.o super.o symlink.o decompressor.o +squashfs-y +=3D namei.o super.o symlink.o decompressor.o page_actor.o squashfs-$(CONFIG_SQUASHFS_FILE_CACHE) +=3D file_cache.o -squashfs-$(CONFIG_SQUASHFS_FILE_DIRECT) +=3D file_direct.o page_actor.o +squashfs-$(CONFIG_SQUASHFS_FILE_DIRECT) +=3D file_direct.o squashfs-$(CONFIG_SQUASHFS_DECOMP_SINGLE) +=3D decompressor_single.o squashfs-$(CONFIG_SQUASHFS_DECOMP_MULTI) +=3D decompressor_multi.o squashfs-$(CONFIG_SQUASHFS_DECOMP_MULTI_PERCPU) +=3D decompressor_multi_pe= rcpu.o diff --git a/fs/squashfs/page_actor.h b/fs/squashfs/page_actor.h index 2e3073ace009..26e07373af8a 100644 --- a/fs/squashfs/page_actor.h +++ b/fs/squashfs/page_actor.h @@ -6,46 +6,6 @@ * Phillip Lougher */ =20 -#ifndef CONFIG_SQUASHFS_FILE_DIRECT -struct squashfs_page_actor { - void **page; - int pages; - int length; - int next_page; -}; - -static inline struct squashfs_page_actor *squashfs_page_actor_init(void **= page, - int pages, int length) -{ - struct squashfs_page_actor *actor =3D kmalloc(sizeof(*actor), GFP_KERNEL); - - if (actor =3D=3D NULL) - return NULL; - - actor->length =3D length ? : pages * PAGE_SIZE; - actor->page =3D page; - actor->pages =3D pages; - actor->next_page =3D 0; - return actor; -} - -static inline void *squashfs_first_page(struct squashfs_page_actor *actor) -{ - actor->next_page =3D 1; - return actor->page[0]; -} - -static inline void *squashfs_next_page(struct squashfs_page_actor *actor) -{ - return actor->next_page =3D=3D actor->pages ? NULL : - actor->page[actor->next_page++]; -} - -static inline void squashfs_finish_page(struct squashfs_page_actor *actor) -{ - /* empty */ -} -#else struct squashfs_page_actor { union { void **buffer; @@ -76,4 +36,3 @@ static inline void squashfs_finish_page(struct squashfs_p= age_actor *actor) actor->squashfs_finish_page(actor); } #endif -#endif --=20 2.36.1.255.ge46751e96f-goog From nobody Tue Apr 28 05:05:49 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAC63C43334 for ; Mon, 6 Jun 2022 15:03:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240258AbiFFPDd (ORCPT ); Mon, 6 Jun 2022 11:03:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240297AbiFFPDX (ORCPT ); Mon, 6 Jun 2022 11:03:23 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C076D1D08AD for ; Mon, 6 Jun 2022 08:03:20 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id k5-20020a17090a404500b001e8875e6242so2025625pjg.5 for ; Mon, 06 Jun 2022 08:03:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=78qlS0+VzMo9YnbPE8S51ZKOVHUk72X1BTb4Y0KDRy4=; b=em8v3f6IPRDCDduD4h0KpWCx4D9FyrCgpGffTuHZLi/MLHUDKn/o23wxP90AQnNC57 72ErI/a8d3rwXKMsRhqB0p5BXIFLsOIqF7HZcyj7OCogfV81tkggLBafj2kdyX6C0zuN SsVBcexcgsRUES6LchEm33Lkc1bT0v06qGr10= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=78qlS0+VzMo9YnbPE8S51ZKOVHUk72X1BTb4Y0KDRy4=; b=U5SzT75mMm4C2IPlriNDHQUHKW/R5SRfrBg6AWpJbarsDOWqHHnNMXOvlj40q/T3lc /wjsntgvV1yoNaQTuSgUmd7LKwd/3UVn5CcPjRc6lE2ZOvVxuPW2j4Zsnxa2ahqXwqoY YGVmvirTmJR4sr+FrzP+HjsuRsZJwwWGgkPmWkHs9wL5bTu6bha4kT6BUR4SUzIk2E0m JwC3toW3n6B/jL78glP1fDxxw8ZPUl0iXtUdmm9OwmZa/Sx1wwMqhEX9lTPQE/f/XwQI 6W0+TbUypUg5Tw0g0jizdRX4gV4SSEREvCdPn4spWe6NY7q/okKxRZRAmsE9K8c1hT8e 25Yg== X-Gm-Message-State: AOAM533vKTBHfJqGCjK2BgiZ1rYQkjtrRAFvXwxqNgfvQbNsivbaOplh CQLbvl2JwNjVPNt+TTx+aAxf+Q== X-Google-Smtp-Source: ABdhPJzBGeo49gx5Piq2s8WNtXs8Dv8AMd8JEeGehwBIELwlmnaoWhNZHOitb6G5zWU0YW52xIWhtA== X-Received: by 2002:a17:90b:38c8:b0:1e8:5202:f6d4 with SMTP id nn8-20020a17090b38c800b001e85202f6d4mr14524346pjb.149.1654527799750; Mon, 06 Jun 2022 08:03:19 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:a0a:5e4:e24:c8c4]) by smtp.gmail.com with ESMTPSA id k13-20020aa7998d000000b0050dc76281ecsm7468864pfh.198.2022.06.06.08.03.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 08:03:19 -0700 (PDT) From: Hsin-Yi Wang To: Phillip Lougher , Matthew Wilcox , Xiongwei Song , Marek Szyprowski , Andrew Morton Cc: Zheng Liang , Zhang Yi , Hou Tao , Miao Xie , "linux-mm @ kvack . org" , "squashfs-devel @ lists . sourceforge . net" , linux-kernel@vger.kernel.org Subject: [PATCH v5 3/3] squashfs: implement readahead Date: Mon, 6 Jun 2022 23:03:05 +0800 Message-Id: <20220606150305.1883410-4-hsinyi@chromium.org> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220606150305.1883410-1-hsinyi@chromium.org> References: <20220606150305.1883410-1-hsinyi@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Implement readahead callback for squashfs. It will read datablocks which cover pages in readahead request. For a few cases it will not mark page as uptodate, including: - file end is 0. - zero filled blocks. - current batch of pages isn't in the same datablock. - decompressor error. Otherwise pages will be marked as uptodate. The unhandled pages will be updated by readpage later. Suggested-by: Matthew Wilcox Signed-off-by: Hsin-Yi Wang Reported-by: Matthew Wilcox Reported-by: Phillip Lougher Reported-by: Xiongwei Song Reported-by: Marek Szyprowski Reported-by: Andrew Morton --- v4->v5: - Handle short file cases reported by Marek and Matthew. - Fix checkpatch error reported by Andrew. v4: https://lore.kernel.org/lkml/20220601103922.1338320-4-hsinyi@chromium.o= rg/ v3: https://lore.kernel.org/lkml/20220523065909.883444-4-hsinyi@chromium.or= g/ v2: https://lore.kernel.org/lkml/20220517082650.2005840-4-hsinyi@chromium.o= rg/ v1: https://lore.kernel.org/lkml/20220516105100.1412740-3-hsinyi@chromium.o= rg/ --- fs/squashfs/file.c | 124 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 123 insertions(+), 1 deletion(-) diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c index a8e495d8eb86..fbd096cd15f4 100644 --- a/fs/squashfs/file.c +++ b/fs/squashfs/file.c @@ -39,6 +39,7 @@ #include "squashfs_fs_sb.h" #include "squashfs_fs_i.h" #include "squashfs.h" +#include "page_actor.h" =20 /* * Locate cache slot in range [offset, index] for specified inode. If @@ -495,7 +496,128 @@ static int squashfs_read_folio(struct file *file, str= uct folio *folio) return 0; } =20 +static void squashfs_readahead(struct readahead_control *ractl) +{ + struct inode *inode =3D ractl->mapping->host; + struct squashfs_sb_info *msblk =3D inode->i_sb->s_fs_info; + size_t mask =3D (1UL << msblk->block_log) - 1; + unsigned short shift =3D msblk->block_log - PAGE_SHIFT; + loff_t start =3D readahead_pos(ractl) & ~mask; + size_t len =3D readahead_length(ractl) + readahead_pos(ractl) - start; + struct squashfs_page_actor *actor; + unsigned int nr_pages =3D 0; + struct page **pages; + int i, file_end =3D i_size_read(inode) >> msblk->block_log; + unsigned int max_pages =3D 1UL << shift; + + readahead_expand(ractl, start, (len | mask) + 1); + + if (file_end =3D=3D 0) + return; + + pages =3D kmalloc_array(max_pages, sizeof(void *), GFP_KERNEL); + if (!pages) + return; + + actor =3D squashfs_page_actor_init_special(pages, max_pages, 0); + if (!actor) + goto out; + + for (;;) { + pgoff_t index; + int res, bsize; + u64 block =3D 0; + unsigned int expected; + + nr_pages =3D __readahead_batch(ractl, pages, max_pages); + if (!nr_pages) + break; + + if (readahead_pos(ractl) >=3D i_size_read(inode)) + goto skip_pages; + + index =3D pages[0]->index >> shift; + if ((pages[nr_pages - 1]->index >> shift) !=3D index) + goto skip_pages; + + expected =3D index =3D=3D file_end ? + (i_size_read(inode) & (msblk->block_size - 1)) : + msblk->block_size; + + bsize =3D read_blocklist(inode, index, &block); + if (bsize =3D=3D 0) + goto skip_pages; + + if (nr_pages < max_pages) { + struct squashfs_cache_entry *buffer; + unsigned int block_mask =3D max_pages - 1; + int offset =3D pages[0]->index - (pages[0]->index & ~block_mask); + + buffer =3D squashfs_get_datablock(inode->i_sb, block, + bsize); + if (buffer->error) { + squashfs_cache_put(buffer); + goto skip_pages; + } + + expected -=3D offset * PAGE_SIZE; + for (i =3D 0; i < nr_pages && expected > 0; i++, + expected -=3D PAGE_SIZE, offset++) { + int avail =3D min_t(int, expected, PAGE_SIZE); + + squashfs_fill_page(pages[i], buffer, + offset * PAGE_SIZE, avail); + unlock_page(pages[i]); + } + + squashfs_cache_put(buffer); + continue; + } + + res =3D squashfs_read_data(inode->i_sb, block, bsize, NULL, + actor); + + if (res =3D=3D expected) { + int bytes; + + /* Last page may have trailing bytes not filled */ + bytes =3D res % PAGE_SIZE; + if (bytes) { + void *pageaddr; + + pageaddr =3D kmap_atomic(pages[nr_pages - 1]); + memset(pageaddr + bytes, 0, PAGE_SIZE - bytes); + kunmap_atomic(pageaddr); + } + + for (i =3D 0; i < nr_pages; i++) { + flush_dcache_page(pages[i]); + SetPageUptodate(pages[i]); + } + } + + for (i =3D 0; i < nr_pages; i++) { + unlock_page(pages[i]); + put_page(pages[i]); + } + } + + kfree(actor); + kfree(pages); + return; + +skip_pages: + for (i =3D 0; i < nr_pages; i++) { + unlock_page(pages[i]); + put_page(pages[i]); + } + + kfree(actor); +out: + kfree(pages); +} =20 const struct address_space_operations squashfs_aops =3D { - .read_folio =3D squashfs_read_folio + .read_folio =3D squashfs_read_folio, + .readahead =3D squashfs_readahead }; --=20 2.36.1.255.ge46751e96f-goog