From patchwork Wed Feb 28 18:22:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13575819 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 274A7C54E41 for ; Wed, 28 Feb 2024 18:22:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC0E56B00AC; Wed, 28 Feb 2024 13:22:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A65FD6B00AB; Wed, 28 Feb 2024 13:22:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 86B8B6B00AC; Wed, 28 Feb 2024 13:22:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 6E7C76B00AA for ; Wed, 28 Feb 2024 13:22:42 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id CAA9C4117D for ; Wed, 28 Feb 2024 18:22:41 +0000 (UTC) X-FDA: 81842033322.08.CECA22D Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf22.hostedemail.com (Postfix) with ESMTP id 4737BC0021 for ; Wed, 28 Feb 2024 18:22:40 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=pFm81e4b; dmarc=none; spf=none (imf22.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709144560; 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=zyLVkLIMvfYhi7iymKpQZImO3Ib0JWZlKPrLFkzRDOc=; b=yD2VI6XASkOYSlRRD8Qg7NP6NsDhenhLUOPZHq1jo4fWM0ik/H++DCv5/NcjNnSglTX4TE JmCUP8CkPVoedlJOSNYSBi0i9xQyKIzRbo08CgoPY+r1yGtag6ghov/YD0picwRszRW0eo 3l/yghoRr4u0WfjpbCtglwa77cU2Jug= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=pFm81e4b; dmarc=none; spf=none (imf22.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=1709144560; a=rsa-sha256; cv=none; b=fv0ZocvTkbpXNwRqAxySKZoL4bOqaGqkvrJW95PbY4BLQFa9akoRz3ONtZzvKNctCaw+Rw Jy2oTGcSa8Nlf+bLTg5XpsXnzBamPLby15cGQOQz2FyrMBI+iSiCzyXsA5BKr3SuvprFvO 4p3i1PK2z0m/FncKf6ab/7va5ivzycY= 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: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=zyLVkLIMvfYhi7iymKpQZImO3Ib0JWZlKPrLFkzRDOc=; b=pFm81e4bb+QtvK5+4H/e9fu/ca mDosN7UQ10AaICUT4M41ananaVFX+K5PU3cy09vMfhRQ48/C2saMliUm5n/PgBPNe3sYVx3jCGWF4 cOliMJqNps/mIkTxPSq4kcOQmCtqW6CbXiYj7xBGpK6Dk89Tpp5dJWoNOvFpCjpb1l7Qnb2nM0LCT zPNLpho0r7Dyv0dockjEJHcxuuolGuN1+236cAXNbZ4gTVSb0O4/hP46FKEoouDqLwmNyY+GBHpud oPOqkRGPM3ADoF7GwTXspm0FTROU1+KbMUEp/gjWwVd8EE1f/QRtgemhdmVlBR9kSu0ys11PaKc0F OXac9udA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfOZf-00000005sUS-1bQo; Wed, 28 Feb 2024 18:22:35 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH 1/1] mm: Convert pagecache_isize_extended to use a folio Date: Wed, 28 Feb 2024 18:22:28 +0000 Message-ID: <20240228182230.1401088-2-willy@infradead.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240228182230.1401088-1-willy@infradead.org> References: <20240228182230.1401088-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 4737BC0021 X-Stat-Signature: kekua911yjtjeqhh5z1ma7tdsxo83a7c X-HE-Tag: 1709144560-896258 X-HE-Meta: U2FsdGVkX19NxUnImFdBxMYbcOTkR/uEIh7Fuh3QNOm1z7akuOhZNaIpk6jmAfj65eybRZoyyvk9E0hz5jOl9YFL/6rQfufh/DAHs50mxr3C/PTqbCSf4RWKK670WgPChGuz6ugZe6GYNt9lHrg6KZ7+DWofleKfUUdvjSM24L6VuFkPfUyU3nyHRKIxYy80fLH1xdQN7QK7yRWEb55Azd2dsOzySLQ3+gsJWMDK/LiN7hxGT4a6A+Dl3YlGD+BNfLg/VqZ3D/xXr8VPRKMdb17Ms6NOy0UCrfdxXxHW6bo+zP6G5Lrte1GSANfsT6XcZfz3zC8Dky59bBfGcStGEcbsdhoRM6W8LHvo2NO7EuWAGJmXQEF+/7Gl5IViP7MmF5Y++6alIDMwJrb3GxtX1So+QCdzSkFneJ26mvws6pxyW6SNuxvMpyyzLKC6ZI6jUiRuUdd41V5e5Rsk+NL8JNtLn8M5Xt1nd/nMlkqKt0T00aqpgFVMSG2lktjlUXNdY/m/LZL9ijZ8AE9WFOvR3OLCTUU37p2b3FHOkHE7mPU0TXrfWPUWcfK+uTNmsIAmWZvbiGKAnwcd7hEm4SeCUHSGHSvzuUpEgBIAeBeH/v1QijgbfSLSRciTuQnd7T9pakmYRjWKMoq5r3OJRm8BlePpiEfjlzsowiRTWmWZH3Hmmpyv/oRAzqGb0TpkJudPbJCW3KFu4vbbjtWMqldVyo4s+3mmsS1agT8iDTTHalvc24P93RDgJn8jKZY0XrP/Fet/CqJDV62YDgG/pNSZEXJ4D/ERnmYabpQ9THwmxrazlqis2v14zu9yMonqCWLl+wXhMrD+QvU58IsBwz8HNGIYcA29LHGF+qBbfs9amDzm9HUrYcXFKdWiqo3nqBK/TUS5Vdu8MxyPE9BG5Ec7qDDDbqIIi+sH 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: List-Subscribe: List-Unsubscribe: Remove four hidden calls to compound_head(). Also exit early if the filesystem block size is >= PAGE_SIZE instead of just equal to PAGE_SIZE. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Pankaj Raghav --- mm/truncate.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/mm/truncate.c b/mm/truncate.c index 725b150e47ac..25776e1915b8 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -781,31 +781,29 @@ void pagecache_isize_extended(struct inode *inode, loff_t from, loff_t to) { int bsize = i_blocksize(inode); loff_t rounded_from; - struct page *page; - pgoff_t index; + struct folio *folio; WARN_ON(to > inode->i_size); - if (from >= to || bsize == PAGE_SIZE) + if (from >= to || bsize >= PAGE_SIZE) return; /* Page straddling @from will not have any hole block created? */ rounded_from = round_up(from, bsize); if (to <= rounded_from || !(rounded_from & (PAGE_SIZE - 1))) return; - index = from >> PAGE_SHIFT; - page = find_lock_page(inode->i_mapping, index); - /* Page not cached? Nothing to do */ - if (!page) + folio = filemap_lock_folio(inode->i_mapping, from / PAGE_SIZE); + /* Folio not cached? Nothing to do */ + if (IS_ERR(folio)) return; /* - * See clear_page_dirty_for_io() for details why set_page_dirty() + * See folio_clear_dirty_for_io() for details why folio_mark_dirty() * is needed. */ - if (page_mkclean(page)) - set_page_dirty(page); - unlock_page(page); - put_page(page); + if (folio_mkclean(folio)) + folio_mark_dirty(folio); + folio_unlock(folio); + folio_put(folio); } EXPORT_SYMBOL(pagecache_isize_extended);