From patchwork Wed Dec 8 04:22:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 12663625 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 7B377C433F5 for ; Wed, 8 Dec 2021 06:05:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 84C586B0073; Wed, 8 Dec 2021 01:04:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 67BB66B0078; Wed, 8 Dec 2021 01:04:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 456EE6B0074; Wed, 8 Dec 2021 01:04:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay035.a.hostedemail.com [64.99.140.35]) by kanga.kvack.org (Postfix) with ESMTP id 29F036B0071 for ; Wed, 8 Dec 2021 01:04:43 -0500 (EST) Received: by unirelay01.hostedemail.com (Postfix, from userid 108) id D3B73605AD; Wed, 8 Dec 2021 05:38:47 +0000 (UTC) Received: by unirelay01.hostedemail.com (Postfix, from userid 108) id 35C39604D5; Wed, 8 Dec 2021 05:32:08 +0000 (UTC) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 5C0D960A0F for ; Wed, 8 Dec 2021 04:23:18 +0000 (UTC) X-FDA: 78893332476.30.C37890A Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf05.hostedemail.com (Postfix) with ESMTP id DCC5B100002 for ; Wed, 8 Dec 2021 04:23:17 +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: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=PRh0VjIPJ/xdMLO8RLWdCCSHILXWRHuUOZvS3c2PDV4=; b=s97Po3qmIMWLOvQDRaqmMdsAs0 XR/0Vf2i8cLRnwljdB4wuLGg+s3w2/e1Xjnr6RC7VJmHL9whKiJcaKGFXMD90JPld+IAhuJH8wzJO NP8UchXQyG78QbxcL8wy/Yg4wOlB8A0Jg0ztwZYK0tK3UMr3XvB3DoWypdkU/FTKcyFlWgRNLtnck i/5O008ECD51WMWj3fz7oyn36xy36mMdfqC6Fe+LDzDP8JebbHStijG9Giu2jIhasyBnzn9nJMRnf vNJnMQ+K5gqYb9BxguUDhBlvIOogRkyV0zA1dcZX/ottrv6pWiinRtyDYwVGDn9+q6pJVCgA8i69O 8clIHFQQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1muoU7-0084cK-0S; Wed, 08 Dec 2021 04:23:15 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH 39/48] filemap: Convert filemap_read() to use a folio Date: Wed, 8 Dec 2021 04:22:47 +0000 Message-Id: <20211208042256.1923824-40-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211208042256.1923824-1-willy@infradead.org> References: <20211208042256.1923824-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: DCC5B100002 X-Stat-Signature: oi5rtcb1kbop9u81zmdjxtfkrdu63dk6 Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=s97Po3qm; spf=none (imf05.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-HE-Tag: 1638937397-817479 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: We know the pagevec always contains folios, but use page_folio() anyway instead of casting. Removes a few calls to legacy functions. Signed-off-by: Matthew Wilcox (Oracle) --- mm/filemap.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index fb3cdb7aeffc..91399027b349 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2668,30 +2668,26 @@ ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *iter, mark_page_accessed(pvec.pages[0]); for (i = 0; i < pagevec_count(&pvec); i++) { - struct page *page = pvec.pages[i]; - size_t page_size = thp_size(page); - size_t offset = iocb->ki_pos & (page_size - 1); + struct folio *folio = page_folio(pvec.pages[i]); + size_t fsize = folio_size(folio); + size_t offset = iocb->ki_pos & (fsize - 1); size_t bytes = min_t(loff_t, end_offset - iocb->ki_pos, - page_size - offset); + fsize - offset); size_t copied; - if (end_offset < page_offset(page)) + if (end_offset < folio_pos(folio)) break; if (i > 0) - mark_page_accessed(page); + folio_mark_accessed(folio); /* - * If users can be writing to this page using arbitrary - * virtual addresses, take care about potential aliasing - * before reading the page on the kernel side. + * If users can be writing to this folio using arbitrary + * virtual addresses, take care of potential aliasing + * before reading the folio on the kernel side. */ - if (writably_mapped) { - int j; - - for (j = 0; j < thp_nr_pages(page); j++) - flush_dcache_page(page + j); - } + if (writably_mapped) + flush_dcache_folio(folio); - copied = copy_page_to_iter(page, offset, bytes, iter); + copied = copy_folio_to_iter(folio, offset, bytes, iter); already_read += copied; iocb->ki_pos += copied;