From patchwork Fri Jun 17 08:38:09 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: 12885293 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 B391BC433EF for ; Fri, 17 Jun 2022 08:38:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 53D5A6B0081; Fri, 17 Jun 2022 04:38:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4C67F6B0082; Fri, 17 Jun 2022 04:38:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 33FE26B0083; Fri, 17 Jun 2022 04:38:43 -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 21B976B0081 for ; Fri, 17 Jun 2022 04:38:43 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id EA3D181534 for ; Fri, 17 Jun 2022 08:38:42 +0000 (UTC) X-FDA: 79587076884.02.4CAFCDD Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by imf10.hostedemail.com (Postfix) with ESMTP id 86B63C000A for ; Fri, 17 Jun 2022 08:38:42 +0000 (UTC) Received: by mail-pj1-f43.google.com with SMTP id f16so2432049pjj.1 for ; Fri, 17 Jun 2022 01:38: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=ZkbtHcgR5KA0zD+x9oTUHYVWwacT9VRypGcZ4wLZpOg=; b=IQFp5xvBUij3vF6RFgONUsdI4F7LxAqN3ZtrQJPeUNxo+8zjmXF0j0NLkeatzKk0Mu Defn/MOopf+Tt0LZJhZgRZHPpDV16Far+cgOJxrI7ZBIjwr2nsEfcGhxQyeciQWOJJk9 92AbvVtuk7PzI/PoFh5iu1MlFb2Rm7mCnC7lc= 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=ZkbtHcgR5KA0zD+x9oTUHYVWwacT9VRypGcZ4wLZpOg=; b=8OlC6/sNKWKdvYHQOHhCqurNQyszFJ2lpXnsV0QosSFHkHVCAhIhmYwUsyafoqcXX5 TxwDKYn2FokQymrtqqyOvH00JnGWYymWMc6qXaSyBMA83TsCTOpyYnV3iSCyA17dfgU1 LYxV53eColLIlokIjMUsUN5y6RaYqQKmSnGrHnNh5EgCE+KYpi0Fk4fyDUBBM/A3lo4T OS7rtMB0EBeZx63GA8ayYLA0pv/SiFhALh2DSNrgJZoaDXJZNosX+QKE/4a2bWcMuiZv asMfx3Dn3MzhyGGtixoX51Kaxiq2c4ToF50Ve59AXC3o/Itoa0hHf/qRyvWpYnhfdSSE q4IA== X-Gm-Message-State: AJIora8X+7F8xKyFYXU8xbThYNzxfEt8Uj+QaYDRVFsymw/LgvP+JWki fGodYS/C4OkCPEemghjhVOb5tA== X-Google-Smtp-Source: AGRyM1s7VdOCGqUQpIDER4YWqjxPf/Ek4KvwYv/N24Zykvnrz2Rw2pxH86XQrvXmIMf1TkI7KpHZxg== X-Received: by 2002:a17:902:930c:b0:167:8960:2c39 with SMTP id bc12-20020a170902930c00b0016789602c39mr8426893plb.33.1655455121565; Fri, 17 Jun 2022 01:38:41 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:a0dc:9427:fea8:f78a]) by smtp.gmail.com with ESMTPSA id d12-20020a62f80c000000b005185407eda5sm3154103pfh.44.2022.06.17.01.38.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 01:38:41 -0700 (PDT) From: Hsin-Yi Wang To: Phillip Lougher , Matthew Wilcox , Marek Szyprowski , Andrew Morton Cc: Xiongwei Song , Zheng Liang , Zhang Yi , Hou Tao , Miao Xie , "linux-mm @ kvack . org" , "squashfs-devel @ lists . sourceforge . net" , linux-kernel@vger.kernel.org Subject: [PATCH v7 1/4] Revert "squashfs: provide backing_dev_info in order to disable read-ahead" Date: Fri, 17 Jun 2022 16:38:09 +0800 Message-Id: <20220617083810.337573-2-hsinyi@chromium.org> X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog In-Reply-To: <20220617083810.337573-1-hsinyi@chromium.org> References: <20220617083810.337573-1-hsinyi@chromium.org> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=IQFp5xvB; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf10.hostedemail.com: domain of hsinyi@chromium.org designates 209.85.216.43 as permitted sender) smtp.mailfrom=hsinyi@chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655455122; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ZkbtHcgR5KA0zD+x9oTUHYVWwacT9VRypGcZ4wLZpOg=; b=Lt/4CMJqAtB3YZJzXvctFG3CZciprkdH9A373UN6oFHFJ9itQ5jseX1FCVc0PE3hIADkwe 4CNNolGDjMg5qATTxay9WPHCW6fXx1MePfAYACjCgKWJe0KmgyWD0xOKv+GQK9H2MQgiLi c/aWNJDujoXniokDIgiNa+0hglvf6LA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655455122; a=rsa-sha256; cv=none; b=xIPJd4toibZmAIRKlXYKomeYRuKCb3pxu7NZYdIU9qi2TJ/88r+K8V4vDC2M8hFROeLekJ QFKU/m1Zo6CUEoo5B+8LHbO7R4z5TOnCdVoVmGwRcilUbk/UmX6gvx0uxyNeCZAPAyje3O h+XPNKnXBQsT+g9uvCT7Boxxuu8zr+Y= X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 86B63C000A X-Rspam-User: Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=IQFp5xvB; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf10.hostedemail.com: domain of hsinyi@chromium.org designates 209.85.216.43 as permitted sender) smtp.mailfrom=hsinyi@chromium.org X-Stat-Signature: idasoggfu8ch1ptaf4sns815furegurm X-HE-Tag: 1655455122-91198 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 6d594ba2ed28f..32565dafa7f3b 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 Fri Jun 17 08:38:11 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: 12885294 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 8C1DDC433EF for ; Fri, 17 Jun 2022 08:38:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0AF816B0082; Fri, 17 Jun 2022 04:38:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 00B806B0083; Fri, 17 Jun 2022 04:38:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DEE476B0085; Fri, 17 Jun 2022 04:38:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id CB5376B0082 for ; Fri, 17 Jun 2022 04:38:55 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 98C66939 for ; Fri, 17 Jun 2022 08:38:55 +0000 (UTC) X-FDA: 79587077430.10.4A37E6B Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by imf11.hostedemail.com (Postfix) with ESMTP id 2A64F40086 for ; Fri, 17 Jun 2022 08:38:55 +0000 (UTC) Received: by mail-pf1-f172.google.com with SMTP id u2so3623821pfc.2 for ; Fri, 17 Jun 2022 01:38:54 -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=zopK+BvSuamYvb8kkpPXiSJpoMOkgUyTWgxXUH/cCsw=; b=GpjdkIbTWWbrZUCBW7rlQQdUuuBvKFDKBuLlaoY5VjEUH10jMZXq59WS6tJnFqEgfL c2058J9vJgcrlylt8KFriWP/rA4D2Tzv8GF0nE7LdoNrmnUfvxYWAlDgXRm62NqnITvI SgKeEyr4pOBraKH9bjFC+FgB/1ZzI5FGuLBG4= 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=zopK+BvSuamYvb8kkpPXiSJpoMOkgUyTWgxXUH/cCsw=; b=WINxZT6gc0TdvJi7eLwQIukjh5Y6KhaLP/B0bni1mH8/w6TsiKRJTjRsTg55bQ0SwF hxbYNf8AavxLFt3AUpEiQJ/wUuxbWp7iExEugkXb3UVVPtmZ0LMKsIOgyXH754KEpTLv wKmCCQLqZNIgeQlrL/h08WF7sbFZl2JwiqA79xk32kxhXV8avvhpJnGyiQYVT7zaVrY1 9bRnuLx7Pmb4aZCHgRbuEFCsGN6wj06FBkOar6jsZ214D3MMsdTeKPcLLL6NNYPU3wUH zPEguMw+xxg0MAFjE71lNumQ/UrdgtcXWQwVIdb5jx9Wj3tWIkgG4+gI+e/IEAuCCbGf 3tCA== X-Gm-Message-State: AJIora+bFEdX76uearVUCw0I6p+yeK1VrNNFlIuufuM15bvOnOVP1rJA SEyafYYyzjWVyAAxw05Xz0JF2A== X-Google-Smtp-Source: AGRyM1uPYLhqbv/0uKLCtUWT/6Sgfvzcvfo4kaPqSj6W9uUwVrFuRA9YUyKPuKXoe5ttY3bo9JJPng== X-Received: by 2002:a05:6a00:1502:b0:51c:2991:f1c with SMTP id q2-20020a056a00150200b0051c29910f1cmr8765805pfu.37.1655455134146; Fri, 17 Jun 2022 01:38:54 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:a0dc:9427:fea8:f78a]) by smtp.gmail.com with ESMTPSA id d12-20020a62f80c000000b005185407eda5sm3154103pfh.44.2022.06.17.01.38.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 01:38:53 -0700 (PDT) From: Hsin-Yi Wang To: Phillip Lougher , Matthew Wilcox , Marek Szyprowski , Andrew Morton Cc: Xiongwei Song , Zheng Liang , Zhang Yi , Hou Tao , Miao Xie , "linux-mm @ kvack . org" , "squashfs-devel @ lists . sourceforge . net" , linux-kernel@vger.kernel.org Subject: [PATCH v7 2/4] squashfs: always build "file direct" version of page actor Date: Fri, 17 Jun 2022 16:38:11 +0800 Message-Id: <20220617083810.337573-3-hsinyi@chromium.org> X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog In-Reply-To: <20220617083810.337573-1-hsinyi@chromium.org> References: <20220617083810.337573-1-hsinyi@chromium.org> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=GpjdkIbT; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf11.hostedemail.com: domain of hsinyi@chromium.org designates 209.85.210.172 as permitted sender) smtp.mailfrom=hsinyi@chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655455135; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=zopK+BvSuamYvb8kkpPXiSJpoMOkgUyTWgxXUH/cCsw=; b=NDev24n6U5svwiOw5O9y6UHM5Touf3/gtYwIRV1Q17ZQqseQ9J41WS++1I82Kq15v+Sci2 oXm2CUH7Iqn63Hj4RtxaK71maZWD+Yg/8O7t1rM3U9kfapPZyNgk1909jWrnigQrqdKxH2 0p4bd7LyVOwWAW4cpK5LCHNy/H094GU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655455135; a=rsa-sha256; cv=none; b=KCuVS0T9SMe8dr5geYUdhcaCPofZG88LIAgqBYGjCsYEe+bWMunh6r3mR/hIq0OVJMIluO LLBc5cZyIpF5HZSu1SB2/y7gfNtd2k9PYXfMzAPQ7OmzsVC1IYbebBRohmU/exnh+KoKVt myMhv+phDZqMU8hMJB9ypRchfX5Ji8A= X-Stat-Signature: wqsfowjfnp9zqu8sobptqgwmpumrczpg X-Rspamd-Queue-Id: 2A64F40086 X-Rspam-User: Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=GpjdkIbT; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf11.hostedemail.com: domain of hsinyi@chromium.org designates 209.85.210.172 as permitted sender) smtp.mailfrom=hsinyi@chromium.org X-Rspamd-Server: rspam10 X-HE-Tag: 1655455135-785399 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 | 46 ---------------------------------------- 2 files changed, 2 insertions(+), 48 deletions(-) diff --git a/fs/squashfs/Makefile b/fs/squashfs/Makefile index 7bd9b8b856d0b..477c89a519ee8 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 37523c54256fa..24841d28bc0fb 100644 --- a/fs/squashfs/page_actor.h +++ b/fs/squashfs/page_actor.h @@ -6,51 +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 */ -} - -static inline void squashfs_actor_nobuff(struct squashfs_page_actor *actor) -{ - /* empty */ -} -#else struct squashfs_page_actor { union { void **buffer; @@ -91,4 +46,3 @@ static inline void squashfs_actor_nobuff(struct squashfs_page_actor *actor) actor->alloc_buffer = 0; } #endif -#endif From patchwork Fri Jun 17 08:38:13 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: 12885295 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 9C738C433EF for ; Fri, 17 Jun 2022 08:39:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3B6836B0083; Fri, 17 Jun 2022 04:39:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 33F436B0085; Fri, 17 Jun 2022 04:39:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 192366B0087; Fri, 17 Jun 2022 04:39:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 05C146B0083 for ; Fri, 17 Jun 2022 04:39:05 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D4B03214AF for ; Fri, 17 Jun 2022 08:39:04 +0000 (UTC) X-FDA: 79587077808.26.A10559A Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by imf21.hostedemail.com (Postfix) with ESMTP id 7CC4C1C00A5 for ; Fri, 17 Jun 2022 08:39:04 +0000 (UTC) Received: by mail-pl1-f174.google.com with SMTP id r1so3311111plo.10 for ; Fri, 17 Jun 2022 01:39:04 -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=OcQHcF0Ot6zJHxJE6BCq0SLAaPt9Vdx4j9mbahe8wSE=; b=gKMzClnTDfI8SUjMNX6fH7fhxMRMio7/lnouINYXTknvlSQGrGJcKIAZtWflN/Bohq qoxPsXVblEwF/jvueaJK163tba46YMu4zx8a5mAiAXDZn+N5vtObxQ9xc8Q6AghEOMJD W5f5AraAVihtPahuek9K4ljUWRatX40WkUMuA= 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=OcQHcF0Ot6zJHxJE6BCq0SLAaPt9Vdx4j9mbahe8wSE=; b=QKLkoOX7STaio5LtT63NNwmmDCmaaou3KqGRewgSEnUisgaNJQWLMTkExaFEXH10Nq qIiWdUmOyPbc54PnmFh8Lk/m7Dn3XxIcGbTQnufsgsNrtgNbcK4pyMvDzjEqLvPqOp/4 07Zzix9/KovkbgTd2gi4xyhwqiO8AbzQlh5eKxDh4RVzQWZMBdUmFkQxkH5LcJblQV78 H+KSwPsdNr4ylR96/G9+7y4upM6OhP8hnmc1suZ1L4XjYHfnFdxkR49pvY3Uo0emSrWm qsTVrarxtTWFqFtfypAJWVeoG4SVcaOuIk8MW3HhwDIAVLQrYUElSKYKZJzWK6RUVpyC dlMQ== X-Gm-Message-State: AJIora+f+GpfF7si1AXWQGswYICkjzun6XX7xKDSr6XD9U64DNB79+Jp oqRHQr0AzKcbEt1Y1d6mmXPl9g== X-Google-Smtp-Source: AGRyM1vXrobSvy6fvBmTMguR7jdxWtClLv8yNDivQ52V+DQBP9+yRJ7i0flqk2jWsoX1tcsWCsKVUA== X-Received: by 2002:a17:902:d50e:b0:16a:13d:30ab with SMTP id b14-20020a170902d50e00b0016a013d30abmr3915658plg.31.1655455143450; Fri, 17 Jun 2022 01:39:03 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:a0dc:9427:fea8:f78a]) by smtp.gmail.com with ESMTPSA id d12-20020a62f80c000000b005185407eda5sm3154103pfh.44.2022.06.17.01.39.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 01:39:03 -0700 (PDT) From: Hsin-Yi Wang To: Phillip Lougher , Matthew Wilcox , Marek Szyprowski , Andrew Morton Cc: Xiongwei Song , Zheng Liang , Zhang Yi , Hou Tao , Miao Xie , "linux-mm @ kvack . org" , "squashfs-devel @ lists . sourceforge . net" , linux-kernel@vger.kernel.org Subject: [PATCH v7 3/4] squashfs: implement readahead Date: Fri, 17 Jun 2022 16:38:13 +0800 Message-Id: <20220617083810.337573-4-hsinyi@chromium.org> X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog In-Reply-To: <20220617083810.337573-1-hsinyi@chromium.org> References: <20220617083810.337573-1-hsinyi@chromium.org> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=gKMzClnT; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf21.hostedemail.com: domain of hsinyi@chromium.org designates 209.85.214.174 as permitted sender) smtp.mailfrom=hsinyi@chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655455144; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=OcQHcF0Ot6zJHxJE6BCq0SLAaPt9Vdx4j9mbahe8wSE=; b=fyklneiTiSPAOo+FZfnUksn8n6ySj0epGUm4BwuWMCLUn31Q1N1p+YpZShw6+KahAYHkfA p5HRIX4Wa63d6KVzkYEy8HV24s5frPkg7ZwMFBuNLmzYL7P1PRJsu5OrB0z1fgSBkvuv0D MUKQWek21pAO7ViUrLv9zm9DEMcBsms= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655455144; a=rsa-sha256; cv=none; b=fW/7tOLRMoMPP0FwlU/3yClrg+UjctT2CH8jYHB6+dBV7+B+3/5E9zqMKj3l4LwyceEC6M T6jcLxTTOjsZStdn8mhTL25rbB2185DDb+8yl4GRqLYW0A2e6PUGsdqjhA28CxCY0COm3E fVHsPP9zrJytaJVMDLCB2sbEryGsPo0= X-Stat-Signature: qip9e4toauf3t33skthj4okfc35tt5cb X-Rspamd-Queue-Id: 7CC4C1C00A5 X-Rspam-User: Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=gKMzClnT; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf21.hostedemail.com: domain of hsinyi@chromium.org designates 209.85.214.174 as permitted sender) smtp.mailfrom=hsinyi@chromium.org X-Rspamd-Server: rspam10 X-HE-Tag: 1655455144-928291 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: Andrew Morton --- fs/squashfs/file.c | 92 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-) diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c index 7f0904b203294..f0c64ee272d5d 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 @@ -496,7 +497,96 @@ static int squashfs_read_folio(struct file *file, struct folio *folio) return res; } +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; + + 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; + + actor = squashfs_page_actor_init_special(msblk, pages, nr_pages, + expected); + if (!actor) + goto skip_pages; + + res = squashfs_read_data(inode->i_sb, block, bsize, NULL, actor); + + kfree(actor); + + if (res == expected) { + int bytes; + + /* Last page (if present) may have trailing bytes not filled */ + bytes = res % PAGE_SIZE; + if (pages[nr_pages - 1]->index == file_end && bytes) + memzero_page(pages[nr_pages - 1], bytes, + PAGE_SIZE - bytes); + + 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(pages); + return; + +skip_pages: + for (i = 0; i < nr_pages; i++) { + unlock_page(pages[i]); + put_page(pages[i]); + } + kfree(pages); +} const struct address_space_operations squashfs_aops = { - .read_folio = squashfs_read_folio + .read_folio = squashfs_read_folio, + .readahead = squashfs_readahead }; From patchwork Fri Jun 17 08:38:15 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: 12885296 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 0D161C433EF for ; Fri, 17 Jun 2022 08:39:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9830B6B0080; Fri, 17 Jun 2022 04:39:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 90BF06B0085; Fri, 17 Jun 2022 04:39:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 785E76B0087; Fri, 17 Jun 2022 04:39:14 -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 62D436B0080 for ; Fri, 17 Jun 2022 04:39:14 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 3D534163A for ; Fri, 17 Jun 2022 08:39:14 +0000 (UTC) X-FDA: 79587078228.26.8397064 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by imf12.hostedemail.com (Postfix) with ESMTP id E19E8400A1 for ; Fri, 17 Jun 2022 08:39:13 +0000 (UTC) Received: by mail-pl1-f182.google.com with SMTP id d13so3299310plh.13 for ; Fri, 17 Jun 2022 01:39:13 -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=G086Dnit23XcYgqGZXR8d4QAiX5I5zPq+4/SqclxxJs=; b=VdbwQ4cd6v433oanoE0oyHKGpgJ6Sqwso/c30X2vOYB5aA4/iAtfKKyfVWc0dmgiXu CWjpdg0Kc8jVXkJVDW8W21xhw0scR/bhN55J5YUHztOeynl60wnyx6Yav+WWA1iL1NKy BrkUYqeLHVQqTyDE2xNlZuADrrmCANFnZj9WU= 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=G086Dnit23XcYgqGZXR8d4QAiX5I5zPq+4/SqclxxJs=; b=0PIPVqgwVmlMXvsbBVgX+W9I6h/FL0jDUGM989Qtxz02Z/dovSQXBAli0L1O+AGT/Y 3W6cbucMH6OEAgGSCooKP95fDE+GNEyazf6A69VzVzLoCkrbb+lmG/Xqva7zOrhcDcNT O2zPAjvIULPw7JNsaICbpBkwtFlUdTSF4GHbESHt+apqFWjx5MhC3+fUo9BhjOLz0CZz DlrApPxRaBRSqWPYeoqXAdQvbD8t0rKZyMdfPkwkcAIKbFSynuG7nweuoQq1QtocwMp/ O3VBiZnkVj2+3wLrznlzMwts68jrDRPanPuussm14rWxn+d2JQRBnYey7j+3Z9Ed5dzW KnHQ== X-Gm-Message-State: AJIora/2hxTqBPZ03NSi1/1KzuOog6Hr1+JJ1pgTIPN0lhyYQHx0jNhu 6Rfhr2PtaIMaphPvnPdKjnlR+Q== X-Google-Smtp-Source: AGRyM1tPpQfuwZvZz9Xp+OlNElXn9z7cg7Ee0CHxsdUetFEHC3NVB1yjPycl87pTn/NmxdJo4O59hw== X-Received: by 2002:a17:90b:388c:b0:1e2:f376:b8d with SMTP id mu12-20020a17090b388c00b001e2f3760b8dmr20205301pjb.148.1655455152985; Fri, 17 Jun 2022 01:39:12 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:a0dc:9427:fea8:f78a]) by smtp.gmail.com with ESMTPSA id d12-20020a62f80c000000b005185407eda5sm3154103pfh.44.2022.06.17.01.39.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 01:39:12 -0700 (PDT) From: Hsin-Yi Wang To: Phillip Lougher , Matthew Wilcox , Marek Szyprowski , Andrew Morton Cc: Xiongwei Song , Zheng Liang , Zhang Yi , Hou Tao , Miao Xie , "linux-mm @ kvack . org" , "squashfs-devel @ lists . sourceforge . net" , linux-kernel@vger.kernel.org Subject: [PATCH v7 4/4] squashfs: support reading fragments in readahead call Date: Fri, 17 Jun 2022 16:38:15 +0800 Message-Id: <20220617083810.337573-5-hsinyi@chromium.org> X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog In-Reply-To: <20220617083810.337573-1-hsinyi@chromium.org> References: <20220617083810.337573-1-hsinyi@chromium.org> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655455154; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=G086Dnit23XcYgqGZXR8d4QAiX5I5zPq+4/SqclxxJs=; b=5YlqtyKyl4ItaUXx3dnNO3fqkQzyFKagcIA0u7um4FbaOr3dK7KtG5A9P0j3SqrRmHxLIO 64tlcYlshCrUeUufgmzos320RLDbO9K8t+qytCPcley7CRYQzNKgyBFqKgwIsds28SBQ8v P9HgbqC9e4HBOxsrwH6SVm1pCZgS5l4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655455154; a=rsa-sha256; cv=none; b=4uAYWXXiBQVUQFe4cyizxiJ0AXlB9REzaI1RXDOhuVse+2DvijLy9eIuknTqlYRoXsFVvO xBZtRU9s8odE4akL6yPdS9iMxS5Mw++Up7BDq4BIx8EF5PR9X+obEzPl+/tr6e1ddn207k c1EkJon1kYFCgXdAKVqDftV0vQACKKg= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=VdbwQ4cd; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf12.hostedemail.com: domain of hsinyi@chromium.org designates 209.85.214.182 as permitted sender) smtp.mailfrom=hsinyi@chromium.org Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=VdbwQ4cd; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf12.hostedemail.com: domain of hsinyi@chromium.org designates 209.85.214.182 as permitted sender) smtp.mailfrom=hsinyi@chromium.org X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: E19E8400A1 X-Stat-Signature: uwag17mj6pt1dids7jfmsh5qx3fsgze1 X-HE-Tag: 1655455153-124840 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 This patch adds a function which can be used to read fragments in the readahead call. This function is necessary because filesystems built with the -tailends (or -always-use-fragments) option may have fragments present which cannot be currently handled. Signed-off-by: Phillip Lougher Signed-off-by: Hsin-Yi Wang --- fs/squashfs/file.c | 47 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c index f0c64ee272d5d..98e64fec75b77 100644 --- a/fs/squashfs/file.c +++ b/fs/squashfs/file.c @@ -497,6 +497,41 @@ static int squashfs_read_folio(struct file *file, struct folio *folio) return res; } +static int squashfs_readahead_fragment(struct page **page, + unsigned int pages, unsigned int expected) +{ + struct inode *inode = page[0]->mapping->host; + struct squashfs_cache_entry *buffer = squashfs_get_fragment(inode->i_sb, + squashfs_i(inode)->fragment_block, + squashfs_i(inode)->fragment_size); + struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info; + unsigned int n, mask = (1 << (msblk->block_log - PAGE_SHIFT)) - 1; + + if (buffer->error) + goto out; + + expected += squashfs_i(inode)->fragment_offset; + + for (n = 0; n < pages; n++) { + unsigned int base = (page[n]->index & mask) << PAGE_SHIFT; + unsigned int offset = base + squashfs_i(inode)->fragment_offset; + + if (expected > offset) { + unsigned int avail = min_t(unsigned int, expected - + offset, PAGE_SIZE); + + squashfs_fill_page(page[n], buffer, offset, avail); + } + + unlock_page(page[n]); + put_page(page[n]); + } + +out: + squashfs_cache_put(buffer); + return buffer->error; +} + static void squashfs_readahead(struct readahead_control *ractl) { struct inode *inode = ractl->mapping->host; @@ -513,9 +548,6 @@ static void squashfs_readahead(struct readahead_control *ractl) readahead_expand(ractl, start, (len | mask) + 1); - if (file_end == 0) - return; - pages = kmalloc_array(max_pages, sizeof(void *), GFP_KERNEL); if (!pages) return; @@ -541,6 +573,15 @@ static void squashfs_readahead(struct readahead_control *ractl) (i_size_read(inode) & (msblk->block_size - 1)) : msblk->block_size; + if (index == file_end && squashfs_i(inode)->fragment_block != + SQUASHFS_INVALID_BLK) { + res = squashfs_readahead_fragment(pages, nr_pages, + expected); + if (res) + goto skip_pages; + continue; + } + bsize = read_blocklist(inode, index, &block); if (bsize == 0) goto skip_pages;