nilfs2: convert nilfs_copy_dirty_pages() to use filemap_get_folios_tag()

Convert function to use folios throughout.  This is in preparation for the
removal of find_get_pages_range_tag().  This change removes 8 calls to
compound_head().

Link: https://lkml.kernel.org/r/20230104211448.4804-22-vishal.moola@gmail.com
Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Acked-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
Vishal Moola (Oracle) 2023-01-04 13:14:46 -08:00 committed by Andrew Morton
parent 41f3f3b537
commit d4a16d3133
1 changed files with 20 additions and 19 deletions

View File

@ -240,42 +240,43 @@ static void nilfs_copy_page(struct page *dst, struct page *src, int copy_dirty)
int nilfs_copy_dirty_pages(struct address_space *dmap,
struct address_space *smap)
{
struct pagevec pvec;
struct folio_batch fbatch;
unsigned int i;
pgoff_t index = 0;
int err = 0;
pagevec_init(&pvec);
folio_batch_init(&fbatch);
repeat:
if (!pagevec_lookup_tag(&pvec, smap, &index, PAGECACHE_TAG_DIRTY))
if (!filemap_get_folios_tag(smap, &index, (pgoff_t)-1,
PAGECACHE_TAG_DIRTY, &fbatch))
return 0;
for (i = 0; i < pagevec_count(&pvec); i++) {
struct page *page = pvec.pages[i], *dpage;
for (i = 0; i < folio_batch_count(&fbatch); i++) {
struct folio *folio = fbatch.folios[i], *dfolio;
lock_page(page);
if (unlikely(!PageDirty(page)))
NILFS_PAGE_BUG(page, "inconsistent dirty state");
folio_lock(folio);
if (unlikely(!folio_test_dirty(folio)))
NILFS_PAGE_BUG(&folio->page, "inconsistent dirty state");
dpage = grab_cache_page(dmap, page->index);
if (unlikely(!dpage)) {
dfolio = filemap_grab_folio(dmap, folio->index);
if (unlikely(!dfolio)) {
/* No empty page is added to the page cache */
err = -ENOMEM;
unlock_page(page);
folio_unlock(folio);
break;
}
if (unlikely(!page_has_buffers(page)))
NILFS_PAGE_BUG(page,
if (unlikely(!folio_buffers(folio)))
NILFS_PAGE_BUG(&folio->page,
"found empty page in dat page cache");
nilfs_copy_page(dpage, page, 1);
__set_page_dirty_nobuffers(dpage);
nilfs_copy_page(&dfolio->page, &folio->page, 1);
filemap_dirty_folio(folio_mapping(dfolio), dfolio);
unlock_page(dpage);
put_page(dpage);
unlock_page(page);
folio_unlock(dfolio);
folio_put(dfolio);
folio_unlock(folio);
}
pagevec_release(&pvec);
folio_batch_release(&fbatch);
cond_resched();
if (likely(!err))