From patchwork Mon Jun 13 08:28:00 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: 12879163 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 7C6A2C433EF for ; Mon, 13 Jun 2022 08:28:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 13B2B6B0256; Mon, 13 Jun 2022 04:28:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 075EB6B0257; Mon, 13 Jun 2022 04:28:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E31AF6B0258; Mon, 13 Jun 2022 04:28:11 -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 CD4CB6B0256 for ; Mon, 13 Jun 2022 04:28:11 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9EE723539E for ; Mon, 13 Jun 2022 08:28:11 +0000 (UTC) X-FDA: 79572535182.14.D9ABCAF Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by imf20.hostedemail.com (Postfix) with ESMTP id 378501C007A for ; Mon, 13 Jun 2022 08:28:11 +0000 (UTC) Received: by mail-pl1-f181.google.com with SMTP id f9so4546241plg.0 for ; Mon, 13 Jun 2022 01:28:10 -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=TgHg0MUizrXjDF8ad/OqkO0qwgk0KXix4D6xsPRARVAZQlAAVWz859Q5ieKtHCft7k owKsPdbZEYtxyqYnHeIU8IAIdCNROBeYACaOkl4nTS6uw/qiohVmL9V9uZH5xuikS3NX PEStaXJRZSd/GQq4pxH8f4CRA4aaZEi55S070= 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=odmn/++JTVrSu3GcfSmi6MqvKoHWqVLnaSuIAF97ehmMlZg+W2vH+JPZwNCw5VjYI8 Vau3OA+hL5qq3m3IXstWw5coys5vE1zWKNH8ALDeK/1mrbSwBzbUOQuNsRyYdebkwlZr fVIO+vFbbyHL4JSJw2eswEXYGJ/ojWCFkAvh6Po8ujvzVt30yq6RFcwJ9eWfSlWhmtTv zuCeWKq8E4Jhu/IAxrJfRJEES5kdLcKtqiyplcGZ1T/uSXRa/Xlgl3oZdKoiMWaB/ktW CECSsltqOQFqxWFKbhEqkHYZuoGFTgAzTw2K3lT96A2RzSF3wrtgaL3FBD3UW/28y8bA bPcA== X-Gm-Message-State: AOAM532t9JlgdDVfC8uPu0i3oYtFdQCU4pdfFUz9QezVTi8VRV4PpTdU I7iyr2WYPI1Yj/XPXTuGpCKv66XXdEbAAQ== X-Google-Smtp-Source: ABdhPJwi2SCEgGhZ9I5onX8/zOrE1DLMbnkSlLcyHUO6ndmNQT89+0bno1W9+WZ49cCJAUst7NqxuA== X-Received: by 2002:a17:90b:1192:b0:1e2:da25:4095 with SMTP id gk18-20020a17090b119200b001e2da254095mr14274601pjb.240.1655108890190; Mon, 13 Jun 2022 01:28:10 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:79ca:e1d9:ad5:dc9e]) by smtp.gmail.com with ESMTPSA id br8-20020a056a00440800b00518a473265csm4624906pfb.217.2022.06.13.01.28.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jun 2022 01:28:09 -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 v6 1/3] Revert "squashfs: provide backing_dev_info in order to disable read-ahead" Date: Mon, 13 Jun 2022 16:28:00 +0800 Message-Id: <20220613082802.1301238-2-hsinyi@chromium.org> X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog In-Reply-To: <20220613082802.1301238-1-hsinyi@chromium.org> References: <20220613082802.1301238-1-hsinyi@chromium.org> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655108891; a=rsa-sha256; cv=none; b=fA6YblURM/+yxjZAqbiV+wWS/hcpptMRIV2F8xoG2wxsEYjvugCCdLjj32+pqAISElZ8Qv U+WnjYjFSfLE//gv0gUjNgEesLxo35mW+HHED5w8dT1naYNKOyMXBIWufPIvheYIpinUWV wqUc8/nRPj7aoPXqWGKtgH8djBG2tTU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655108891; 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=DW6+1laE45TZFRWNJOxmL/iJCE7VwOMhgGeRxaBi+ePXfQhH4ojLGziu3VxhTRXPOgyNCD 4ZfMosJG4TgmizoXSU5xTiFoDFNLTsYM1LYPFL94vr5RbPvkB0j6FU2j7fjcI4ccKzZKC1 7j538vTuXLWu0onivj+aKcGXBoXGMms= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=TgHg0MUi; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf20.hostedemail.com: domain of hsinyi@chromium.org designates 209.85.214.181 as permitted sender) smtp.mailfrom=hsinyi@chromium.org Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=TgHg0MUi; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf20.hostedemail.com: domain of hsinyi@chromium.org designates 209.85.214.181 as permitted sender) smtp.mailfrom=hsinyi@chromium.org X-Stat-Signature: 5qzxfxyk1h83i8tmznbmztfzm58gjwhh X-Rspamd-Queue-Id: 378501C007A X-Rspamd-Server: rspam12 X-Rspam-User: X-HE-Tag: 1655108891-484523 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 Mon Jun 13 08:28:01 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: 12879164 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 0FB75C433EF for ; Mon, 13 Jun 2022 08:28:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9EEE08D0142; Mon, 13 Jun 2022 04:28:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 94EDC6B0259; Mon, 13 Jun 2022 04:28:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C87D8D0142; Mon, 13 Jun 2022 04:28:14 -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 677BB6B0258 for ; Mon, 13 Jun 2022 04:28:14 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3E971344D3 for ; Mon, 13 Jun 2022 08:28:14 +0000 (UTC) X-FDA: 79572535308.20.A133961 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by imf30.hostedemail.com (Postfix) with ESMTP id D774F80088 for ; Mon, 13 Jun 2022 08:28:13 +0000 (UTC) Received: by mail-pj1-f54.google.com with SMTP id k12-20020a17090a404c00b001eaabc1fe5dso2275078pjg.1 for ; Mon, 13 Jun 2022 01:28: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=PWjwYzB1HNf+oPRDU2wDyWSO4j3cyp8KqyrOSYFXeuM=; b=R43F9PSPlNS3+j0fw+D4qLkyB2pNxxG+Kf9qvBKMGRcozIpC9qYPH9m/kxTrduFUZt Get7ZtYXGMS0lblH3PECs6OSbjvJQAeSIxK8WwtonC7AjhgAC8AMUSGLtH6Qo3XUmCbu CtNNhK/b0kQt0+tvXslyUKS2nSNroZsDd6aJs= 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=PWjwYzB1HNf+oPRDU2wDyWSO4j3cyp8KqyrOSYFXeuM=; b=MpjUtQoj207CZCh9wP+yW3qJJFZq2GVGDAJsmW8y/vrYnei2fpCiikodL9Et+JqCuH 1bHzVtXYNDn+Fa1IH/IIjgEQlorieip1QwzlYBrGqkfNXXUHZlkvIyVlKRHD3x+85tgz oQO0TawD0oD3nnMCj/0M0dxfSBny+kJA3QQ7cXBVU6CTvcKVenIXO+VkDXXvJIH/pmHS meEATz4/XE1Qj9zSlBmkXm65aHm72xO2WvBxGLVq+qJmu2X4PWF+Q/32Kmf11m65SrrR F2rjid+HD1sst+9VdZICde35/v1B2XJ727D22/SQ9Jkk3FLu9qS8L0SppRHDFDugapY0 k9tA== X-Gm-Message-State: AOAM530HJO9wdN3QkjXKNQo/oQJ1/UPY43r6i30BNiCf3iz3f5gXcLDa DLLb25IGL7oATeCek1WfemMVcA== X-Google-Smtp-Source: ABdhPJxGVyS1PPoBilRK9Z+DXulNdhuOawyV0hnMEGPXO44wPhWnP2DXLm8oOQeYEhn1M78QwqZJFg== X-Received: by 2002:a17:902:7e84:b0:166:395c:4b68 with SMTP id z4-20020a1709027e8400b00166395c4b68mr58667443pla.8.1655108892769; Mon, 13 Jun 2022 01:28:12 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:79ca:e1d9:ad5:dc9e]) by smtp.gmail.com with ESMTPSA id br8-20020a056a00440800b00518a473265csm4624906pfb.217.2022.06.13.01.28.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jun 2022 01:28: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 v6 2/3] squashfs: always build "file direct" version of page actor Date: Mon, 13 Jun 2022 16:28:01 +0800 Message-Id: <20220613082802.1301238-3-hsinyi@chromium.org> X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog In-Reply-To: <20220613082802.1301238-1-hsinyi@chromium.org> References: <20220613082802.1301238-1-hsinyi@chromium.org> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655108894; a=rsa-sha256; cv=none; b=3iy1eTT9GlVGiNVPi3do0JrH4+opJQZjuh95ycpyT5nJk49PSsr8L3mv8j3WyQ4hJHLLt6 aPkljfpFhNo1LRbaJ4PgAgoKnf3ArVPMKAAiTt2H6d8kgKlSLjqGqIl5F40xhBlNRA77ji Pml99Y2m9cE1sD0HKbhvMyQBTejT1JI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655108894; 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=PWjwYzB1HNf+oPRDU2wDyWSO4j3cyp8KqyrOSYFXeuM=; b=YPDP62jrz6UNmYdYAU3AHKLpMEnN2SEVeShfOQeM4Q0DiR5rkinSXCtRnJLv/E16nsxFOp H1efVByHN3lWvy6ASilSN+cNPIqwulhmeKtcE8MklSDASLOTTjClrHkoyizRdibX5bOP8d 0v2rIOEvOe9qWopDlN5pO7zy5hUzc2I= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=R43F9PSP; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf30.hostedemail.com: domain of hsinyi@chromium.org designates 209.85.216.54 as permitted sender) smtp.mailfrom=hsinyi@chromium.org Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=R43F9PSP; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf30.hostedemail.com: domain of hsinyi@chromium.org designates 209.85.216.54 as permitted sender) smtp.mailfrom=hsinyi@chromium.org X-Stat-Signature: 5sa55x54nabhqqpwe8ahwwk6os5sj5e9 X-Rspamd-Queue-Id: D774F80088 X-Rspamd-Server: rspam12 X-Rspam-User: X-HE-Tag: 1655108893-910711 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 --- v5->v6: rebase content on top of the dependent series. --- 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 Mon Jun 13 08:28:02 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: 12879171 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 E7359C433EF for ; Mon, 13 Jun 2022 08:28:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 818958D0169; Mon, 13 Jun 2022 04:28:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A0DA6B025B; Mon, 13 Jun 2022 04:28:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 61AE68D0169; Mon, 13 Jun 2022 04:28:27 -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 4C4C86B025A for ; Mon, 13 Jun 2022 04:28:27 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2CE5120E5D for ; Mon, 13 Jun 2022 08:28:27 +0000 (UTC) X-FDA: 79572535854.29.9F00D54 Received: from mail-vs1-f46.google.com (mail-vs1-f46.google.com [209.85.217.46]) by imf16.hostedemail.com (Postfix) with ESMTP id CE9F3180088 for ; Mon, 13 Jun 2022 08:28:26 +0000 (UTC) Received: by mail-vs1-f46.google.com with SMTP id x9so5155195vsg.13 for ; Mon, 13 Jun 2022 01:28:26 -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=ykDR2Uk4CbOQ3wM0PXuQC4oxDGLqvfs6LYo+jnOevDY=; b=iBEsynkrqKiDNFcZ/2PPp1KD827bEZaQ/fOYwNHs93fW8/auD7Uf41sOsHATyyeNgu v4qiBS0sWa2faVOaBotB267Qu1DkblzSW3vCivrWnXT0Lg4RmDx1p1XW/fyBzBH98cz/ k0ud7NQUACMOVgBADm0y8FMttNspzpifAnudU= 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=ykDR2Uk4CbOQ3wM0PXuQC4oxDGLqvfs6LYo+jnOevDY=; b=ctZdWQFeCUeccMxB6d3a12znUPNSIjKxHoXYkyKfJ1Kb+otEOEozwWEA/Q5BEgpt4/ 4k511Ls8OE63/CXWWfkhDzpXw8dKUNyWgcNIlL+R0QVq2sxMQxIeSGFG76VtOzZKiC+x oQtOJPVJ/vAW/ONXVplvFtGAjLKuImllH/Jgm9lVEV+Ne1k6+BMUWHxk+/pZDTlMCi2r hHiuew8FyPKmsWfYpbdbbHep/PqY9hK2PAINzqUusmGj3GoEEfb9/+4VdARQi6EksYht yACUnGUspqbZ3/aW0+Z50o/4Xo8TM80UaduNsCKfBeYdhlAqrKj/oNSN/vq/Ic7JYDDM WsuA== X-Gm-Message-State: AOAM531kBbwmKB6XUWj032/O7g5Hau9Jlv5b8PowoHDiB9KKt4o8I0/V uXo8YvABz722pGn+9TT/rXcAoVKtavdbYQ== X-Google-Smtp-Source: ABdhPJygjTGKX6O7iWUY8qOD+wjhd0VACZB/J2Z7QNA2jWpF+iXgT4YvK1K2bcNxt+9/tu+2hettsA== X-Received: by 2002:a05:6a00:2341:b0:51b:dd96:c7c1 with SMTP id j1-20020a056a00234100b0051bdd96c7c1mr53913886pfj.14.1655108895352; Mon, 13 Jun 2022 01:28:15 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:79ca:e1d9:ad5:dc9e]) by smtp.gmail.com with ESMTPSA id br8-20020a056a00440800b00518a473265csm4624906pfb.217.2022.06.13.01.28.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jun 2022 01:28:14 -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 v6 3/3] squashfs: implement readahead Date: Mon, 13 Jun 2022 16:28:02 +0800 Message-Id: <20220613082802.1301238-4-hsinyi@chromium.org> X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog In-Reply-To: <20220613082802.1301238-1-hsinyi@chromium.org> References: <20220613082802.1301238-1-hsinyi@chromium.org> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655108906; a=rsa-sha256; cv=none; b=krmZ3r//HD6sB1nl+RPJJOV5ge1SeDm7IWavaP7Ay+1wDx/GZ7V06g0BzpBN1aa/HZ3KbU qYVZrq7OvQKKM+cd8aJ8KPUuL9gnL89NrlMlY80Vx0Kvsl6Ej10oXnfCaepCRjrKylKmya /Mr3pT7eLoqRyGmHozZw0C9NH6yWBKc= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=iBEsynkr; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf16.hostedemail.com: domain of hsinyi@chromium.org designates 209.85.217.46 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=1655108906; 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=ykDR2Uk4CbOQ3wM0PXuQC4oxDGLqvfs6LYo+jnOevDY=; b=7Vs86GwG4CELLXkQ1mCqDkVqIaK/Wh33oetRTS2NWUQviZfUz2XUbMH3ISXNVabCZASswD edpX64C9rfhuGT/ZGZQztohaBBE6xRrO0WRvNJLL77fvD/pAhddDAwiv1xL3o7a6X3Icju MUnXlh1P/geXmr4E3glDYQbZjAP4u4M= X-Stat-Signature: adx3tszxkr7o5816689zajhy8ucofwfq X-Rspam-User: X-Rspamd-Queue-Id: CE9F3180088 X-Rspamd-Server: rspam07 Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=iBEsynkr; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf16.hostedemail.com: domain of hsinyi@chromium.org designates 209.85.217.46 as permitted sender) smtp.mailfrom=hsinyi@chromium.org X-HE-Tag: 1655108906-523876 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 --- v5->v6: - use the new squashfs_page_actor_init_special() to handle short file cases as well. - use memzero_page(). v5: https://lore.kernel.org/lkml/20220606150305.1883410-4-hsinyi@chromium.org/ 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 | 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 };