]> www.infradead.org Git - users/willy/linux.git/commitdiff
iomap: Convert __iomap_zero_iter to use a folio
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 5 Nov 2021 18:24:09 +0000 (14:24 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Sat, 18 Dec 2021 05:06:07 +0000 (00:06 -0500)
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>
fs/iomap/buffered-io.c

index b1ded5204d1c450fbf1b2370e2d5473d420a3274..47cf558244f4388d879b30d5731d7aa7fb4e1594 100644 (file)
@@ -893,19 +893,23 @@ EXPORT_SYMBOL_GPL(iomap_file_unshare);
 
 static s64 __iomap_zero_iter(struct iomap_iter *iter, loff_t pos, u64 length)
 {
+       struct folio *folio;
        struct page *page;
        int status;
-       unsigned offset = offset_in_page(pos);
+       size_t offset;
        unsigned bytes = min_t(u64, UINT_MAX, length);
 
        status = iomap_write_begin(iter, pos, bytes, &page);
        if (status)
                return status;
-       if (bytes > PAGE_SIZE - offset)
-               bytes = PAGE_SIZE - offset;
+       folio = page_folio(page);
+
+       offset = offset_in_folio(folio, pos);
+       if (bytes > folio_size(folio) - offset)
+               bytes = folio_size(folio) - offset;
 
-       zero_user(page, offset, bytes);
-       mark_page_accessed(page);
+       folio_zero_range(folio, offset, bytes);
+       folio_mark_accessed(folio);
 
        return iomap_write_end(iter, pos, bytes, bytes, page);
 }