Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2958853iob; Mon, 16 May 2022 09:50:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7NLOUFU7wnWE/jq2YXc23N2JajNjZYDGR79wikc4GHEvDdwW3q3nJXEa7cdd1ya5rJ9cY X-Received: by 2002:a05:6402:1cc1:b0:413:2b12:fc49 with SMTP id ds1-20020a0564021cc100b004132b12fc49mr14138679edb.118.1652719848080; Mon, 16 May 2022 09:50:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652719848; cv=none; d=google.com; s=arc-20160816; b=E23e32RIbfzy41NaEXx4S65CsRkhoWEICoRay2//HTurP2NGHyI2cH2cYzp90iVkso IZLaSv+j6IpLtTlK+yosGCvXAOqQpldnNWB52PImt4gdnvDB9JhO41ztms/3qmxpZW/8 PYM3WbkZCccjdaVK7laScYv437bCKEdPVoQ3PC+L/hY5TURe56DZ3n9t0Nw3M2AGtFsU 62zVx9lY6WxZUXx/0xTLyzwsC83Tt+pj08hLX76ZQIt666AIu4BzrghVARFjPHj3DsRZ ROaOTLqvKWPC8sZU7FRgkvNPZwVO2Gi8mE9P4enr8U90on65v9g4uZvN9nAv1IKVhdM1 KceQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=beBrIscqgy/0uR/o+DxDTi2opTq7h59zNaTA5248BaE=; b=fwIH+dGkn95vvG/+OtOd58xR6celT32/L3p5zLVi+V0cGeSX+W4EZZePrVsMG3PZzv JwoESuzAD2jpeZLW3tfLFvBD4UyzsSTrAYm05xvsCztA30yhlk6Ug7t8j+rhG2vDbmXK az7G1QLdATQpAb/jplm1/9WE33i273yJwsmYwWs5JENKCDMYYdB0dgtnb842IjP18gq3 mtEaWHhkF4592e1+FW35Wzgd4hMe3ZF62sCigL2AZRJ+eT9C4jnz7PUoDLJZOSWuN1HP TgqVsm3y2aZl3JarMUKasWX1TUCWITAsZqjDkJt+GEZeifv8+nwsaGQ8IrCc0ug8V6YA FntA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=cO6FBmkT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h1-20020a0564020e8100b0042ab87c1eeesi1905933eda.475.2022.05.16.09.50.22; Mon, 16 May 2022 09:50:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=cO6FBmkT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243604AbiEPM4v (ORCPT + 99 others); Mon, 16 May 2022 08:56:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243891AbiEPM4E (ORCPT ); Mon, 16 May 2022 08:56:04 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EB8C38BE4 for ; Mon, 16 May 2022 05:55:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=beBrIscqgy/0uR/o+DxDTi2opTq7h59zNaTA5248BaE=; b=cO6FBmkT8y7IKKung2vpOoIQ5k 7oOqh/CYnFPlnrU1EfIvPKMMRYCfHUNrp+7WbU3R72a4bEDHzoZlyVdwo8TF+7+VIz/8amLZBTKGV QeMJJwfl5Y5/9RDq362odnkReBqFLN8g8Yi4qs7+NBJdR3DbbowtGGj73pAq+hZP6IzTisv/seGF9 VYEjTKO/fJ6jX9hpEHz6iMwSxpwQ9NdL3QgV27N4fQ4O8BIkeE3Hx7/8EybgwipWcPjrUklCEu86N MPPSZz1FSuISFDZYMmi2zwZNQDhzLaImM0nX+2F9auL5AwD3M7Wli7Dyz6RURKO4RR550eZ101FAe iFv1tLlA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqaFx-009tNO-NU; Mon, 16 May 2022 12:55:25 +0000 Date: Mon, 16 May 2022 13:55:25 +0100 From: Matthew Wilcox To: Hsin-Yi Wang Cc: Phillip Lougher , Xiongwei Song , 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: Re: [PATCH 2/2] squashfs: implement readahead Message-ID: References: <20220516105100.1412740-1-hsinyi@chromium.org> <20220516105100.1412740-3-hsinyi@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 16, 2022 at 08:47:52PM +0800, Hsin-Yi Wang wrote: > On Mon, May 16, 2022 at 8:36 PM Matthew Wilcox wrote: > > > > On Mon, May 16, 2022 at 07:04:08PM +0800, Hsin-Yi Wang wrote: > > > > + loff_t req_end = readahead_pos(ractl) + readahead_length(ractl); > > > > + 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; > > > > + u64 block = 0; > > > > + int bsize, res, i, index; > > > > + int file_end = i_size_read(inode) >> msblk->block_log; > > > > + unsigned int max_pages = 1UL << shift; > > > > + > > > > + readahead_expand(ractl, start, (len | mask) + 1); > > > > + > > > > + if (readahead_pos(ractl) + readahead_length(ractl) < req_end || > > > > + file_end == 0) > > > > + return; > > > > What's the first half of this condition supposed to be checking for? > > It seems to be checking whether readahead_expand() shrunk the range > > covered by the ractl, but readahead_expand() never does that, so I'm > > confused why you're checking for it. > > hi Matthew, > > This is to check if readahead_expand() expands as much as it's requested. > I didn't encounter the mismatch so far in my testing. If this check is > not necessary, it can be removed. Then I think req_end is miscalculated? It should surely be: req_end = start + (len | mask) + 1; But I'm not sure that we should be failing under such circumstances. For example, we may have been asked to read 1.5MB, attempt to round up to 2MB, and fail. But we can still submit a readahead for the first 1MB, before leaving the second 512kB for readpage to handle. So maybe we should just remove this check entirely.