From mboxrd@z Thu Jan 1 00:00:00 1970 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 C3039C4332F for ; Wed, 12 Oct 2022 00:21:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E66C900003; Tue, 11 Oct 2022 20:21:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 29638900002; Tue, 11 Oct 2022 20:21:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 13787900003; Tue, 11 Oct 2022 20:21:23 -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 0253C900002 for ; Tue, 11 Oct 2022 20:21:22 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id C39EF801CB for ; Wed, 12 Oct 2022 00:21:22 +0000 (UTC) X-FDA: 80010393204.14.DDE1C0C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf20.hostedemail.com (Postfix) with ESMTP id 5127A1C0035 for ; Wed, 12 Oct 2022 00:21:22 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 463FE61248; Wed, 12 Oct 2022 00:21:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80175C433D6; Wed, 12 Oct 2022 00:21:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1665534080; bh=AX9kUFUlah6MBBDV2ZA6IkEQk1cpIC4nteSoj08vbH4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=1D5XzC6ueJJO1v1ueQRvfrFpxNnNooOEZBmT6w7lq8fHdf6XoFUeBnyUeo+4nG+bw H/VQiFfv+n+CJvkBl9xQQSeoj2gJQ7Rx9kv/D38yCD9mu/EtzJ/x6TdqhgTMn0XHhR JLy6sTmJyN8NlfoNd0xgXjHDEXKYYoxLXr1JM+k4= Date: Tue, 11 Oct 2022 17:21:19 -0700 From: Andrew Morton To: nicememory@gmail.com Cc: bugzilla-daemon@kernel.org, Matthew Wilcox , linux-mm@kvack.org Subject: Re: [Bug 216570] New: Pass wrong index value to DEFINE_READAHEAD which leads to almost no readahead of fsverity data Message-Id: <20221011172119.00ee0ce1cbd82fbb6f83ce1e@linux-foundation.org> In-Reply-To: References: X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665534082; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=bb+lK9vjUsaHP0UCLlmJ5RSr7h06dahrzwk7dSDPD5w=; b=jr8azhfZHsKEXUa3PYDa4xDNzM/wVNVszjdsZOVFb5lXv81TWKXw+o90u7Ur9K08YrHJAY 3pQ9hPTtP+BbsbJM0SpEEqGCrP29VkrkOKlVC5JzpuTpRLv+mlaKeRbh9bQoE3ZlE0FOco wKGu2yqZwbp6SywI0QQMWhqTwXpMAUA= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=1D5XzC6u; spf=pass (imf20.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665534082; a=rsa-sha256; cv=none; b=2sBng12gJBK0ipOhnSo2A6OUA4JnbHjcu6gdrKIDdM4cZRQl9ZPle5SH4cVvYW69fcruuD LFMvTDCtDdbUzMOu9IfAv3C9tP9ScLEQouzSFkT+VYXcqayIXi4ck0rgFfnTlJwalI6khC qIHRbgmopbM9ASQDItE0QODy9+GXN84= X-Rspam-User: X-Rspamd-Server: rspam11 Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=1D5XzC6u; spf=pass (imf20.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Stat-Signature: x34x56w4y3tm4eb77jesggagwc74eenq X-Rspamd-Queue-Id: 5127A1C0035 X-HE-Tag: 1665534082-301847 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: (switched to email. Please respond via emailed reply-to-all, not via the bugzilla web interface). On Tue, 11 Oct 2022 06:52:49 +0000 bugzilla-daemon@kernel.org wrote: > https://bugzilla.kernel.org/show_bug.cgi?id=216570 > > Bug ID: 216570 > Summary: Pass wrong index value to DEFINE_READAHEAD which leads > to almost no readahead of fsverity data > Product: Memory Management > Version: 2.5 > Kernel Version: 6.0 > Hardware: All > OS: Linux > Tree: Mainline > Status: NEW > Severity: low > Priority: P1 > Component: Other > Assignee: akpm@linux-foundation.org > Reporter: nicememory@gmail.com > Regression: No > > It was introduced by commit 73bb49da50cd460bb3ba31250ed2e7fbf2115edf > > In function ext4_read_merkle_tree_page and f2fs_read_merkle_tree_page, > parameter index was added by a offset and then passed to > page_cache_readahead_unbounded. > For now, index is passed to DEFINE_READAHEAD directly with wrong value. oops, yes, thanks. Matthew, could you please take a look? > > Possible fix is not changing the value of parameter index and defining a new > local variable ra_index to replace all the other reference to index. Like: > > static struct page *ext4_read_merkle_tree_page(struct inode *inode, > pgoff_t index, > unsigned long num_ra_pages) > { > pgoff_t ra_index = index + ext4_verity_metadata_pos(inode) >> > PAGE_SHIFT; > DEFINE_READAHEAD(ractl, NULL, NULL, inode->i_mapping, ra_index); > struct page *page; > > page = find_get_page_flags(inode->i_mapping, ra_index, FGP_ACCESSED); > if (!page || !PageUptodate(page)) { > if (page) > put_page(page); > else if (num_ra_pages > 1) > page_cache_ra_unbounded(&ractl, num_ra_pages, 0); > page = read_mapping_page(inode->i_mapping, ra_index, NULL); > } > return page; > } > > > static struct page *f2fs_read_merkle_tree_page(struct inode *inode, > pgoff_t index, > unsigned long num_ra_pages) > { > pgoff_t ra_index = index + f2fs_verity_metadata_pos(inode) >> > PAGE_SHIFT; > DEFINE_READAHEAD(ractl, NULL, NULL, inode->i_mapping, ra_index); > struct page *page; > > page = find_get_page_flags(inode->i_mapping, ra_index, FGP_ACCESSED); > if (!page || !PageUptodate(page)) { > if (page) > put_page(page); > else if (num_ra_pages > 1) > page_cache_ra_unbounded(&ractl, num_ra_pages, 0); > page = read_mapping_page(inode->i_mapping, ra_index, NULL); > } > return page; > } >