Commit d4a16d31 authored by Vishal Moola (Oracle)'s avatar Vishal Moola (Oracle) Committed by Andrew Morton

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.comSigned-off-by: default avatarVishal Moola (Oracle) <vishal.moola@gmail.com>
Acked-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 41f3f3b5
......@@ -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))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment