From patchwork Wed Jun 1 10:39:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hsin-Yi Wang X-Patchwork-Id: 12866658 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D6E7C433F5 for ; Wed, 1 Jun 2022 10:39:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9961E6B00BA; Wed, 1 Jun 2022 06:39:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 96F9A8D0007; Wed, 1 Jun 2022 06:39:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 85CB98D0006; Wed, 1 Jun 2022 06:39:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 741326B00BA for ; Wed, 1 Jun 2022 06:39:43 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3DF0F206F0 for ; Wed, 1 Jun 2022 10:39:43 +0000 (UTC) X-FDA: 79529321046.18.90FE955 Received: from mail-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) by imf04.hostedemail.com (Postfix) with ESMTP id B349940064 for ; Wed, 1 Jun 2022 10:39:23 +0000 (UTC) Received: by mail-qv1-f42.google.com with SMTP id j2so1120405qvp.9 for ; Wed, 01 Jun 2022 03:39:42 -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=J4DFyJFooJ1/aFuihbbPDsZUg/rHDSDYYB/zizL1l+XlzXtXYJdHboF7hjsiktBIub UpUo4fe91c62KQ2wCh8Q+E45OrEt+KX8PYpsHsOkh2E9Aoh7GxZ5QNGR2Z1BR7K4Ed3k +5Tfy0rfFvGXQkPL4dqf8dbHmppQCXzaLme0Y= 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=fb+K0MCC+wDpArIxGawu3/aKxhKevEjbD31Rz0UBdO0Kfbm8ceJ+zZeI4/kpL6EHEo +E6Nc/Oo07I4TpbVC32LOCYihjvOjH84XAIv4AZSNfN/Bl3L5Q98KII7bMc6C0sXNek+ tsuZJ8wygy2wavk4s6SHEIX4Xq8NCXlwCgUKL1NIiveA2AWMj6BBCDr6sEliuQoKzpEx BV4MYPE5fbp5wFtzHmDFL5VIHe54fu+lz25Q7QiEMw7leicsKx4X2ghY5XtXioA4N3SR ZoCsl9r5vI9XbciCienx883noXNc+rJHzhxt4U0BihYZ9tM+tJTT47YUtI7YNcgzD4+B tPhA== X-Gm-Message-State: AOAM530kKy3g/v7c7+F5q6G5gwQVZkk2dyzWXKhC5lzvI3sJ3+QxmcYZ twydHvn6Ub7UXql+um1rykkfIZIH1bIcBg== X-Google-Smtp-Source: ABdhPJzGikxQY4QeEMbejEgnYu1+SViSz+uEqFU1v5hBzeBBzAFeuZfr9bzWJJED51l9pR4HX5nyZA== X-Received: by 2002:a17:902:9044:b0:15d:1c51:5bef with SMTP id w4-20020a170902904400b0015d1c515befmr65260044plz.170.1654079970845; Wed, 01 Jun 2022 03:39:30 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:dc30:e75c:ae95:f2d6]) by smtp.gmail.com with ESMTPSA id i9-20020a17090332c900b00163bfaf0b17sm1183867plr.233.2022.06.01.03.39.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 03:39:30 -0700 (PDT) From: Hsin-Yi Wang To: Phillip Lougher , Matthew Wilcox , Xiongwei Song Cc: Zheng Liang , Zhang Yi , Hou Tao , Miao Xie , Andrew Morton , "linux-mm @ kvack . org" , "squashfs-devel @ lists . sourceforge . net" , linux-kernel@vger.kernel.org Subject: [PATCH v4 1/3] Revert "squashfs: provide backing_dev_info in order to disable read-ahead" Date: Wed, 1 Jun 2022 18:39:20 +0800 Message-Id: <20220601103922.1338320-2-hsinyi@chromium.org> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220601103922.1338320-1-hsinyi@chromium.org> References: <20220601103922.1338320-1-hsinyi@chromium.org> MIME-Version: 1.0 X-Stat-Signature: bf5yjcr9tkxfo6yu1m3p9c53dh19poaa Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=J4DFyJFo; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf04.hostedemail.com: domain of hsinyi@chromium.org designates 209.85.219.42 as permitted sender) smtp.mailfrom=hsinyi@chromium.org X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: B349940064 X-HE-Tag: 1654079963-786006 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 #include "squashfs_fs.h" #include "squashfs_fs_sb.h" @@ -113,24 +112,6 @@ static const struct squashfs_decompressor *supported_squashfs_filesystem( return decompressor; } -static int squashfs_bdi_init(struct super_block *sb) -{ - int err; - unsigned int major = MAJOR(sb->s_dev); - unsigned int minor = MINOR(sb->s_dev); - - bdi_put(sb->s_bdi); - sb->s_bdi = &noop_backing_dev_info; - - err = super_setup_bdi_name(sb, "squashfs_%u_%u", major, minor); - if (err) - return err; - - sb->s_bdi->ra_pages = 0; - sb->s_bdi->io_pages = 0; - - return 0; -} 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) TRACE("Entered squashfs_fill_superblock\n"); - /* - * squashfs provides 'backing_dev_info' in order to disable read-ahead. For - * 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 effect - * 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 for - * squashfs. - */ - err = squashfs_bdi_init(sb); - if (err) { - errorf(fc, "squashfs init bdi failed"); - return err; - } - sb->s_fs_info = kzalloc(sizeof(*msblk), GFP_KERNEL); if (sb->s_fs_info == NULL) { ERROR("Failed to allocate squashfs_sb_info\n"); From patchwork Wed Jun 1 10:39:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hsin-Yi Wang X-Patchwork-Id: 12866656 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5234C433F5 for ; Wed, 1 Jun 2022 10:39:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 484916B00B8; Wed, 1 Jun 2022 06:39:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 457C76B00BA; Wed, 1 Jun 2022 06:39:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 31DFD6B00BB; Wed, 1 Jun 2022 06:39:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 1ED0C6B00B8 for ; Wed, 1 Jun 2022 06:39:35 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id E3A3F3476E for ; Wed, 1 Jun 2022 10:39:34 +0000 (UTC) X-FDA: 79529320668.26.5660817 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by imf08.hostedemail.com (Postfix) with ESMTP id F1922160046 for ; Wed, 1 Jun 2022 10:39:08 +0000 (UTC) Received: by mail-pf1-f181.google.com with SMTP id z17so1598470pff.7 for ; Wed, 01 Jun 2022 03:39:34 -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=C78pEyOpmxImWyrV8RjqLJf8nPmlGYFD0fqdmXSu3XWNvntM2agBp44iozoainWKJ3 Axaui0YVALbQSEnR8rjEVrFcjCX26PCWreT1waD7QsntpteG59FKz9Mnrrnuu3nB9eve oCddJpnbDynKK9HCCW91lnavxEvDNpWEdylgo= 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=iZWd3Jgo7WTW7QpPT77EDDacDBnAsfsyPpQm3ko8nsWm0glfpUUhX4xyStKE/9BqPX MTIPLdXxCWKccgAYppSDJmm9dsHR00BKqG8xF3tnl13JZISPg5e1hjnK0fT45ZsguBvK cHTOTM6ttjUlsDx3Ihx2dbqz+T/MvqnaTECm71q4Ap3AyXE24bOM+hYTFa7EWBCIOomh FKvVwzgi1U2aXLJ1600ykbL30OCC+v4TUpiS1sNOXejMsbaR1znFf6tc9GnJj9RyHb2z 4icth0hQxAea/pAAzDjOtTjrwmomBECRAGW9N2Emdyg+e2wrLmXNDHsP3EEeCNhrDSNA VgqQ== X-Gm-Message-State: AOAM531lsFEjPMKfWFOu+XX1w28hvgce+dnO7MiqX79PUQMOVkildA3D bFv6TUIK0xcnPHOSR9MtMg7wIg== X-Google-Smtp-Source: ABdhPJxPBOFPDzYcJlTD535ykPd7L0x0pOe9kzUL+ouANmI7/8e7l2tiHiElnHP5BQ4D4XG6GTHbZA== X-Received: by 2002:a65:6b94:0:b0:3fb:16f4:3620 with SMTP id d20-20020a656b94000000b003fb16f43620mr26218963pgw.464.1654079973429; Wed, 01 Jun 2022 03:39:33 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:dc30:e75c:ae95:f2d6]) by smtp.gmail.com with ESMTPSA id i9-20020a17090332c900b00163bfaf0b17sm1183867plr.233.2022.06.01.03.39.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 03:39:32 -0700 (PDT) From: Hsin-Yi Wang To: Phillip Lougher , Matthew Wilcox , Xiongwei Song Cc: Zheng Liang , Zhang Yi , Hou Tao , Miao Xie , Andrew Morton , "linux-mm @ kvack . org" , "squashfs-devel @ lists . sourceforge . net" , linux-kernel@vger.kernel.org Subject: [PATCH v4 2/3] squashfs: always build "file direct" version of page actor Date: Wed, 1 Jun 2022 18:39:21 +0800 Message-Id: <20220601103922.1338320-3-hsinyi@chromium.org> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220601103922.1338320-1-hsinyi@chromium.org> References: <20220601103922.1338320-1-hsinyi@chromium.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: F1922160046 X-Stat-Signature: 7um1ughyb77ipifauh371c5r716dwg64 X-Rspam-User: Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=C78pEyOp; spf=pass (imf08.hostedemail.com: domain of hsinyi@chromium.org designates 209.85.210.181 as permitted sender) smtp.mailfrom=hsinyi@chromium.org; dmarc=pass (policy=none) header.from=chromium.org X-Rspamd-Server: rspam08 X-HE-Tag: 1654079948-405435 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 @@ obj-$(CONFIG_SQUASHFS) += squashfs.o squashfs-y += block.o cache.o dir.o export.o file.o fragment.o id.o inode.o -squashfs-y += namei.o super.o symlink.o decompressor.o +squashfs-y += namei.o super.o symlink.o decompressor.o page_actor.o squashfs-$(CONFIG_SQUASHFS_FILE_CACHE) += file_cache.o -squashfs-$(CONFIG_SQUASHFS_FILE_DIRECT) += file_direct.o page_actor.o +squashfs-$(CONFIG_SQUASHFS_FILE_DIRECT) += file_direct.o squashfs-$(CONFIG_SQUASHFS_DECOMP_SINGLE) += decompressor_single.o squashfs-$(CONFIG_SQUASHFS_DECOMP_MULTI) += decompressor_multi.o squashfs-$(CONFIG_SQUASHFS_DECOMP_MULTI_PERCPU) += decompressor_multi_percpu.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 */ -#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 = kmalloc(sizeof(*actor), GFP_KERNEL); - - if (actor == NULL) - return NULL; - - actor->length = length ? : pages * PAGE_SIZE; - actor->page = page; - actor->pages = pages; - actor->next_page = 0; - return actor; -} - -static inline void *squashfs_first_page(struct squashfs_page_actor *actor) -{ - actor->next_page = 1; - return actor->page[0]; -} - -static inline void *squashfs_next_page(struct squashfs_page_actor *actor) -{ - return actor->next_page == 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_page_actor *actor) actor->squashfs_finish_page(actor); } #endif -#endif From patchwork Wed Jun 1 10:39:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hsin-Yi Wang X-Patchwork-Id: 12866657 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD513C433EF for ; Wed, 1 Jun 2022 10:39:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 456628D0003; Wed, 1 Jun 2022 06:39:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 408956B00BB; Wed, 1 Jun 2022 06:39:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2CED18D0003; Wed, 1 Jun 2022 06:39:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 1D40B6B00BA for ; Wed, 1 Jun 2022 06:39:38 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id E03CA3476E for ; Wed, 1 Jun 2022 10:39:37 +0000 (UTC) X-FDA: 79529320794.17.EDFF884 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by imf16.hostedemail.com (Postfix) with ESMTP id 60C9618007A for ; Wed, 1 Jun 2022 10:39:20 +0000 (UTC) Received: by mail-pf1-f182.google.com with SMTP id j6so1570300pfe.13 for ; Wed, 01 Jun 2022 03:39:36 -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=Pt3emh9sRv27GcQGoBsy8VqQGPtdBSzil539OvyNfVQ=; b=npgk1ZKmueI5lZFFzNwkrfAGR35TrhiHe4Bt8ftRQ7yumNW8F6tPSmv7mEhm6/tuF1 7KJLx0nwVtdymcisO3+aXt05FKhJ5TbtRgzZihTNkGr/JGrnvVP58/6M3kQoKvJVXwya dbJBblmhBe8tx8v5Ukuu9w4JvI8rSw1qLt5Rk= 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=Pt3emh9sRv27GcQGoBsy8VqQGPtdBSzil539OvyNfVQ=; b=QMFHUyreJGPFKmXYjvOcqzRxwf4c8i25oziNvCYsdDcIiZdX7km5szVjSQuoi/ShV1 wdD0pjSXWcHxiYsNKBnj0vZzfnjk+NtBHl6CQrs4gV89YLAuojzeascd4PSTI8m1Rst+ 9v56Pny6ODoh2fMEPoDLpbH/+4liURarpv3LNRkf2n0tAB+fjaZKXrzJbBcqmXwTToOp RNPtoAuT/iufXcEO6E9AG8oHed2P/BiDSIQy72kNkcooxBrjEBiKnVsqbmvtx32fiHP6 sQfuiiG2zrGMJuLmfsDnOK0qLqrKslK6v7znqS+gC0/Y2pZUyI7nAFQMQcbE9rw0ipn1 DFPg== X-Gm-Message-State: AOAM533X2xEPJ/+q/byskyfbl2IrMIll3pmHU0+b856VvwcUGQmTqWmJ 7wFqNqYK+XDdiQLaAO4CRQmisw== X-Google-Smtp-Source: ABdhPJyTATonbx8DBaAETQIhbDZDdB/jypUUcYIpqGWAzeXLbC2fOMCBWG9ub55OlJpr43hOQgu0SQ== X-Received: by 2002:a63:894a:0:b0:3fc:a724:578c with SMTP id v71-20020a63894a000000b003fca724578cmr1936274pgd.499.1654079976036; Wed, 01 Jun 2022 03:39:36 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:dc30:e75c:ae95:f2d6]) by smtp.gmail.com with ESMTPSA id i9-20020a17090332c900b00163bfaf0b17sm1183867plr.233.2022.06.01.03.39.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 03:39:35 -0700 (PDT) From: Hsin-Yi Wang To: Phillip Lougher , Matthew Wilcox , Xiongwei Song Cc: Zheng Liang , Zhang Yi , Hou Tao , Miao Xie , Andrew Morton , "linux-mm @ kvack . org" , "squashfs-devel @ lists . sourceforge . net" , linux-kernel@vger.kernel.org Subject: [PATCH v4 3/3] squashfs: implement readahead Date: Wed, 1 Jun 2022 18:39:22 +0800 Message-Id: <20220601103922.1338320-4-hsinyi@chromium.org> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220601103922.1338320-1-hsinyi@chromium.org> References: <20220601103922.1338320-1-hsinyi@chromium.org> MIME-Version: 1.0 Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=npgk1ZKm; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf16.hostedemail.com: domain of hsinyi@chromium.org designates 209.85.210.182 as permitted sender) smtp.mailfrom=hsinyi@chromium.org X-Stat-Signature: cengikmmew6f1g8jcwyfz59btp6n1n1j X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 60C9618007A X-HE-Tag: 1654079960-455804 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 or not enough in a 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 --- v3->v4: Fix a few variable type and their locations. v3: https://lore.kernel.org/lkml/20220523065909.883444-4-hsinyi@chromium.org/ v2: https://lore.kernel.org/lkml/20220517082650.2005840-4-hsinyi@chromium.org/ v1: https://lore.kernel.org/lkml/20220516105100.1412740-3-hsinyi@chromium.org/ --- fs/squashfs/file.c | 97 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 1 deletion(-) diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c index a8e495d8eb86..df7ad4b3e99c 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" /* * Locate cache slot in range [offset, index] for specified inode. If @@ -495,7 +496,101 @@ static int squashfs_read_folio(struct file *file, struct folio *folio) return 0; } +static void squashfs_readahead(struct readahead_control *ractl) +{ + struct inode *inode = ractl->mapping->host; + struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info; + size_t mask = (1UL << msblk->block_log) - 1; + unsigned short shift = msblk->block_log - PAGE_SHIFT; + loff_t start = readahead_pos(ractl) &~ mask; + size_t len = readahead_length(ractl) + readahead_pos(ractl) - start; + struct squashfs_page_actor *actor; + unsigned int nr_pages = 0; + struct page **pages; + int i, file_end = i_size_read(inode) >> msblk->block_log; + unsigned int max_pages = 1UL << shift; + + readahead_expand(ractl, start, (len | mask) + 1); + + if (file_end == 0) + return; + + pages = kmalloc_array(max_pages, sizeof(void *), GFP_KERNEL); + if (!pages) + return; + + actor = squashfs_page_actor_init_special(pages, max_pages, 0); + if (!actor) + goto out; + + for (;;) { + pgoff_t index; + int res, bsize; + u64 block = 0; + unsigned int expected; + + nr_pages = __readahead_batch(ractl, pages, max_pages); + if (!nr_pages) + break; + + if (readahead_pos(ractl) >= i_size_read(inode) || + nr_pages < max_pages) + goto skip_pages; + + index = pages[0]->index >> shift; + if ((pages[nr_pages - 1]->index >> shift) != index) + goto skip_pages; + + expected = index == file_end ? + (i_size_read(inode) & (msblk->block_size - 1)) : + msblk->block_size; + + bsize = read_blocklist(inode, index, &block); + if (bsize == 0) + goto skip_pages; + + res = squashfs_read_data(inode->i_sb, block, bsize, NULL, + actor); + + if (res == expected) { + int bytes; + + /* Last page may have trailing bytes not filled */ + bytes = res % PAGE_SIZE; + if (bytes) { + void *pageaddr; + + pageaddr = kmap_atomic(pages[nr_pages - 1]); + memset(pageaddr + bytes, 0, PAGE_SIZE - bytes); + kunmap_atomic(pageaddr); + } + + for (i = 0; i < nr_pages; i++) + SetPageUptodate(pages[i]); + } + + for (i = 0; i < nr_pages; i++) { + unlock_page(pages[i]); + put_page(pages[i]); + } + } + + kfree(actor); + kfree(pages); + return; + +skip_pages: + for (i = 0; i < nr_pages; i++) { + unlock_page(pages[i]); + put_page(pages[i]); + } + + kfree(actor); +out: + kfree(pages); +} const struct address_space_operations squashfs_aops = { - .read_folio = squashfs_read_folio + .read_folio = squashfs_read_folio, + .readahead = squashfs_readahead };