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);