From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: Phillip Lougher <phillip@squashfs.org.uk>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
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 [thread overview]
Message-ID: <20241216162701.57549-5-willy@infradead.org> (raw)
In-Reply-To: <20241216162701.57549-1-willy@infradead.org>
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) <willy@infradead.org>
---
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);
--
2.45.2
next prev parent reply other threads:[~2024-12-16 16:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-16 16:26 [PATCH 1/5] squashfs: Use a folio throughout squashfs_read_folio() Matthew Wilcox (Oracle)
2024-12-16 16:26 ` [PATCH 2/5] squashfs: Pass a folio to squashfs_readpage_fragment() Matthew Wilcox (Oracle)
2025-01-14 21:08 ` Phillip Lougher
2024-12-16 16:26 ` [PATCH 3/5] squashfs: Convert squashfs_readpage_block() to take a folio Matthew Wilcox (Oracle)
2025-01-14 21:08 ` Phillip Lougher
2024-12-16 16:26 ` [PATCH 4/5] squashfs; Convert squashfs_copy_cache() " Matthew Wilcox (Oracle)
2025-01-14 21:08 ` Phillip Lougher
2024-12-16 16:26 ` Matthew Wilcox (Oracle) [this message]
2024-12-20 18:19 ` [PATCH 5/5] squashfs: Convert squashfs_fill_page() " Phillip Lougher
2024-12-20 18:19 ` Phillip Lougher
2024-12-20 18:24 ` Matthew Wilcox
2024-12-20 18:42 ` Phillip Lougher
2024-12-20 22:19 ` Andrew Morton
2025-01-14 21:08 ` Phillip Lougher
2025-01-14 21:07 ` [PATCH 1/5] squashfs: Use a folio throughout squashfs_read_folio() Phillip Lougher
2025-01-14 21:10 ` Phillip Lougher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241216162701.57549-5-willy@infradead.org \
--to=willy@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=phillip@squashfs.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox