Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4960723rdb; Fri, 15 Sep 2023 19:21:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFDyFLZi41l352O/04eCBxc9ot4ez4IvHPTDJA80ddX/+XMBw6gSjyQEs/1h6IUbnWTYbf9 X-Received: by 2002:a05:6a20:8404:b0:12e:caac:f263 with SMTP id c4-20020a056a20840400b0012ecaacf263mr4703994pzd.20.1694830904821; Fri, 15 Sep 2023 19:21:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694830904; cv=none; d=google.com; s=arc-20160816; b=rqmL2yHRwVQfjQtT9ZgoBlu+UsRtDlp2QzUooKFPrg5Iy7eHn6xHD4S7Q71Xriz7rf 83plRENeal6EjN5sSiQdHBrpHSjaif3uvFxCmqfqwrEpv9zv4CxBGWzT2YsTx2H8DN/p X0dsDHHfO146BcPEgGfdLOXZGETPoKyz0q67g1cFGQ9oT5UXItHv65dOcWAuTn9Wv4h3 rRBVsKOz4RMfqrs5xx0GOEX56eQUU75IES0L0UtvFBUi9Vo6PcYyV1WSQclvKEFGXCoJ WdzSyCiHgWltrqSX6QomDs6WrAhGdWNL6STwpfwu5XEOQ0ATHjuyt1S0WinP0u1GYCtz I8Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=v1ROluVJSO7Og0x78gpfVtBYiLqeXgpCBUoOyNe/wDk=; fh=kl+S4GAUWD1kOeoqBopscteh2mu3DZslcHc01dOJ6TI=; b=V0nbtxCJI6WPei7T6O5OItSxt34R63XjEkOR8m1lQ20Wik/bvu3FBqoHLcrPmyPOO6 A1xw3ajT4JQpW45WR7mWg3VTZB/4/3qT4jTwjbgwRGiWQ+40BvQB7PO+s0Z6TV4SBIzT lKr4ju8dfi3abWZ099RUAASuSA8SZiHri7mKni2Vb7io0rJWPWmAcHivktGIzZjgApVU HkX+sj+RqXpQ43CRrkM8uhZ5zSBAbnN1R11v/whk7YCsvwk4goeXkU7rpoo2QhitCOiL JQOZnOFD/HsiBTrvFt3M3CtgGa9prRvzFqns3jJB9F2FON1Bq5hBOJqJ9/W50R7ww5of 3Mow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pankajraghav.com header.s=MBO0001 header.b=gScikhRf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id j63-20020a638b42000000b00578251aa71bsi1849399pge.57.2023.09.15.19.21.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 19:21:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@pankajraghav.com header.s=MBO0001 header.b=gScikhRf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 586F580879F0; Fri, 15 Sep 2023 11:41:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236801AbjIOSlE (ORCPT + 99 others); Fri, 15 Sep 2023 14:41:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236766AbjIOSka (ORCPT ); Fri, 15 Sep 2023 14:40:30 -0400 Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [80.241.56.161]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 350D346B7; Fri, 15 Sep 2023 11:39:09 -0700 (PDT) Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4RnNJB14wvz9spX; Fri, 15 Sep 2023 20:39:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803146; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v1ROluVJSO7Og0x78gpfVtBYiLqeXgpCBUoOyNe/wDk=; b=gScikhRfoSfUAACxzO+p12H84XzAf0M/1y/sXgTZwi/SgPURdSIOMvREaunNOLzkA85V5k CkYo7Lcirhjq/rxs9lLFIlbq+saLu5YE4wAsu553hUQgaAdLpnd6lWIJPRf79Do52gShSl MApjJ5VYI5gdB2GmwbCQdVfYyscSdpvjxz/UD/mMTo3yWb5Oo9lRMwslcX/s5/Dme/ByaM pvoVjRe/LuOWXOvQ4z+1rMTn2nLNkOeteypbQeBaG7pl4lV2R9pYHLCIU7ryNihhJRCQKb P/Zo3IhJskWPDN4dnUQANxUvg31hX/f2ObFgnkjEJb2nLswBC4EENX4tks9G3g== From: Pankaj Raghav To: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: p.raghav@samsung.com, david@fromorbit.com, da.gomez@samsung.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, willy@infradead.org, djwong@kernel.org, linux-mm@kvack.org, chandan.babu@oracle.com, mcgrof@kernel.org, gost.dev@samsung.com Subject: [RFC 05/23] filemap: align index to mapping_min_order in filemap_range_has_page() Date: Fri, 15 Sep 2023 20:38:30 +0200 Message-Id: <20230915183848.1018717-6-kernel@pankajraghav.com> In-Reply-To: <20230915183848.1018717-1-kernel@pankajraghav.com> References: <20230915183848.1018717-1-kernel@pankajraghav.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4RnNJB14wvz9spX X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 15 Sep 2023 11:41:35 -0700 (PDT) From: Luis Chamberlain page cache is mapping min_folio_order aligned. Use mapping min_folio_order to align the start_byte and end_byte in filemap_range_has_page(). Signed-off-by: Luis Chamberlain --- mm/filemap.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 2c47729dc8b0..4dee24b5b61c 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -477,9 +477,12 @@ EXPORT_SYMBOL(filemap_flush); bool filemap_range_has_page(struct address_space *mapping, loff_t start_byte, loff_t end_byte) { + unsigned int min_order = mapping_min_folio_order(mapping); + unsigned int nrpages = 1UL << min_order; + pgoff_t index = round_down(start_byte >> PAGE_SHIFT, nrpages); struct folio *folio; - XA_STATE(xas, &mapping->i_pages, start_byte >> PAGE_SHIFT); - pgoff_t max = end_byte >> PAGE_SHIFT; + XA_STATE(xas, &mapping->i_pages, index); + pgoff_t max = round_down(end_byte >> PAGE_SHIFT, nrpages); if (end_byte < start_byte) return false; -- 2.40.1