From: "Vishal Moola (Oracle)" <vishal.moola@gmail.com>
To: linux-fsdevel@vger.kernel.org
Cc: linux-btrfs@vger.kernel.org, linux-nilfs@vger.kernel.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
"Vishal Moola (Oracle)" <vishal.moola@gmail.com>
Subject: [PATCH 5/7] nilfs2: Convert nilfs_find_uncommited_extent() to use filemap_get_folios_contig()
Date: Mon, 15 Aug 2022 11:54:50 -0700 [thread overview]
Message-ID: <20220815185452.37447-6-vishal.moola@gmail.com> (raw)
In-Reply-To: <20220815185452.37447-1-vishal.moola@gmail.com>
Converted function to use folios throughout. This is in preparation for
the removal of find_get_pages_contig(). Now also supports large folios.
Also cleaned up an unnecessary if statement - pvec.pages[0]->index > index
will always evaluate to false, and filemap_get_folios_contig() returns 0 if
there is no folio found at index.
Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
---
fs/nilfs2/page.c | 38 +++++++++++++++++---------------------
1 file changed, 17 insertions(+), 21 deletions(-)
diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c
index 3267e96c256c..40cc8eb0bc8e 100644
--- a/fs/nilfs2/page.c
+++ b/fs/nilfs2/page.c
@@ -480,13 +480,13 @@ unsigned long nilfs_find_uncommitted_extent(struct inode *inode,
sector_t start_blk,
sector_t *blkoff)
{
- unsigned int i;
+ unsigned int i, nr;
pgoff_t index;
unsigned int nblocks_in_page;
unsigned long length = 0;
sector_t b;
- struct pagevec pvec;
- struct page *page;
+ struct folio_batch fbatch;
+ struct folio *folio;
if (inode->i_mapping->nrpages == 0)
return 0;
@@ -494,27 +494,24 @@ unsigned long nilfs_find_uncommitted_extent(struct inode *inode,
index = start_blk >> (PAGE_SHIFT - inode->i_blkbits);
nblocks_in_page = 1U << (PAGE_SHIFT - inode->i_blkbits);
- pagevec_init(&pvec);
+ folio_batch_init(&fbatch);
repeat:
- pvec.nr = find_get_pages_contig(inode->i_mapping, index, PAGEVEC_SIZE,
- pvec.pages);
- if (pvec.nr == 0)
+ nr = filemap_get_folios_contig(inode->i_mapping, &index, ULONG_MAX,
+ &fbatch);
+ if (nr == 0)
return length;
- if (length > 0 && pvec.pages[0]->index > index)
- goto out;
-
- b = pvec.pages[0]->index << (PAGE_SHIFT - inode->i_blkbits);
+ b = fbatch.folios[0]->index << (PAGE_SHIFT - inode->i_blkbits);
i = 0;
do {
- page = pvec.pages[i];
+ folio = fbatch.folios[i];
- lock_page(page);
- if (page_has_buffers(page)) {
+ folio_lock(folio);
+ if (folio_buffers(folio)) {
struct buffer_head *bh, *head;
- bh = head = page_buffers(page);
+ bh = head = folio_buffers(folio);
do {
if (b < start_blk)
continue;
@@ -532,18 +529,17 @@ unsigned long nilfs_find_uncommitted_extent(struct inode *inode,
b += nblocks_in_page;
}
- unlock_page(page);
+ folio_unlock(folio);
- } while (++i < pagevec_count(&pvec));
+ } while (++i < nr);
- index = page->index + 1;
- pagevec_release(&pvec);
+ folio_batch_release(&fbatch);
cond_resched();
goto repeat;
out_locked:
- unlock_page(page);
+ folio_unlock(folio);
out:
- pagevec_release(&pvec);
+ folio_batch_release(&fbatch);
return length;
}
--
2.36.1
next prev parent reply other threads:[~2022-08-15 18:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-15 18:54 [PATCH 0/7] Convert to filemap_get_folios_contig() Vishal Moola (Oracle)
2022-08-15 18:54 ` [PATCH 1/7] filemap: Add filemap_get_folios_contig() Vishal Moola (Oracle)
2022-08-15 18:54 ` [PATCH 2/7] btrfs: Convert __process_pages_contig() to use filemap_get_folios_contig() Vishal Moola (Oracle)
2022-08-15 18:54 ` [PATCH 3/7] btrfs: Convert end_compressed_writeback() to use filemap_get_folios() Vishal Moola (Oracle)
2022-08-15 18:54 ` [PATCH 4/7] btrfs: Convert process_page_range() to use filemap_get_folios_contig() Vishal Moola (Oracle)
2022-08-15 18:54 ` Vishal Moola (Oracle) [this message]
2022-08-15 23:34 ` [PATCH 5/7] nilfs2: Convert nilfs_find_uncommited_extent() " kernel test robot
2022-08-16 2:47 ` kernel test robot
2022-08-15 18:54 ` [PATCH 6/7] ramfs: Convert ramfs_nommu_get_unmapped_area() " Vishal Moola (Oracle)
2022-08-15 18:54 ` [PATCH 7/7] filemap: Remove find_get_pages_contig() Vishal Moola (Oracle)
2022-08-15 20:17 ` [PATCH 0/7] Convert to filemap_get_folios_contig() Matthew Wilcox
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=20220815185452.37447-6-vishal.moola@gmail.com \
--to=vishal.moola@gmail.com \
--cc=linux-btrfs@vger.kernel.org \
--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