linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: linux-fsdevel@vger.kernel.org
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net, linux-mm@kvack.org,
	linux-nilfs@vger.kernel.org
Subject: [PATCH 07/10] nilfs2: Convert nilfs_copy_back_pages() to use filemap_get_folios()
Date: Sun,  5 Jun 2022 20:38:51 +0100	[thread overview]
Message-ID: <20220605193854.2371230-8-willy@infradead.org> (raw)
In-Reply-To: <20220605193854.2371230-1-willy@infradead.org>

Use folios throughout.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/nilfs2/page.c | 60 ++++++++++++++++++++++++------------------------
 1 file changed, 30 insertions(+), 30 deletions(-)

diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c
index a8e88cc38e16..3267e96c256c 100644
--- a/fs/nilfs2/page.c
+++ b/fs/nilfs2/page.c
@@ -294,57 +294,57 @@ int nilfs_copy_dirty_pages(struct address_space *dmap,
 void nilfs_copy_back_pages(struct address_space *dmap,
 			   struct address_space *smap)
 {
-	struct pagevec pvec;
+	struct folio_batch fbatch;
 	unsigned int i, n;
-	pgoff_t index = 0;
+	pgoff_t start = 0;
 
-	pagevec_init(&pvec);
+	folio_batch_init(&fbatch);
 repeat:
-	n = pagevec_lookup(&pvec, smap, &index);
+	n = filemap_get_folios(smap, &start, ~0UL, &fbatch);
 	if (!n)
 		return;
 
-	for (i = 0; i < pagevec_count(&pvec); i++) {
-		struct page *page = pvec.pages[i], *dpage;
-		pgoff_t offset = page->index;
-
-		lock_page(page);
-		dpage = find_lock_page(dmap, offset);
-		if (dpage) {
-			/* overwrite existing page in the destination cache */
-			WARN_ON(PageDirty(dpage));
-			nilfs_copy_page(dpage, page, 0);
-			unlock_page(dpage);
-			put_page(dpage);
-			/* Do we not need to remove page from smap here? */
+	for (i = 0; i < folio_batch_count(&fbatch); i++) {
+		struct folio *folio = fbatch.folios[i], *dfolio;
+		pgoff_t index = folio->index;
+
+		folio_lock(folio);
+		dfolio = filemap_lock_folio(dmap, index);
+		if (dfolio) {
+			/* overwrite existing folio in the destination cache */
+			WARN_ON(folio_test_dirty(dfolio));
+			nilfs_copy_page(&dfolio->page, &folio->page, 0);
+			folio_unlock(dfolio);
+			folio_put(dfolio);
+			/* Do we not need to remove folio from smap here? */
 		} else {
-			struct page *p;
+			struct folio *f;
 
-			/* move the page to the destination cache */
+			/* move the folio to the destination cache */
 			xa_lock_irq(&smap->i_pages);
-			p = __xa_erase(&smap->i_pages, offset);
-			WARN_ON(page != p);
+			f = __xa_erase(&smap->i_pages, index);
+			WARN_ON(folio != f);
 			smap->nrpages--;
 			xa_unlock_irq(&smap->i_pages);
 
 			xa_lock_irq(&dmap->i_pages);
-			p = __xa_store(&dmap->i_pages, offset, page, GFP_NOFS);
-			if (unlikely(p)) {
+			f = __xa_store(&dmap->i_pages, index, folio, GFP_NOFS);
+			if (unlikely(f)) {
 				/* Probably -ENOMEM */
-				page->mapping = NULL;
-				put_page(page);
+				folio->mapping = NULL;
+				folio_put(folio);
 			} else {
-				page->mapping = dmap;
+				folio->mapping = dmap;
 				dmap->nrpages++;
-				if (PageDirty(page))
-					__xa_set_mark(&dmap->i_pages, offset,
+				if (folio_test_dirty(folio))
+					__xa_set_mark(&dmap->i_pages, index,
 							PAGECACHE_TAG_DIRTY);
 			}
 			xa_unlock_irq(&dmap->i_pages);
 		}
-		unlock_page(page);
+		folio_unlock(folio);
 	}
-	pagevec_release(&pvec);
+	folio_batch_release(&fbatch);
 	cond_resched();
 
 	goto repeat;
-- 
2.35.1


  parent reply	other threads:[~2022-06-05 19:39 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-05 19:38 [PATCH 00/10] Convert to filemap_get_folios() Matthew Wilcox (Oracle)
2022-06-05 19:38 ` [PATCH 01/10] filemap: Add filemap_get_folios() Matthew Wilcox (Oracle)
2022-06-08  8:00   ` Christoph Hellwig
2022-06-05 19:38 ` [PATCH 02/10] buffer: Convert clean_bdev_aliases() to use filemap_get_folios() Matthew Wilcox (Oracle)
2022-06-08  8:01   ` Christoph Hellwig
2022-06-05 19:38 ` [PATCH 03/10] ext4: Convert mpage_release_unused_pages() " Matthew Wilcox (Oracle)
2022-06-08  8:02   ` Christoph Hellwig
2022-06-08 16:02     ` Matthew Wilcox
2022-06-09  3:55       ` Christoph Hellwig
2022-06-05 19:38 ` [PATCH 04/10] ext4: Convert mpage_map_and_submit_buffers() " Matthew Wilcox (Oracle)
2022-06-08  8:03   ` Christoph Hellwig
2022-06-05 19:38 ` [PATCH 05/10] f2fs: Convert f2fs_invalidate_compress_pages() " Matthew Wilcox (Oracle)
2022-06-08  8:03   ` Christoph Hellwig
2022-06-15  8:14   ` [f2fs-dev] " Chao Yu
2022-06-05 19:38 ` [PATCH 06/10] hugetlbfs: Convert remove_inode_hugepages() " Matthew Wilcox (Oracle)
2022-06-08  8:04   ` Christoph Hellwig
2022-06-10 15:52   ` Sumanth Korikkar
2022-06-10 18:35     ` Gerald Schaefer
2022-06-10 21:17     ` Matthew Wilcox
2022-06-10 21:56       ` Mike Kravetz
2022-06-13  6:56       ` Sumanth Korikkar
2022-06-05 19:38 ` Matthew Wilcox (Oracle) [this message]
2022-06-07 16:10   ` [PATCH 07/10] nilfs2: Convert nilfs_copy_back_pages() " Ryusuke Konishi
2022-06-08  8:04   ` Christoph Hellwig
2022-06-05 19:38 ` [PATCH 08/10] vmscan: Add check_move_unevictable_folios() Matthew Wilcox (Oracle)
2022-06-08  8:07   ` Christoph Hellwig
2022-06-08 16:32     ` Matthew Wilcox
2022-06-09  3:56       ` Christoph Hellwig
2022-06-08 15:33   ` [vmscan] bc9eb0d5ef: BUG:KASAN:stack-out-of-bounds_in_check_move_unevictable_pages kernel test robot
2022-06-05 19:38 ` [PATCH 09/10] shmem: Convert shmem_unlock_mapping() to use filemap_get_folios() Matthew Wilcox (Oracle)
2022-06-08  8:08   ` Christoph Hellwig
2022-06-05 19:38 ` [PATCH 10/10] filemap: Remove find_get_pages_range() and associated functions Matthew Wilcox (Oracle)
2022-06-08  8:08   ` Christoph Hellwig
2022-06-07 11:37 ` [PATCH 00/10] Convert to filemap_get_folios() Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220605193854.2371230-8-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nilfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).