From patchwork Fri Sep 15 18:38:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pankaj Raghav (Samsung)" X-Patchwork-Id: 13387466 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 BAE49EED61E for ; Fri, 15 Sep 2023 18:39:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 509F46B03B7; Fri, 15 Sep 2023 14:39:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 492F46B03B8; Fri, 15 Sep 2023 14:39:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 333426B03B9; Fri, 15 Sep 2023 14:39:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 1EA0B6B03B7 for ; Fri, 15 Sep 2023 14:39:11 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D7D5A80786 for ; Fri, 15 Sep 2023 18:39:10 +0000 (UTC) X-FDA: 81239694060.21.8B5C02B Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [80.241.56.161]) by imf12.hostedemail.com (Postfix) with ESMTP id 3E61E4000B for ; Fri, 15 Sep 2023 18:39:08 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=gScikhRf; dmarc=none; spf=pass (imf12.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.161 as permitted sender) smtp.mailfrom=me@pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694803149; a=rsa-sha256; cv=none; b=Piw4Zwqs53WUI/+QdlUoLlXbAf4p/bU61dHaE+GUr4OTblMVnnXyv2QlEkGzfzRa6BIf4P l30VzSnPtS/tKjZztvvhZPd+mqOnh1il4Mh/ffQOXxGlgWWz84DW8k1o0XYxzHi4+swUmt 1XbCyLqKT5epcLn+TNKQEsq7JLVhWdI= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=gScikhRf; dmarc=none; spf=pass (imf12.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.161 as permitted sender) smtp.mailfrom=me@pankajraghav.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694803149; 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=v1ROluVJSO7Og0x78gpfVtBYiLqeXgpCBUoOyNe/wDk=; b=da7T4sDHFmNrhj5GwOnR0oVVXxXZc1SJo110VJANol53WHJIfrSYPKMNnkQXyg8wQ8dfO/ D8Bg4XEJPlkOLmljZQambrhG9sM5QqvDuEvjb9kJmFMuzJ9XYNNy1ueW3SroTLK+hSjdPd iSXX1xn9KnhmOlO4T7n0sOxLgvZET58= 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 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 3E61E4000B X-Stat-Signature: xj6g3socm9u4e8gguwk9tq399s44s5cq X-HE-Tag: 1694803148-915057 X-HE-Meta: U2FsdGVkX18aAe6vRy1FYcpQQPpXiZFC3aBMLGqgUAzk0cJ+NBdtViC8N8mkI1T7jr+sAjtEcZ4knSnPV+k0Lyw5oPTp4dDUXXSlnGMaXYDcNq/lDZeX1vMmZ1FMeexV9jCa53s7KJBR2Gxiy7uHxe13Z6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1mxiTiKc4QuFbYn3MCnGx3j9ci1VaNeiAvrZ1PC26Mxm+dzIzi3jNSJfDE9xWC0L6onLhtNaqM8I/9E466ncWnUwl0B9JgIiCGaofw0ORDP1BLXg2D52hoUtIlZkFQoT7qSYlMYrWkos7/9D0QjwqmSxsAthxXThMOGrXUJXVCAEfgwUsKOeQZyhLY2a 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: 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;