From patchwork Mon Jun 6 15:03:03 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: 12870502 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 7009DCCA473 for ; Mon, 6 Jun 2022 15:03:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EAB4D8D0001; Mon, 6 Jun 2022 11:03:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E365B6B0074; Mon, 6 Jun 2022 11:03:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D1FC08D0001; Mon, 6 Jun 2022 11:03:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C4A876B0073 for ; Mon, 6 Jun 2022 11:03:15 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 9B3D21207E5 for ; Mon, 6 Jun 2022 15:03:15 +0000 (UTC) X-FDA: 79548129150.10.3F6C2AD Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by imf26.hostedemail.com (Postfix) with ESMTP id 5324614005D for ; Mon, 6 Jun 2022 15:03:10 +0000 (UTC) Received: by mail-pj1-f52.google.com with SMTP id gd1so13044906pjb.2 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=jBslK0ss3WIvH1OwlKJzxhwG0JovlfxQSMmSl8mBDAjS2jak9AT31Arz5tiyn92mnE SlWq0OfDsiKYZmJdlmQtULRH1wzeYOWTwAhdQkqjWzc0fXFIAUNg4+TJcwiYmKfWMVyu eBgjP9XBE1dkUnYtg8yKgHZeJ1JMvDcF7/+MFjYVzP27Ph/FW6BZe6pa6aWJ3GDmHILq JUNadSlLlI8zkhZ0Ewl7A8rqmH7NigpPTP+sUIIatDjRH0Qyk3LfTbtnqPRYFTPB97ks 5/OAC3iPMWnywDr4NnNF4rHATqoLV7YYDqSFn80/1jrCOivtl2NO3EhYLyuU5KUcN+vi OWNA== X-Gm-Message-State: AOAM531UAu8hDufvIL/5Vfj9ql2tS04tXghb10OUzFga2oOt/cw8QzLb JQ4xfN+yG/YVsT7DRdrJNr5ZFA== 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 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 5324614005D Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=LaLT54Og; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf26.hostedemail.com: domain of hsinyi@chromium.org designates 209.85.216.52 as permitted sender) smtp.mailfrom=hsinyi@chromium.org X-Stat-Signature: 18qi9weh6xdxc9qtkj5b89i7apk67ta9 X-Rspam-User: X-HE-Tag: 1654527790-963394 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 Mon Jun 6 15:03:04 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: 12870503 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 5ED4DC43334 for ; Mon, 6 Jun 2022 15:03:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 002DC6B0073; Mon, 6 Jun 2022 11:03:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EF4028D0003; Mon, 6 Jun 2022 11:03:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DBCFE8D0002; Mon, 6 Jun 2022 11:03:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id CB74D6B0073 for ; Mon, 6 Jun 2022 11:03:18 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 99FEA2096C for ; Mon, 6 Jun 2022 15:03:18 +0000 (UTC) X-FDA: 79548129276.14.13C6514 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by imf31.hostedemail.com (Postfix) with ESMTP id 8B4A520085 for ; Mon, 6 Jun 2022 15:02:32 +0000 (UTC) Received: by mail-pf1-f175.google.com with SMTP id u2so12931139pfc.2 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=g9y9D4ZZmqwAAn1w9x5FUJ8zOgvk/n0UoiUtLWysCEzxrL5xPfTchIjsy7kEUMFK0c 5Lb9+umD/aGp/wX03hLvRkVKcfFxJcN21QITGWR/S96i4T3FZBZh9W0HK6zwoJgWKj8+ 1fsJQO29G6t7w5DYU5NSWGFINDZaCyF7HxIrKqwhL/xm5yOQ8H4HSpCG+2oNMqoRaICK wNfZtt3VKfmIn8F5T+DUqCIYHJl1oZFB0RXhY4Og8o6maiiVCJ6j6g0a6PaB2HOVXf5K yf/mC+6uu2X16++AIzMsb3wv3DSQmSgM8+eXYNlh9HOUJFMrRAvxj+DdrENRxVqq/uC8 Y2fg== X-Gm-Message-State: AOAM532IhQ0GhEu5094QEqBQfAoTXOiRh5DfE/yQQ7OzyYXcLSfbxTSE DpJB5v909OJMRPfNhkdY4Egd4g== 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 X-Stat-Signature: 94xo579feuhckjaoq7h958489z16cgu4 Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b="Oxd/anO5"; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf31.hostedemail.com: domain of hsinyi@chromium.org designates 209.85.210.175 as permitted sender) smtp.mailfrom=hsinyi@chromium.org X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 8B4A520085 X-HE-Tag: 1654527752-750742 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 Mon Jun 6 15:03:05 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: 12870504 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 EB5E1C43334 for ; Mon, 6 Jun 2022 15:03:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 831296B0074; Mon, 6 Jun 2022 11:03:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7E4798D0003; Mon, 6 Jun 2022 11:03:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 67E1B8D0002; Mon, 6 Jun 2022 11:03:21 -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 595E26B0074 for ; Mon, 6 Jun 2022 11:03:21 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 2F7B0349F7 for ; Mon, 6 Jun 2022 15:03:21 +0000 (UTC) X-FDA: 79548129402.26.581A22E Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by imf09.hostedemail.com (Postfix) with ESMTP id 05C93140016 for ; Mon, 6 Jun 2022 15:03:03 +0000 (UTC) Received: by mail-pj1-f46.google.com with SMTP id w2-20020a17090ac98200b001e0519fe5a8so12768402pjt.4 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=zygxdiiLpycyEAB90Bh8BSwhfvVe1iApufCmQeQvTamQP5BEXp9CFopFa/OWIrVft9 hqfhOkhPSrkXgrHcZJ1W5ThzMhOd3SApl4BqqE3qPi7kgOUOrIjouVFtPFFsrlkY5XzB u9eFlVbjus0PO24o5cRtRdFV1AbsnvI24zXDZhIW1uFejIEu0e9qAkPtrWi0GyYNuR0S /KKLPY9XovgTGX/wCOc3YF1/nlfdOAt4MN/9pygKqJ6sPOo8MJ2fHjVnVPpyXI9qvf1j IGa6YXtUKholIkxtkIlHxJxRKFfo0STDZyYGeBl0wYnThGx0wDBnrA6chu4rra3HkvX2 RjXQ== X-Gm-Message-State: AOAM531eNtP6n6mBkEABIKWj4A4GgjBdQW7VX61yY1bQtmDebj5MnnrU GuMhmSwdbD0mi7yKJyOk0asZLA== 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 X-Stat-Signature: gp17s5t8p97t9437d3xxfughekmfek87 Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=em8v3f6I; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf09.hostedemail.com: domain of hsinyi@chromium.org designates 209.85.216.46 as permitted sender) smtp.mailfrom=hsinyi@chromium.org X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 05C93140016 X-HE-Tag: 1654527783-522058 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. - 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.org/ 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 | 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" /* * Locate cache slot in range [offset, index] for specified inode. If @@ -495,7 +496,128 @@ 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)) + 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; + + if (nr_pages < max_pages) { + struct squashfs_cache_entry *buffer; + unsigned int block_mask = max_pages - 1; + int offset = pages[0]->index - (pages[0]->index & ~block_mask); + + buffer = squashfs_get_datablock(inode->i_sb, block, + bsize); + if (buffer->error) { + squashfs_cache_put(buffer); + goto skip_pages; + } + + expected -= offset * PAGE_SIZE; + for (i = 0; i < nr_pages && expected > 0; i++, + expected -= PAGE_SIZE, offset++) { + int avail = 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 = 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++) { + flush_dcache_page(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 };