Merge tag 'f2fs-for-6.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk...
[linux-2.6-block.git] / fs / f2fs / node.c
index 19a1fee88a363aaba57065dc6fb86f5934492fea..bd1dad5237967686a3d5359423c5e43157b3abe7 100644 (file)
@@ -1518,23 +1518,24 @@ iput_out:
 static struct page *last_fsync_dnode(struct f2fs_sb_info *sbi, nid_t ino)
 {
        pgoff_t index;
-       struct pagevec pvec;
+       struct folio_batch fbatch;
        struct page *last_page = NULL;
-       int nr_pages;
+       int nr_folios;
 
-       pagevec_init(&pvec);
+       folio_batch_init(&fbatch);
        index = 0;
 
-       while ((nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
-                               PAGECACHE_TAG_DIRTY))) {
+       while ((nr_folios = filemap_get_folios_tag(NODE_MAPPING(sbi), &index,
+                                       (pgoff_t)-1, PAGECACHE_TAG_DIRTY,
+                                       &fbatch))) {
                int i;
 
-               for (i = 0; i < nr_pages; i++) {
-                       struct page *page = pvec.pages[i];
+               for (i = 0; i < nr_folios; i++) {
+                       struct page *page = &fbatch.folios[i]->page;
 
                        if (unlikely(f2fs_cp_error(sbi))) {
                                f2fs_put_page(last_page, 0);
-                               pagevec_release(&pvec);
+                               folio_batch_release(&fbatch);
                                return ERR_PTR(-EIO);
                        }
 
@@ -1565,7 +1566,7 @@ continue_unlock:
                        last_page = page;
                        unlock_page(page);
                }
-               pagevec_release(&pvec);
+               folio_batch_release(&fbatch);
                cond_resched();
        }
        return last_page;
@@ -1730,12 +1731,12 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
                        unsigned int *seq_id)
 {
        pgoff_t index;
-       struct pagevec pvec;
+       struct folio_batch fbatch;
        int ret = 0;
        struct page *last_page = NULL;
        bool marked = false;
        nid_t ino = inode->i_ino;
-       int nr_pages;
+       int nr_folios;
        int nwritten = 0;
 
        if (atomic) {
@@ -1744,20 +1745,21 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
                        return PTR_ERR_OR_ZERO(last_page);
        }
 retry:
-       pagevec_init(&pvec);
+       folio_batch_init(&fbatch);
        index = 0;
 
-       while ((nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
-                               PAGECACHE_TAG_DIRTY))) {
+       while ((nr_folios = filemap_get_folios_tag(NODE_MAPPING(sbi), &index,
+                                       (pgoff_t)-1, PAGECACHE_TAG_DIRTY,
+                                       &fbatch))) {
                int i;
 
-               for (i = 0; i < nr_pages; i++) {
-                       struct page *page = pvec.pages[i];
+               for (i = 0; i < nr_folios; i++) {
+                       struct page *page = &fbatch.folios[i]->page;
                        bool submitted = false;
 
                        if (unlikely(f2fs_cp_error(sbi))) {
                                f2fs_put_page(last_page, 0);
-                               pagevec_release(&pvec);
+                               folio_batch_release(&fbatch);
                                ret = -EIO;
                                goto out;
                        }
@@ -1823,7 +1825,7 @@ continue_unlock:
                                break;
                        }
                }
-               pagevec_release(&pvec);
+               folio_batch_release(&fbatch);
                cond_resched();
 
                if (ret || marked)
@@ -1888,17 +1890,18 @@ static bool flush_dirty_inode(struct page *page)
 void f2fs_flush_inline_data(struct f2fs_sb_info *sbi)
 {
        pgoff_t index = 0;
-       struct pagevec pvec;
-       int nr_pages;
+       struct folio_batch fbatch;
+       int nr_folios;
 
-       pagevec_init(&pvec);
+       folio_batch_init(&fbatch);
 
-       while ((nr_pages = pagevec_lookup_tag(&pvec,
-                       NODE_MAPPING(sbi), &index, PAGECACHE_TAG_DIRTY))) {
+       while ((nr_folios = filemap_get_folios_tag(NODE_MAPPING(sbi), &index,
+                                       (pgoff_t)-1, PAGECACHE_TAG_DIRTY,
+                                       &fbatch))) {
                int i;
 
-               for (i = 0; i < nr_pages; i++) {
-                       struct page *page = pvec.pages[i];
+               for (i = 0; i < nr_folios; i++) {
+                       struct page *page = &fbatch.folios[i]->page;
 
                        if (!IS_DNODE(page))
                                continue;
@@ -1925,7 +1928,7 @@ continue_unlock:
                        }
                        unlock_page(page);
                }
-               pagevec_release(&pvec);
+               folio_batch_release(&fbatch);
                cond_resched();
        }
 }
@@ -1935,23 +1938,24 @@ int f2fs_sync_node_pages(struct f2fs_sb_info *sbi,
                                bool do_balance, enum iostat_type io_type)
 {
        pgoff_t index;
-       struct pagevec pvec;
+       struct folio_batch fbatch;
        int step = 0;
        int nwritten = 0;
        int ret = 0;
-       int nr_pages, done = 0;
+       int nr_folios, done = 0;
 
-       pagevec_init(&pvec);
+       folio_batch_init(&fbatch);
 
 next_step:
        index = 0;
 
-       while (!done && (nr_pages = pagevec_lookup_tag(&pvec,
-                       NODE_MAPPING(sbi), &index, PAGECACHE_TAG_DIRTY))) {
+       while (!done && (nr_folios = filemap_get_folios_tag(NODE_MAPPING(sbi),
+                               &index, (pgoff_t)-1, PAGECACHE_TAG_DIRTY,
+                               &fbatch))) {
                int i;
 
-               for (i = 0; i < nr_pages; i++) {
-                       struct page *page = pvec.pages[i];
+               for (i = 0; i < nr_folios; i++) {
+                       struct page *page = &fbatch.folios[i]->page;
                        bool submitted = false;
 
                        /* give a priority to WB_SYNC threads */
@@ -2026,7 +2030,7 @@ write_node:
                        if (--wbc->nr_to_write == 0)
                                break;
                }
-               pagevec_release(&pvec);
+               folio_batch_release(&fbatch);
                cond_resched();
 
                if (wbc->nr_to_write == 0) {