mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-06 19:07:52 +00:00
iomap: Convert __iomap_zero_iter to use a folio
The zero iterator can work in folio-sized chunks instead of page-sized chunks. This will save a lot of page cache lookups if the file is cached in large folios. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
This commit is contained in:
parent
d454ab82bc
commit
a25def1fe5
1 changed files with 9 additions and 5 deletions
|
@ -893,19 +893,23 @@ EXPORT_SYMBOL_GPL(iomap_file_unshare);
|
||||||
|
|
||||||
static s64 __iomap_zero_iter(struct iomap_iter *iter, loff_t pos, u64 length)
|
static s64 __iomap_zero_iter(struct iomap_iter *iter, loff_t pos, u64 length)
|
||||||
{
|
{
|
||||||
|
struct folio *folio;
|
||||||
struct page *page;
|
struct page *page;
|
||||||
int status;
|
int status;
|
||||||
unsigned offset = offset_in_page(pos);
|
size_t offset;
|
||||||
unsigned bytes = min_t(u64, UINT_MAX, length);
|
unsigned bytes = min_t(u64, UINT_MAX, length);
|
||||||
|
|
||||||
status = iomap_write_begin(iter, pos, bytes, &page);
|
status = iomap_write_begin(iter, pos, bytes, &page);
|
||||||
if (status)
|
if (status)
|
||||||
return status;
|
return status;
|
||||||
if (bytes > PAGE_SIZE - offset)
|
folio = page_folio(page);
|
||||||
bytes = PAGE_SIZE - offset;
|
|
||||||
|
|
||||||
zero_user(page, offset, bytes);
|
offset = offset_in_folio(folio, pos);
|
||||||
mark_page_accessed(page);
|
if (bytes > folio_size(folio) - offset)
|
||||||
|
bytes = folio_size(folio) - offset;
|
||||||
|
|
||||||
|
folio_zero_range(folio, offset, bytes);
|
||||||
|
folio_mark_accessed(folio);
|
||||||
|
|
||||||
return iomap_write_end(iter, pos, bytes, bytes, page);
|
return iomap_write_end(iter, pos, bytes, bytes, page);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue