From patchwork Wed Oct 12 19:34:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13005394 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 1E978C4332F for ; Wed, 12 Oct 2022 19:34:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 752016B0071; Wed, 12 Oct 2022 15:34:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 700EA900002; Wed, 12 Oct 2022 15:34:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5A3856B0074; Wed, 12 Oct 2022 15:34:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 48D206B0071 for ; Wed, 12 Oct 2022 15:34:27 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 0FA5E1C61AF for ; Wed, 12 Oct 2022 19:34:27 +0000 (UTC) X-FDA: 80013298974.22.D130335 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf14.hostedemail.com (Postfix) with ESMTP id 2E32E10001E for ; Wed, 12 Oct 2022 19:34:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=ZnDh0S+VifpcdcEivU96CcKngiFDkREJBVwGl9Kvr0g=; b=rk6EBEy+DeIf89AEKn6uhCBttR RzyQVyFOEQbmv5zA9l6UqJh5fq8iTbMHqTJTSUpbHMPr6Nj5p7nGWGtXT57pXwb21q1A5m3vVIEz6 vwm/r8LvWb1DsCBupC+F17Wvz8Wgc3jE5/R91YSIV2qoeE6rrc22568wOjNg4JbkFHVytX3SgI2pM C7uXEfDrFG3OO26tlevHeoWiYLCbB07BG+E+qmorQFSwW+Ay9P3Iv92Qfg37j8mwrMyAr6s3ZXXXk EsZxJYKQoh4gAdcP2rLsSlOdQMLOUU0CEADXJ4xCuf2+b+dpP66yFmGnK7sIsv2SYDK6PXVGcnH8a E5ruW1dQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oihUm-0066EX-RW; Wed, 12 Oct 2022 19:34:24 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, Andrew Morton Cc: "Matthew Wilcox (Oracle)" , Jintao Yin Subject: [PATCH] ext4,f2fs: Fix readahead of verity data Date: Wed, 12 Oct 2022 20:34:19 +0100 Message-Id: <20221012193419.1453558-1-willy@infradead.org> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665603266; 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:references:dkim-signature; bh=ZnDh0S+VifpcdcEivU96CcKngiFDkREJBVwGl9Kvr0g=; b=Rv6XRmvw4SmCt6JHhQ7cC5kxYAFdpQGc0CI1xWFTfdDDk7nL9nYAZDdNqEwUAssqzlqOfN eFz0xP3d67bCACVcL8A2ULVbp2XUo4oSw+P4xFM7fv9JhgI7vFllhU3FVYxmvRafpkLs8u c0rYfpIaECy/vvoSmuXbFMeBMaxBGtg= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=rk6EBEy+; dmarc=none; spf=none (imf14.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665603266; a=rsa-sha256; cv=none; b=7V5ocs6r2K/DELFCbvewGkBs0Z5YXjYvKCmUf2mvLxGk5ZM2L+Ftdjb5CtPFdYA7g6VPGs DITMzSZ+ZTPde54EMZZHS20luGLqaJrs/zXRIPU6881HmZQQ8kjcde7Xqfb7Z6XLEA4rUA Mzbdvvv/2dZY0yaoEb3ZHS7En4EFc+8= X-Stat-Signature: kazbn8kctfoh6disyg1ipff8se1a6mnp X-Rspamd-Queue-Id: 2E32E10001E Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=rk6EBEy+; dmarc=none; spf=none (imf14.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1665603264-59436 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: The recent change of page_cache_ra_unbounded() arguments was buggy in the two callers, causing us to readahead the wrong pages. Move the definition of ractl down to after the index is set correctly. This affected performance on configurations that use fs-verity. Fixes: 73bb49da50cd ("mm/readahead: make page_cache_ra_unbounded take a readahead_control") Reported-by: Jintao Yin Signed-off-by: Matthew Wilcox (Oracle) --- fs/ext4/verity.c | 3 ++- fs/f2fs/verity.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/ext4/verity.c b/fs/ext4/verity.c index 20cadfb740dc..3c640bd7ecae 100644 --- a/fs/ext4/verity.c +++ b/fs/ext4/verity.c @@ -363,13 +363,14 @@ static struct page *ext4_read_merkle_tree_page(struct inode *inode, pgoff_t index, unsigned long num_ra_pages) { - DEFINE_READAHEAD(ractl, NULL, NULL, inode->i_mapping, index); struct page *page; index += ext4_verity_metadata_pos(inode) >> PAGE_SHIFT; page = find_get_page_flags(inode->i_mapping, index, FGP_ACCESSED); if (!page || !PageUptodate(page)) { + DEFINE_READAHEAD(ractl, NULL, NULL, inode->i_mapping, index); + if (page) put_page(page); else if (num_ra_pages > 1) diff --git a/fs/f2fs/verity.c b/fs/f2fs/verity.c index f0805e51b3fe..c352fff88a5e 100644 --- a/fs/f2fs/verity.c +++ b/fs/f2fs/verity.c @@ -258,13 +258,14 @@ static struct page *f2fs_read_merkle_tree_page(struct inode *inode, pgoff_t index, unsigned long num_ra_pages) { - DEFINE_READAHEAD(ractl, NULL, NULL, inode->i_mapping, index); struct page *page; index += f2fs_verity_metadata_pos(inode) >> PAGE_SHIFT; page = find_get_page_flags(inode->i_mapping, index, FGP_ACCESSED); if (!page || !PageUptodate(page)) { + DEFINE_READAHEAD(ractl, NULL, NULL, inode->i_mapping, index); + if (page) put_page(page); else if (num_ra_pages > 1)