From patchwork Mon Dec 16 16:26:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13910029 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 52DB5E7717F for ; Mon, 16 Dec 2024 16:27:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D35118D0008; Mon, 16 Dec 2024 11:27:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CC2068D0006; Mon, 16 Dec 2024 11:27:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B5CEC8D0008; Mon, 16 Dec 2024 11:27:13 -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 96E4A8D0006 for ; Mon, 16 Dec 2024 11:27:13 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1190A1A11E6 for ; Mon, 16 Dec 2024 16:27:13 +0000 (UTC) X-FDA: 82901350980.23.B1CA753 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf15.hostedemail.com (Postfix) with ESMTP id 97CEEA000F for ; Mon, 16 Dec 2024 16:26:30 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Iae0Cxoi; dmarc=none; spf=none (imf15.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=1734366418; 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=bu2kx5ccarvn3y99Em/U+b3Zlo5ch2td1EQGdKbcf9U=; b=nBSLyXIauT62L0HDeOVsbtDdNToZlXyFZw8FiWaMaMwOMkK++4kmWPz/OFVN5ZZo3vO4oc SQECnZByS/JFPbwTGHa1wJeODVNsLbd/KOkhrMDcw6lsDERh+VbC1n9bG9XAZrGEOqt2Hp S1OTDNjK2E9yC3vQwK+oD9fmAf5BEbA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734366418; a=rsa-sha256; cv=none; b=PwjqerduJJiPNHu07fAWtejCTdwDkCiOWx310g8zvYzLOzpKd9BbYMA8ZQYyj1PwbA+dru wIgplfaq6eL9x0NbMkZ0OYLYIbMDE5J5vT+mHFus2xr7R9MQhoRlUM9EtLHbIZZoqVi5JV iUAshJlZohH/oaU05DUcC07C5mlxxVY= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Iae0Cxoi; dmarc=none; spf=none (imf15.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org 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=bu2kx5ccarvn3y99Em/U+b3Zlo5ch2td1EQGdKbcf9U=; b=Iae0CxoiKWel5R+U7fAaIhy4Ax klvtGI5sKG/JH98UBdUH5ppXkVkaN7qU1fh1aTHFHnnv6pBSjGEL5MhpQdZiCIOlWZAPDOl1eQ+zo JVIYUbMNPox2hAORb2ZhVp+BwJcrVi8g0MD6w0jC/XoEBFo+lgZ90xVg2EItjjEYFm/3iObigGlPF 5DjLiAp+DL8VQd1kzIpAGVAHgJizLjkOYhaj3y0PBxclJpS8zGZKcEW/K1NjGOzV1uFjT/QlDe7Vb rH6+v5OCv73CBJ8VFVsUmvSN5yTx6lwpyrfjabFajsqhqQVNBjrQEJ+eoaBYrFQCYVfu42RJjEoPs MgxiYB3g==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tNDw0-00000000Eyx-0jWG; Mon, 16 Dec 2024 16:27:04 +0000 From: "Matthew Wilcox (Oracle)" To: Phillip Lougher Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 1/5] squashfs: Use a folio throughout squashfs_read_folio() Date: Mon, 16 Dec 2024 16:26:55 +0000 Message-ID: <20241216162701.57549-1-willy@infradead.org> X-Mailer: git-send-email 2.47.1 MIME-Version: 1.0 X-Stat-Signature: z9iz959dqhfstj3ynfukfnwgj6d5jo3r X-Rspamd-Queue-Id: 97CEEA000F X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1734366390-619226 X-HE-Meta: U2FsdGVkX18Yry+E810wmpcDRYz512hzfNpEKaHxsoI6YxdJA6nuVjSH1pRTNw0XjzQzQ5iCzhv6LZgWgmGHjxt/CtYzl6kh/XqpIj6vtSCrduyrNaKTFbzb7EU6AJWOMhn1OMduG+fLdMyug2i4GFKrBC6JPSF6sXNj54EKtra3XYFFHRTFZcM6uK24w9FnE6Z+aKzFY6S1IaY9PC4MGB9l26lHyDRcI/7hGLbWkIlY86hYhEbMDL2PZP1LYtQKxNeU4ddVU5yF77Ul31bYGRtgeiXhHAHXTmhvQSQEe6uPYoKdcWQhH7bnmj7ZsmfCyb1F8N8/U3yJPSqGfGu8lw+wLZ238AX+az9O6Oxp+C9D32KNcj6vzcibW4jhsXTF2i+WUJUOW3kgdwdhXNsKLy7ukFABRfNWzGhU0adm/f54QKMWuId1FpX008240UFRimwsZIoR/q3K9zZzcIS59CxrV2TzmPZ5GGKpfdw2VNVBLFT8rqVqxAdRd4gMSG+2qeH3f9F+E0zUX+f/JouYDxlasKQbFvRjUO/44bcPuVMiRVpfXB2aCcPdz4qFSgcMRV6/C02sGr4te/l69p10wxpjLfb2y6z7eiPI0Dmo1F3REK21/v+f2z67zyHoXRtc+gwIbla7IeecEOv9Ojb3c+DvwCXdYMtVqReHuPMBdCRCRzCZLCYC4lYHBYSEkiKHLcJTDyZtHXMx9aPxz2WKSw3iU9Wqksy0QOGOQnpQ3/B/GUIMTfQbBuklVBTBg+dmvUj+kY2dqggW4DwWRHIgXDcnHvKyHmgTN2oSZoTy+gZaZC1wWBEdJFdMTkOPZLnE90u6FpcBa6bHBgvDYfYBnd7BDnw5918MGqVR5Q2DNihI9LzgjC897bMGobD00fwAv1h4K+o1W0ek/HfEKqI3XAC560dEv+CUms1rlAE8cDb2NGyAEEKG0c3bJxwF+KsXXDB+BieA5fXe7V1pvZd +jktGrLR bIznHQX/E/cO2tWThqjm+k20WjNoW8eD7WhRo4guPjR9e5Yx2GS1DuTGmngeBeMPh8Z/nhFjJMIDQiuzz0esPpASvf/Ckps5OrJR/JC9IsdAWG5UwIwnituMlQOAF/j2x1Be/VVi5Fn8cQR0N1udv4gLOaiJPRQOgT0WF5sydXZHfXSJkp6D1q8Z1jxUuT2LZGZEcea6bQoYGJumd3yjuez5gwfe3hWp7V2XqAnvhRMo325aWtwKnO0sdchzKd8Mc/p3aSk4fP2It4TTbRuuTODAHeMwYNoNAyQ+I 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: Use modern folio APIs where they exist and convert back to struct page for the internal functions. Signed-off-by: Matthew Wilcox (Oracle) --- fs/squashfs/file.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c index 21aaa96856c1..bc6598c3a48f 100644 --- a/fs/squashfs/file.c +++ b/fs/squashfs/file.c @@ -445,21 +445,19 @@ static int squashfs_readpage_sparse(struct page *page, int expected) static int squashfs_read_folio(struct file *file, struct folio *folio) { - struct page *page = &folio->page; - struct inode *inode = page->mapping->host; + struct inode *inode = folio->mapping->host; struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info; - int index = page->index >> (msblk->block_log - PAGE_SHIFT); + int index = folio->index >> (msblk->block_log - PAGE_SHIFT); int file_end = i_size_read(inode) >> msblk->block_log; int expected = index == file_end ? (i_size_read(inode) & (msblk->block_size - 1)) : msblk->block_size; int res = 0; - void *pageaddr; TRACE("Entered squashfs_readpage, page index %lx, start block %llx\n", - page->index, squashfs_i(inode)->start); + folio->index, squashfs_i(inode)->start); - if (page->index >= ((i_size_read(inode) + PAGE_SIZE - 1) >> + if (folio->index >= ((i_size_read(inode) + PAGE_SIZE - 1) >> PAGE_SHIFT)) goto out; @@ -472,23 +470,18 @@ static int squashfs_read_folio(struct file *file, struct folio *folio) goto out; if (res == 0) - res = squashfs_readpage_sparse(page, expected); + res = squashfs_readpage_sparse(&folio->page, expected); else - res = squashfs_readpage_block(page, block, res, expected); + res = squashfs_readpage_block(&folio->page, block, res, expected); } else - res = squashfs_readpage_fragment(page, expected); + res = squashfs_readpage_fragment(&folio->page, expected); if (!res) return 0; out: - pageaddr = kmap_atomic(page); - memset(pageaddr, 0, PAGE_SIZE); - kunmap_atomic(pageaddr); - flush_dcache_page(page); - if (res == 0) - SetPageUptodate(page); - unlock_page(page); + folio_zero_segment(folio, 0, folio_size(folio)); + folio_end_read(folio, res == 0); return res; } From patchwork Mon Dec 16 16:26:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13910027 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 57D18E77183 for ; Mon, 16 Dec 2024 16:27:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B10098D0001; Mon, 16 Dec 2024 11:27:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ABFF08D0006; Mon, 16 Dec 2024 11:27:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9874F8D0001; Mon, 16 Dec 2024 11:27:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 6CEF78D0006 for ; Mon, 16 Dec 2024 11:27:08 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D2642A0C4A for ; Mon, 16 Dec 2024 16:27:07 +0000 (UTC) X-FDA: 82901350770.30.924D8BD Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf22.hostedemail.com (Postfix) with ESMTP id E868DC0013 for ; Mon, 16 Dec 2024 16:26:34 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="UrW9/DRj"; 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; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734366394; 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=LZ5OrPuIVHgO9uugI8412gKWwbcN2x5YFOCCPNSvsdU=; b=FTNKU8ULd0uLHH2tNMYQfN3XkFj/Ui5RFrGynToaqqX/ETR4Zswr3eC7xGCWxCIqvdR9g5 mPF0fhEVV6I6P+lh3Xk1voQ5rqTMcd04aj7PDyVcOGSeJpJVz6MT8qXeYbMCw2opHjHfuL xB7mgxfSEe4EQoNvHafDFnH3of1skBA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734366394; a=rsa-sha256; cv=none; b=FG6Fxjb2Jt8VgaUnz9y/BcgXudvM/LvHXIgXE8dtZvJ7hq7vdr4w8fIiEFZJyVHU6HkdUo dU68IhdnkTZEJ2Ws0FWRPYzRtCSGZq37YpxV8uRO5cJ9iJ5K3X/cBaia3meWll25nFGaqA +KnYpRB6Rh6PC6bBPPtZaLYGIGgD6WA= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="UrW9/DRj"; 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; dmarc=none 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=LZ5OrPuIVHgO9uugI8412gKWwbcN2x5YFOCCPNSvsdU=; b=UrW9/DRjnQPLsYP/yd4yQlcHu0 xPyRAYXC5eCr8izMxP6tUCqLNZBH++WOnbO/MOAg15K4p/sIFNHriClp6x9sMwL+qpM7lkAFEMZn0 fHkwODU8cl8J78IByFhvU4KsBUUHYuxM1Jv6W99Osq3AlRUO0uQ1NuZNziW/Qz3PSjsusYfmiUeAz 58s0w2Lf4IME7xurCx5dNnz247V24W5daWZwgp5wzyRrY1JwPZ1gJ10oTP/WQbmXRYektlslayu6S O46I9PePGWUlwMciEkqUKQLicaiwzfcvhoEhPLbL2g6PnTcaHET5xBshaB9UBRCiIRuL79F9Qmar+ iNwh2c7A==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tNDw0-00000000Ez0-1BlL; Mon, 16 Dec 2024 16:27:04 +0000 From: "Matthew Wilcox (Oracle)" To: Phillip Lougher Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 2/5] squashfs: Pass a folio to squashfs_readpage_fragment() Date: Mon, 16 Dec 2024 16:26:56 +0000 Message-ID: <20241216162701.57549-2-willy@infradead.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241216162701.57549-1-willy@infradead.org> References: <20241216162701.57549-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: E868DC0013 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: r8nhwzzy3y3a7n16e7rmkpadceo5q6hc X-HE-Tag: 1734366394-45134 X-HE-Meta: U2FsdGVkX18LQxu4z5W1agr0FjM4zLKMc9pKZagYG6WRDw1Wf4NopFPNPSvdR3OWZq5nlNT22Ch4dBTGFZU5DCTl90OHhVClF/v1iZFlLFTfITX5eD8gWmYVq7MrAHLFIxnBIE7LZPnWW7G0dA/whbTXgWqRgXPtrqfzCApJ+eocY+/U3OaI2yVcQOxjcwLH5fm9q679nk+p6cWuXYC9d6llMWEaNEqcZ4p7Ob937INig8ssajcBtjSTJ7pCf526SIwP59lpPHBtvRRE0h/xx7tLfy2pa9nJ0BAUtDFt8G+kgrEeYH0RPdB4W/nGMPi8KPXk1pYS/W06mRpLA+UFGSRVnETWOGTc8SGeQn+pVUj3Y9MFUXjbiojpfjr+PGP6bsHOtIdsPoaz/WEuPQQtSg7If65Yd5p4dbWT/DYyEOeMvCIZWdK0WMty4oG9Wb6ogUzwD+J648mHji6hqyluy/QVcYIVNMSCWKlnEoqXA5pJJzL8JvLZY00K41AKaX6ZVrm9/gFRlUrB3pCHeWOBPP1OlTifcpLqDT15f1lzSp/dB6IC5nZ/wHXUNGz0415l8JVM0P+/cFVlSZaa/tftukCXmBQDF0G69pOLdbeJ38mlI51/J3SrBlZDz/P0kTpD8J5CPuglDDH3t53kHC/FSo8cRTr70HHmePq4FgifBiae5pNsr3yLbfQ9OQs6J44FRpM5obV+57/HX6X7/eJ8WM212YzD4P9rPpwNFv4F0w+dKKpD2JNyzkGeL2SqEDcmZ/e4hvnD3fCQbI3bIfoYntJY6YDhGZ9G//PejSsfTBopDU766dji72cQyR4vKa88s/eAs+Gi6PAwjHsMv+kIQ9iZtYu26YXE6VnsRRvjqJBafwWqgE7koTm8tykUY/lDgynKev0gcAr0kKf9cSHJ7YSLmVbYSlmF62Cv0LPTbbOIXpKUtPjzS3xpXkjOoKMVdSXbfMHqBmusFdvBwPU yw5BrYM0 jmsIkvh46cKXeRgngj1LATslkOGeLhhAf9rLyiAC8X7WM2ebIPFqKcLaAc0rC/NrwzTa5G0J1/NZ6+eJiDkIN5dmT+kyEQLp57DJ0FZGNWyVQvGlnXjU21JMCBZx7+xzJ1RTl240FKknYBzcMYvys7x9j2Fz7+d/QFHneqqfXrLLtKC+syM4MolM8H0Ks+guR/YTh1r0b6QCgj+V1/QiFHtKQzF+kRRLqozRcsWa7oY/zfsjbte+r4e28iMlGk4L8PafmKX0eIDaPZnir6U7Prln2ErekEk/eBBIb 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 an access to page->mapping. Signed-off-by: Matthew Wilcox (Oracle) --- fs/squashfs/file.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c index bc6598c3a48f..6bd16e12493b 100644 --- a/fs/squashfs/file.c +++ b/fs/squashfs/file.c @@ -417,9 +417,9 @@ void squashfs_copy_cache(struct page *page, struct squashfs_cache_entry *buffer, } /* Read datablock stored packed inside a fragment (tail-end packed block) */ -static int squashfs_readpage_fragment(struct page *page, int expected) +static int squashfs_readpage_fragment(struct folio *folio, int expected) { - struct inode *inode = page->mapping->host; + struct inode *inode = folio->mapping->host; struct squashfs_cache_entry *buffer = squashfs_get_fragment(inode->i_sb, squashfs_i(inode)->fragment_block, squashfs_i(inode)->fragment_size); @@ -430,7 +430,7 @@ static int squashfs_readpage_fragment(struct page *page, int expected) squashfs_i(inode)->fragment_block, squashfs_i(inode)->fragment_size); else - squashfs_copy_cache(page, buffer, expected, + squashfs_copy_cache(&folio->page, buffer, expected, squashfs_i(inode)->fragment_offset); squashfs_cache_put(buffer); @@ -474,7 +474,7 @@ static int squashfs_read_folio(struct file *file, struct folio *folio) else res = squashfs_readpage_block(&folio->page, block, res, expected); } else - res = squashfs_readpage_fragment(&folio->page, expected); + res = squashfs_readpage_fragment(folio, expected); if (!res) return 0; From patchwork Mon Dec 16 16:26:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13910028 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 A874DE77180 for ; Mon, 16 Dec 2024 16:27:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0B1678D0007; Mon, 16 Dec 2024 11:27:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 038118D0006; Mon, 16 Dec 2024 11:27:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD0C98D0007; Mon, 16 Dec 2024 11:27:10 -0500 (EST) 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 B71288D0006 for ; Mon, 16 Dec 2024 11:27:10 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 60DB843422 for ; Mon, 16 Dec 2024 16:27:10 +0000 (UTC) X-FDA: 82901350896.30.2285F98 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf15.hostedemail.com (Postfix) with ESMTP id C72ECA0029 for ; Mon, 16 Dec 2024 16:26:27 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=cSLKXi1s; dmarc=none; spf=none (imf15.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=1734366414; a=rsa-sha256; cv=none; b=Dw9d+X/CMfC+BtNS4B5Lrz8nqF9F2X1cfjPEneqiCqBvLgpF0uUORToQMks6aVXLPvZtYU q0A0qHXDB1Ib9CvzO9y4Qfhn5I+APV7g0DXLipwxCv0cid9Qwc0FZbmPvqEE4QPz1T8i6k Nzun1NEwOVsyF/PDA0Q3KfmjDagLliE= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=cSLKXi1s; dmarc=none; spf=none (imf15.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=1734366414; 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=eJNIAPCs4sCCfLCR9H+1hO5eJPipcnwMIjpH52PWdqw=; b=2CCLUUfp43jYHr9i52ecVu5S28+2gE5o9/GVA+PQGuhGif6N6m+CInV+5Fy30uy35nxim9 4cNTp+jmYszLeNIF/I6rtD3Lc5moM2JV7m3s77Xf0EBeKRy+QT3bUTKWgt+d2kBUBoE1oA +V51ZvWtIbkkdFxZdc2Nh1i1+ne6n3w= 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=eJNIAPCs4sCCfLCR9H+1hO5eJPipcnwMIjpH52PWdqw=; b=cSLKXi1s8DTi76DX8gfpVDVSTG AzIw47Kh5ZgM9gEFS8i5m8QBRVW/wnLhZhvzeEpIdleQHB8vxJTFk14KyTREU4j8QLFfyPWwCjSZ/ 7obrL9TFnSR2SgJoVBpV4EPUo6jRY6YG3ykDvlCt10aC5Lk7q30HRYYrAyAMCKREdNOhiAwAD2jh2 dm80yONFjz+H564LYoouh/Dcjjr2zo8YbIURUTgVBgs8Sgv/EknPtbrb3XclpnEr87p6gQT1wnH+P cBGPvSUekJx51BONpHZu2vZ+u/vSoHN59DYLjHGqVXHogVKQ16UsPY7iI4xhOi1ayfsQRIfWZGrvt FS6qwIzQ==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tNDw0-00000000Ez6-1WMW; Mon, 16 Dec 2024 16:27:04 +0000 From: "Matthew Wilcox (Oracle)" To: Phillip Lougher Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 3/5] squashfs: Convert squashfs_readpage_block() to take a folio Date: Mon, 16 Dec 2024 16:26:57 +0000 Message-ID: <20241216162701.57549-3-willy@infradead.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241216162701.57549-1-willy@infradead.org> References: <20241216162701.57549-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: C72ECA0029 X-Stat-Signature: 987kge6sgixeadniae1ye8yr6iqaum5y X-HE-Tag: 1734366387-669240 X-HE-Meta: U2FsdGVkX1/vAmZ24vbogYTfm2WxCFrYoqPuXcc+S0fn5+pkK6Hon5SQmTU0rccKiJLXZoc16ImGY/JGKgJ5txIVe/Zou/Kk6KIhwkNrfxdLNEJsDD8ubSVSS/HV10xakIgRVB7o3ga1S8OPc25OD8E8pXIBSl9XT2IyZ7asbj6I98U8NUWOkIKlpjrf6Yy4isKzfWC2r2pyAyyKG2bFP6kKp7ltKz3t9rzAtjf/gmMrErJt+aBXSI6tkbqExoSi3ehttai6MxPMykmwRQwH9DWP3r5ovYNNTNNhGG2cjDbE18rrINDNlBM+CWm6sn5FG2E85O47dBQKDzbf4r+lXMc567L67yOncVNmJvUGHPLkpQKgtP2SDPPnIkm2ct/DDQ/IUQULwLnoD2m9addDD6QFsHmlRAoIqe/whTU1lPGo2HSha0DURoAgSFyx4rqrupOPmhLIMIFk7PUiSsjapLRcu1RPv3i6PLD0gFEEJCgxoMIm3wXbeoi94VfvH4JHHcV7MZnI7l802AiFRVRwWbVZaPl/BolqGUR6V6xeFWmeofg3WNM5Q50Cc02FtO9nCUF3KccL4PXlEde6VSjBgAGoCrp91VSpYvmhsmrh9H+799sfvG+0XsuPwyiXFobY8uytQ8ejxac+v6VcrXhcc6NVFIE9rov5VWOh9KXFHK97NoQ7Co8CKAN05zUlLU4jhrCl3mM9Zd7QnoJfya0hN6XyWbMvAgFpPM2f2eK4VJu513YyJoW3qzba649PI2p3227skhOXo4GRi78EJKxqaPGMsagm4M1zUCBaq2hMS8F5XC7OE+dqejIQ96p374IjxzgeQ947rqRxgbWe8FU/Xk0lelboDf52ZP/0CVU4inhOk+d9FqAOluDt6zxWS+hpRqMKGIFLMLEpDSP6XU0s4X1svOIlTsc4RAbGfiW82Wy4jyjyiGhvv4nr1F+AFTXwiFZIR3XKyhVSLoHYWhv J52M6tth /8gh4KzYlaE377yNdOSkvQBVATBy9fvqCuWmINyKiPZOE2XEkVknXqUpUe/Hn/8PwoJEbdhywaOu60M1dCcKbSeNgTzq6I2Ut6jjEns3YW6CYz9tdXNUKInk06RiNKJfXVA3+bf1uP2Xr9/oNZOZj9LUxyQHUSqcIXes3v27NAu3uzHoLyGE80Rqj5c2Evx76qsRNYWXTwYBEYQeZInNMNmBTMuD4nv4OGYiTDmkZMx8M/P1DU9jkgoouMJ8Y0ODRzXqCNnJHzfWzGkYJaQdM9KsmzPu6zvKaLTwZ 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 a few accesses to page->mapping. Signed-off-by: Matthew Wilcox (Oracle) --- fs/squashfs/file.c | 2 +- fs/squashfs/file_cache.c | 6 +++--- fs/squashfs/file_direct.c | 11 +++++------ fs/squashfs/squashfs.h | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c index 6bd16e12493b..5b81e26b1226 100644 --- a/fs/squashfs/file.c +++ b/fs/squashfs/file.c @@ -472,7 +472,7 @@ static int squashfs_read_folio(struct file *file, struct folio *folio) if (res == 0) res = squashfs_readpage_sparse(&folio->page, expected); else - res = squashfs_readpage_block(&folio->page, block, res, expected); + res = squashfs_readpage_block(folio, block, res, expected); } else res = squashfs_readpage_fragment(folio, expected); diff --git a/fs/squashfs/file_cache.c b/fs/squashfs/file_cache.c index 54c17b7c85fd..0360d22a77d4 100644 --- a/fs/squashfs/file_cache.c +++ b/fs/squashfs/file_cache.c @@ -18,9 +18,9 @@ #include "squashfs.h" /* Read separately compressed datablock and memcopy into page cache */ -int squashfs_readpage_block(struct page *page, u64 block, int bsize, int expected) +int squashfs_readpage_block(struct folio *folio, u64 block, int bsize, int expected) { - struct inode *i = page->mapping->host; + struct inode *i = folio->mapping->host; struct squashfs_cache_entry *buffer = squashfs_get_datablock(i->i_sb, block, bsize); int res = buffer->error; @@ -29,7 +29,7 @@ int squashfs_readpage_block(struct page *page, u64 block, int bsize, int expecte ERROR("Unable to read page, block %llx, size %x\n", block, bsize); else - squashfs_copy_cache(page, buffer, expected, 0); + squashfs_copy_cache(&folio->page, buffer, expected, 0); squashfs_cache_put(buffer); return res; diff --git a/fs/squashfs/file_direct.c b/fs/squashfs/file_direct.c index d19d4db74af8..2c3e809d6891 100644 --- a/fs/squashfs/file_direct.c +++ b/fs/squashfs/file_direct.c @@ -19,12 +19,11 @@ #include "page_actor.h" /* Read separately compressed datablock directly into page cache */ -int squashfs_readpage_block(struct page *target_page, u64 block, int bsize, - int expected) - +int squashfs_readpage_block(struct folio *folio, u64 block, int bsize, + int expected) { - struct folio *folio = page_folio(target_page); - struct inode *inode = target_page->mapping->host; + struct page *target_page = &folio->page; + struct inode *inode = folio->mapping->host; struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info; loff_t file_end = (i_size_read(inode) - 1) >> PAGE_SHIFT; int mask = (1 << (msblk->block_log - PAGE_SHIFT)) - 1; @@ -48,7 +47,7 @@ int squashfs_readpage_block(struct page *target_page, u64 block, int bsize, /* Try to grab all the pages covered by the Squashfs block */ for (i = 0, index = start_index; index <= end_index; index++) { page[i] = (index == folio->index) ? target_page : - grab_cache_page_nowait(target_page->mapping, index); + grab_cache_page_nowait(folio->mapping, index); if (page[i] == NULL) continue; diff --git a/fs/squashfs/squashfs.h b/fs/squashfs/squashfs.h index 5a756e6790b5..0f5373479516 100644 --- a/fs/squashfs/squashfs.h +++ b/fs/squashfs/squashfs.h @@ -72,7 +72,7 @@ void squashfs_copy_cache(struct page *, struct squashfs_cache_entry *, int, int); /* file_xxx.c */ -extern int squashfs_readpage_block(struct page *, u64, int, int); +int squashfs_readpage_block(struct folio *, u64 block, int bsize, int expected); /* id.c */ extern int squashfs_get_id(struct super_block *, unsigned int, unsigned int *); From patchwork Mon Dec 16 16:26:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13910030 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 BB895E77180 for ; Mon, 16 Dec 2024 16:27:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D33F28D0009; Mon, 16 Dec 2024 11:27:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CE3848D0006; Mon, 16 Dec 2024 11:27:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B362B8D0009; Mon, 16 Dec 2024 11:27:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 92A1A8D0006 for ; Mon, 16 Dec 2024 11:27:16 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 497FAA0C4D for ; Mon, 16 Dec 2024 16:27:16 +0000 (UTC) X-FDA: 82901351148.10.DFD9C4B Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf26.hostedemail.com (Postfix) with ESMTP id 3DE9614000A for ; Mon, 16 Dec 2024 16:26:52 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=kWfCA+n0; dmarc=none; spf=none (imf26.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=1734366407; a=rsa-sha256; cv=none; b=7OLI03e9I+fkTbhFwicxQIrOHJuROIoyDeYs9NY9OnU00LdSmrSdRMwxbwDmHi64gLXQMX nWDTrOp02LmDFzt94eRHR3HBG2ZSQn3VQ8yOaCjPegFoqwIfYj5S7EgrYfKgV1t6dVYDru gfj2qwkMy7GNmSICf2Fr2+BTvTXaSSA= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=kWfCA+n0; dmarc=none; spf=none (imf26.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=1734366407; 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=Qu/PiL85fu1e3QcMJHhgZFh62m9BJTBqStwrlLOLtZQ=; b=7GZQ9kS249Qy9GUPTw3VhytexTkqyywyhbnFmMzfc8BOBqHxu4FlEBHMZbfljnp49t63Gd /OaZMeuBteBTVnXnM3jvPL8JxpRuUytHcYw7i3aguhl7knjnp+/+O2zfUMagh3DzQedO03 PNM858OemvWdSC1dWE6M3FpCxxOdUiw= 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=Qu/PiL85fu1e3QcMJHhgZFh62m9BJTBqStwrlLOLtZQ=; b=kWfCA+n0L40xOuhLiv91kDlJhr 2T2FXHN8IBznmYsGX8qZ36MMuO5FzKzQimyLDB9b2O/1rt2dnl/C37LMZISbzu3DoRG9uS/RS5RK5 v78DL1Ddk4mulAZaXdEruEj8LiaRBOpzVFnOyAzNj52NAb63/QlBZPHOVVkXlFeXMaE3Gim0jHVm2 NBkci6eYlT4nadFfn/usX5ttZqo4epj3HdrSA3iNtMJdvmtV+c3Q0qpfpZ2ROIdNUIBH3MzzjsMbD MuDrDPs4E0yP9J5ypdlyyoRuwFFEOMn4MCE3XKfSIDF8hlSr/jJU7/WBnhiEDFDGqMF/naRsWflDE hzGliwiQ==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tNDw0-00000000Ez8-1qLx; Mon, 16 Dec 2024 16:27:04 +0000 From: "Matthew Wilcox (Oracle)" To: Phillip Lougher Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 4/5] squashfs; Convert squashfs_copy_cache() to take a folio Date: Mon, 16 Dec 2024 16:26:58 +0000 Message-ID: <20241216162701.57549-4-willy@infradead.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241216162701.57549-1-willy@infradead.org> References: <20241216162701.57549-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 3DE9614000A X-Stat-Signature: 9zikqyrwudbxt8kdsirweromsfo9otp6 X-Rspam-User: X-HE-Tag: 1734366412-530645 X-HE-Meta: U2FsdGVkX1+e/sbJEXO+Kz7tjKDNy6hUA9rquj14rIzrenhgX2NBo90AYLrGri4WTJAXXlwZs30916zstKO1NbYxRzvgNsuwU+r4qCXtVyRmlJRqoXwrUyNf20xLeL8sRCrFbLAA8aHlZ5/FWCyLvUg0BLduTjyQv5ECzpByR9x5Cv5EibqbGGjylfauTYlJAv3a+569ZecSmgqFrjDdNnrPMiULbYmGORAJaJILchaejRrCO+pSMf7oSRF0vwj5iSJ21vhZBPWxyPbW2MYriiXpBo2VFMqXNt+Clbf1yuojt/3ojIoladOnIuoO7nXdKcm5QHjlOZy8nnVvmSY3hB6YYeOOxEjGTatH6om8F6pc/P2IVpCQOqNmqXLqewJ+R1NxmryJSdpQ2hREqZtOb5JxCEFha6wKcSfPbfWVOap1ZrsaasXQadYB+iCX0FZd52cQ212SkcckElImPEIz9WSsZxR4RHrEEl2enQDyBT8KhfeGe5x/5wXJIxq0Joip4QckafvPTb54ES/4NgotzxxwlQaqVp9BCWjlbT0NqPJFdLivOjoKHLQqvMqpshI5A36118UVg0ePFCKN3oRBCjG0c34xFlZI1k+mMKJ6Mq37bqpBfkIBouoKeqI+A/ap6ZoyyaM0n6CtZIkjrPdSpgqCBANX0J6kY8T05MzHug6J6iRP+uTlexa8jFGEkzr5Pv3/bIxZ1XYSpmhO1VIwE/Ldj5WZ81ElDdHCGd7HT3oU7Fk6T/LVpBNDSwFIMBbX4YUKrVAJXYUZzCuQDUZ2lsnxRml5hzj5qvdVuUQwLJ9m3iOzfw/icEU3/tnPssKNHExneDjXeLf5tZO8NK/GpmtQpfzy8quu9e4toK+bnf52vDHgQj76Z48C+KFsD7QUtdViQYnD647OEsW+12g1v+VhBwncEoEybE2b0bUc9N2g+bh1Xy/62WHTGP4wtIIUOcfNDC53aB3FJ/1RIhA L6J1RWiN xrQ6X0udeNAIWNbW3b0G4WSX7vCZzfXzsHKnUUubNQVTsoOEo4MiS834Dol0n8SG9oMiSRGL8iB67PiAFV1CBaXdTVjuzB2l7aKCguKjGoGczHb/iKwW6OOCvIB1MJrtWZAWJQpi8LhbK1+eMQPCYAjHVT5ZBRt5J8XtPrFjuz1je8GKxNMxJVVtovcUjdzkE+rsXINQi9G8cBlW3/mQFBDCV3IRiOXCnlw6BdG/6A8MBaHy8gP0fQG+NQTnuQNQzw2r15txNfzuzLG6Ufnxw5Ddyr15DyfMnbSfG 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 accesses to page->index and page->mapping. Also use folio APIs where available. This code still assumes order 0 folios. Signed-off-by: Matthew Wilcox (Oracle) --- fs/squashfs/file.c | 46 ++++++++++++++++++++++------------------ fs/squashfs/file_cache.c | 2 +- fs/squashfs/squashfs.h | 4 ++-- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c index 5b81e26b1226..1f27e8161319 100644 --- a/fs/squashfs/file.c +++ b/fs/squashfs/file.c @@ -378,13 +378,15 @@ void squashfs_fill_page(struct page *page, struct squashfs_cache_entry *buffer, } /* Copy data into page cache */ -void squashfs_copy_cache(struct page *page, struct squashfs_cache_entry *buffer, - int bytes, int offset) +void squashfs_copy_cache(struct folio *folio, + struct squashfs_cache_entry *buffer, size_t bytes, + size_t offset) { - struct inode *inode = page->mapping->host; + struct address_space *mapping = folio->mapping; + struct inode *inode = mapping->host; struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info; int i, mask = (1 << (msblk->block_log - PAGE_SHIFT)) - 1; - int start_index = page->index & ~mask, end_index = start_index | mask; + int start_index = folio->index & ~mask, end_index = start_index | mask; /* * Loop copying datablock into pages. As the datablock likely covers @@ -394,25 +396,27 @@ void squashfs_copy_cache(struct page *page, struct squashfs_cache_entry *buffer, */ for (i = start_index; i <= end_index && bytes > 0; i++, bytes -= PAGE_SIZE, offset += PAGE_SIZE) { - struct page *push_page; - int avail = buffer ? min_t(int, bytes, PAGE_SIZE) : 0; + struct folio *push_folio; + size_t avail = buffer ? min(bytes, PAGE_SIZE) : 0; - TRACE("bytes %d, i %d, available_bytes %d\n", bytes, i, avail); + TRACE("bytes %zu, i %d, available_bytes %zu\n", bytes, i, avail); - push_page = (i == page->index) ? page : - grab_cache_page_nowait(page->mapping, i); + push_folio = (i == folio->index) ? folio : + __filemap_get_folio(mapping, i, + FGP_LOCK|FGP_CREAT|FGP_NOFS|FGP_NOWAIT, + mapping_gfp_mask(mapping)); - if (!push_page) + if (!push_folio) continue; - if (PageUptodate(push_page)) - goto skip_page; + if (folio_test_uptodate(push_folio)) + goto skip_folio; - squashfs_fill_page(push_page, buffer, offset, avail); -skip_page: - unlock_page(push_page); - if (i != page->index) - put_page(push_page); + squashfs_fill_page(&push_folio->page, buffer, offset, avail); +skip_folio: + folio_unlock(push_folio); + if (i != folio->index) + folio_put(push_folio); } } @@ -430,16 +434,16 @@ static int squashfs_readpage_fragment(struct folio *folio, int expected) squashfs_i(inode)->fragment_block, squashfs_i(inode)->fragment_size); else - squashfs_copy_cache(&folio->page, buffer, expected, + squashfs_copy_cache(folio, buffer, expected, squashfs_i(inode)->fragment_offset); squashfs_cache_put(buffer); return res; } -static int squashfs_readpage_sparse(struct page *page, int expected) +static int squashfs_readpage_sparse(struct folio *folio, int expected) { - squashfs_copy_cache(page, NULL, expected, 0); + squashfs_copy_cache(folio, NULL, expected, 0); return 0; } @@ -470,7 +474,7 @@ static int squashfs_read_folio(struct file *file, struct folio *folio) goto out; if (res == 0) - res = squashfs_readpage_sparse(&folio->page, expected); + res = squashfs_readpage_sparse(folio, expected); else res = squashfs_readpage_block(folio, block, res, expected); } else diff --git a/fs/squashfs/file_cache.c b/fs/squashfs/file_cache.c index 0360d22a77d4..40e59a43d098 100644 --- a/fs/squashfs/file_cache.c +++ b/fs/squashfs/file_cache.c @@ -29,7 +29,7 @@ int squashfs_readpage_block(struct folio *folio, u64 block, int bsize, int expec ERROR("Unable to read page, block %llx, size %x\n", block, bsize); else - squashfs_copy_cache(&folio->page, buffer, expected, 0); + squashfs_copy_cache(folio, buffer, expected, 0); squashfs_cache_put(buffer); return res; diff --git a/fs/squashfs/squashfs.h b/fs/squashfs/squashfs.h index 0f5373479516..9295556ecfd0 100644 --- a/fs/squashfs/squashfs.h +++ b/fs/squashfs/squashfs.h @@ -68,8 +68,8 @@ extern __le64 *squashfs_read_fragment_index_table(struct super_block *, /* file.c */ void squashfs_fill_page(struct page *, struct squashfs_cache_entry *, int, int); -void squashfs_copy_cache(struct page *, struct squashfs_cache_entry *, int, - int); +void squashfs_copy_cache(struct folio *, struct squashfs_cache_entry *, + size_t bytes, size_t offset); /* file_xxx.c */ int squashfs_readpage_block(struct folio *, u64 block, int bsize, int expected); From patchwork Mon Dec 16 16:26:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13910026 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 04AB4E7717F for ; Mon, 16 Dec 2024 16:27:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A70D8D0005; Mon, 16 Dec 2024 11:27:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 43A838D0001; Mon, 16 Dec 2024 11:27:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2DA998D0005; Mon, 16 Dec 2024 11:27:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 0BAC58D0001 for ; Mon, 16 Dec 2024 11:27:08 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B7983120F5A for ; Mon, 16 Dec 2024 16:27:07 +0000 (UTC) X-FDA: 82901350980.15.E2C7B33 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf02.hostedemail.com (Postfix) with ESMTP id 9575680015 for ; Mon, 16 Dec 2024 16:26:09 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Lc3tibBp; dmarc=none; spf=none (imf02.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=1734366398; a=rsa-sha256; cv=none; b=zFHR5VJnt+cr69elvn6E4VloChgDFEZdBS1PziXkGnjR7c++rse2JIW0Luc/ww2F9qpueP rVtIcm1/6k/cjohrvO1sLH9YhX3SMoyqc9gU9Iyyw9yTbVSlNVyxYL+pRBbu+gicK4JEwN cLIUy4/BdRXEzhKlMvPWwdS+UMPnlGo= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Lc3tibBp; dmarc=none; spf=none (imf02.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=1734366398; 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=VPTyDxUHivha6vOfKSiWFl06XFZgbVdwCU6/eNtqKN4=; b=qDuK8Df8S+2w/9/72v+w3+G2+ykzPrES2VMXUGKJeiEd7OxFSLM3+YQ5v4CuvNoguA1fsf H8cdPJ4kzzT5mTB2kO6VOPDcJIqVUx5ZMJ7QbcMElkZzckE8qbxMb2/xlVTQH8sUb0L9O6 xCRaozaTRXlqNSsjJJ1KuRjcAEVQz7M= 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=VPTyDxUHivha6vOfKSiWFl06XFZgbVdwCU6/eNtqKN4=; b=Lc3tibBpW1UW49d2XMpimwGnes CannalWtmj3JSZXr2sQajB4R+Oq5xsxzUkSxGNkNprVh/y3Qx4pHgypZiakr9Q0IWWXxF6c/sXjKh n14H967WfKO4PistaRZk1ctE2vq773Sv8q7NAnIFGsryfoMel6XY7flrL2ZR04tUBBi41/ZHEML1Y GxaPLcNVpV8JdiIu+KydK67ztam7lirenDvLf8fr4H3lUNl8JJIyMLJxooWluYFHU9W+GcskjaOBd CyCTRE/wJpjApy5fVUDgFlqyXi/pdkrZN2mQs1lynMwuPV8smd10nS3TjjgVlHEPnzZOB32N0JwKC PYACMDqQ==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tNDw0-00000000EzA-29FW; Mon, 16 Dec 2024 16:27:04 +0000 From: "Matthew Wilcox (Oracle)" To: Phillip Lougher Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 5/5] squashfs: Convert squashfs_fill_page() to take a folio Date: Mon, 16 Dec 2024 16:26:59 +0000 Message-ID: <20241216162701.57549-5-willy@infradead.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241216162701.57549-1-willy@infradead.org> References: <20241216162701.57549-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 9575680015 X-Stat-Signature: xtp4x4xfb8uctbhj9gpifuircgggi1xx X-Rspam-User: X-HE-Tag: 1734366369-489014 X-HE-Meta: U2FsdGVkX19hApxQv5V5gJ8+hCCdedFNrW1GQxXMweojlH9wM8+PezZDJ6OhR0M+7GEKKNSj+OnWXKUHlzWutFCfl6IP4cTl6LeHOVvrLBPxXFdKQovPUtL116kwuSkrIWIOiGBuUMHXChuaGAw5X48Q98UAp20w2mQsrJ1m9SNmc7wCV6jtPEqKAKxnTVo3xHGCTL47HMk8Z1QevauPa671qb1piz/Jhk7O/R4s7F/RAwJ17NkZonw0CiCQtDE+3sLlhtMq/jsKmc8P+BskNaWv4GBHJxkc2M4LCMeh/Oxmvrds0quUnqAVBsRC2hn3MK4f8ZzHRu0rNmyHJ3bLnEMjlNNSC0M86EeCRGSW16uyzcqakzSSVlwR2RbdjLDrgGtGfIQROL212V499vpU9z9fwRGjmNuyvS1+Sqs6ohW4gAwi/JNzLStVybn7H19TKlrwIaZK8tRIJVGxha/9ToeanXEwtbOI2pm0lCDiOw6+bnP0tSMVcAQuM5xF55JtuUF6hr+CK2X3NXTzd4O0s2dHMsZducT2a0g6m0usk7ZvgTYrRG+vR04LUnhlOnCZUzwf0yeleVBw9q5JszGk4db+anAthJClRSdXrew6VNedxKlD4wx6PUnL3FHnIjsFMLIk00oR94FzvW/0xERPO92nKzy8bzPFN6Fk0Pj48QVqxn1MymCi8QyPYhYgBG1XXnDjVYbsE8ImgtBEkGmuKEWRPLmSA8DLJG3PyUh+mWnNZl44kGPt2/e+ZqRPjp3cQ2d8KQNsYq5GHh3NOXuDRuKJK5yaZRkA9mkMAyFTaL546/PcXzVJIDRHgh9L0cgtX5NkLauLhKJxD09a6P49GAhbqA/HmEtuQdCFWp8KhyTNEoNUJtMdSXSkOhob1OZlFWz/tnhAVwuvG2os2G/FBz2bOMvBDbt4ktcGjrS3bsPs4gUYntvkGma+WNKxSt1hx2skFUUBR4FZzNNsyAs zSpKMG6A LCWHlX7ZX8fowFVdwlBXmP0OA4Dj0w0guJH3NS68e6Ai1gvbiE8L7HrSxzfSmf38ZmplbCHKE6KHeViXKzvL35um+b1hKNSSsWBQ5PV+M3Z1xPKkx9hlAQTep/6he0tYx6Wyaz6WwWSt93utnNEWHlTHxZF8HBo3BFKO1dQbWRPo65Zm+crC74U6y+u2L4wPpj3hqbxX5wWH1Z2zIvqpDwklj4PD1sW8X+ZxEy3A05g1gly4s9rSU5pu4rAjVimWbT3pHQ8zNrxS/RtM1uHjBvm1k8q9FZR2Qqp6d 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: squashfs_fill_page is only used in this file, so make it static. Use kmap_local instead of kmap_atomic, and return a bool so that the caller can use folio_end_read() which saves an atomic operation over calling folio_mark_uptodate() followed by folio_unlock(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/squashfs/file.c | 21 ++++++++++++--------- fs/squashfs/squashfs.h | 1 - 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c index 1f27e8161319..d363fb26c2c8 100644 --- a/fs/squashfs/file.c +++ b/fs/squashfs/file.c @@ -362,19 +362,21 @@ static int read_blocklist(struct inode *inode, int index, u64 *block) return squashfs_block_size(size); } -void squashfs_fill_page(struct page *page, struct squashfs_cache_entry *buffer, int offset, int avail) +static bool squashfs_fill_page(struct folio *folio, + struct squashfs_cache_entry *buffer, size_t offset, + size_t avail) { - int copied; + size_t copied; void *pageaddr; - pageaddr = kmap_atomic(page); + pageaddr = kmap_local_folio(folio, 0); copied = squashfs_copy_data(pageaddr, buffer, offset, avail); memset(pageaddr + copied, 0, PAGE_SIZE - copied); - kunmap_atomic(pageaddr); + kunmap_local(pageaddr); - flush_dcache_page(page); - if (copied == avail) - SetPageUptodate(page); + flush_dcache_folio(folio); + + return copied == avail; } /* Copy data into page cache */ @@ -398,6 +400,7 @@ void squashfs_copy_cache(struct folio *folio, bytes -= PAGE_SIZE, offset += PAGE_SIZE) { struct folio *push_folio; size_t avail = buffer ? min(bytes, PAGE_SIZE) : 0; + bool filled = false; TRACE("bytes %zu, i %d, available_bytes %zu\n", bytes, i, avail); @@ -412,9 +415,9 @@ void squashfs_copy_cache(struct folio *folio, if (folio_test_uptodate(push_folio)) goto skip_folio; - squashfs_fill_page(&push_folio->page, buffer, offset, avail); + filled = squashfs_fill_page(push_folio, buffer, offset, avail); skip_folio: - folio_unlock(push_folio); + folio_end_read(folio, filled); if (i != folio->index) folio_put(push_folio); } diff --git a/fs/squashfs/squashfs.h b/fs/squashfs/squashfs.h index 9295556ecfd0..37f3518a804a 100644 --- a/fs/squashfs/squashfs.h +++ b/fs/squashfs/squashfs.h @@ -67,7 +67,6 @@ extern __le64 *squashfs_read_fragment_index_table(struct super_block *, u64, u64, unsigned int); /* file.c */ -void squashfs_fill_page(struct page *, struct squashfs_cache_entry *, int, int); void squashfs_copy_cache(struct folio *, struct squashfs_cache_entry *, size_t bytes, size_t offset);