Skip to content

Commit a25def1

Browse files
author
Matthew Wilcox (Oracle)
committed
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) <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]>
1 parent d454ab8 commit a25def1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

fs/iomap/buffered-io.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -893,19 +893,23 @@ EXPORT_SYMBOL_GPL(iomap_file_unshare);
893893

894894
static s64 __iomap_zero_iter(struct iomap_iter *iter, loff_t pos, u64 length)
895895
{
896+
struct folio *folio;
896897
struct page *page;
897898
int status;
898-
unsigned offset = offset_in_page(pos);
899+
size_t offset;
899900
unsigned bytes = min_t(u64, UINT_MAX, length);
900901

901902
status = iomap_write_begin(iter, pos, bytes, &page);
902903
if (status)
903904
return status;
904-
if (bytes > PAGE_SIZE - offset)
905-
bytes = PAGE_SIZE - offset;
905+
folio = page_folio(page);
906+
907+
offset = offset_in_folio(folio, pos);
908+
if (bytes > folio_size(folio) - offset)
909+
bytes = folio_size(folio) - offset;
906910

907-
zero_user(page, offset, bytes);
908-
mark_page_accessed(page);
911+
folio_zero_range(folio, offset, bytes);
912+
folio_mark_accessed(folio);
909913

910914
return iomap_write_end(iter, pos, bytes, bytes, page);
911915
}

0 commit comments

Comments
 (0)