]> 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>
Thu, 9 Dec 2021 21:07:50 +0000 (16:07 -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 67fcd3b9928d75fef1744165d8de8e983d1bb1a5..bbde6d4f27cd774fdddfd6368ee0eb6bccb4e4dc 100644 (file)
@@ -890,20 +890,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;
 
        if (length > UINT_MAX)
                length = UINT_MAX;
        status = iomap_write_begin(iter, pos, length, &page);
        if (status)
                return status;
-       if (length > PAGE_SIZE - offset)
-               length = PAGE_SIZE - offset;
+       folio = page_folio(page);
 
-       zero_user(page, offset, length);
-       mark_page_accessed(page);
+       offset = offset_in_folio(folio, pos);
+       if (length > folio_size(folio) - offset)
+               length = folio_size(folio) - offset;
+       folio_zero_range(folio, offset, length);
+       folio_mark_accessed(folio);
 
        return iomap_write_end(iter, pos, length, length, page);
 }