pagecache_isize_extended
Subsystems (3)
Matthew Wilcox
maintainerRFC 1/1 pagecache_isize_extended
I hadn't looked at pagecache_isize_extended() before, and I'm not entirely sure it's doing the right thing for large folios. Usually we decline to create folios which extend past EOF [1], and we try to split folios on truncate. But folio splitting can fail, and I think we might run into problems with a store to a folio which straddles i_size.
Do we have any xfstests which cover this? I'm not quite sure how to write such a test.
[1] or at least EOF rounded up to PAGE_SIZE
mm/truncate.c +9 -11
@@ -781,8 +781,7 @@ void pagecache_isize_extended(struct inode *inode, loff_t from, loff_t to) {int bsize =i_blocksize (inode);loff_t rounded_from; -struct page *page; -pgoff_t index; +struct folio *folio;WARN_ON (to > inode->i_size);
@@ -793,19 +792,18 @@ void pagecache_isize_extended(struct inode *inode, loff_t from, loff_t to)if (to <= rounded_from || !(rounded_from & (PAGE_SIZE -1 )))return ; - index = from >>PAGE_SHIFT ; - page =find_lock_page (inode->i_mapping, index); -/* Page not cached? Nothing to do */ -if (!page) + folio =filemap_lock_folio (inode->i_mapping, from /PAGE_SIZE ); +/* Folio not cached? Nothing to do */ +if (!folio)return ;/* -* See clear_page_dirty_for_io() for details why set_page_dirty() +* See folio_clear_dirty_for_io() for details why folio_mark_dirty() * is needed. */ -if (page_mkclean (page)) -set_page_dirty (page); -unlock_page (page); -put_page (page); +if (folio_mkclean (folio)) +folio_mark_dirty (folio); +folio_unlock (folio); +folio_put (folio); }EXPORT_SYMBOL (pagecache_isize_extended);