2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-16 17:23:55 +08:00

nilfs2: convert nilfs_find_uncommited_extent() to use filemap_get_folios_contig()

Convert function to use folios throughout.  This is in preparation for the
removal of find_get_pages_contig().  Now also supports large folios.

Also clean 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.

Link: https://lkml.kernel.org/r/20220824004023.77310-6-vishal.moola@gmail.com
Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Acked-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Chris Mason <clm@fb.com>
Cc: David Sterba <dsterba@suse.com>
Cc: David Sterba <dsterb@suse.com>
Cc: Josef Bacik <josef@toxicpanda.com>
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
Vishal Moola (Oracle) 2022-08-23 17:40:21 -07:00 committed by Andrew Morton
parent 47d5541995
commit 24a1efb4a9

View File

@ -480,41 +480,36 @@ unsigned long nilfs_find_uncommitted_extent(struct inode *inode,
sector_t start_blk, sector_t start_blk,
sector_t *blkoff) sector_t *blkoff)
{ {
unsigned int i; unsigned int i, nr_folios;
pgoff_t index; pgoff_t index;
unsigned int nblocks_in_page;
unsigned long length = 0; unsigned long length = 0;
sector_t b; struct folio_batch fbatch;
struct pagevec pvec; struct folio *folio;
struct page *page;
if (inode->i_mapping->nrpages == 0) if (inode->i_mapping->nrpages == 0)
return 0; return 0;
index = start_blk >> (PAGE_SHIFT - inode->i_blkbits); 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: repeat:
pvec.nr = find_get_pages_contig(inode->i_mapping, index, PAGEVEC_SIZE, nr_folios = filemap_get_folios_contig(inode->i_mapping, &index, ULONG_MAX,
pvec.pages); &fbatch);
if (pvec.nr == 0) if (nr_folios == 0)
return length; return length;
if (length > 0 && pvec.pages[0]->index > index)
goto out;
b = pvec.pages[0]->index << (PAGE_SHIFT - inode->i_blkbits);
i = 0; i = 0;
do { do {
page = pvec.pages[i]; folio = fbatch.folios[i];
lock_page(page); folio_lock(folio);
if (page_has_buffers(page)) { if (folio_buffers(folio)) {
struct buffer_head *bh, *head; struct buffer_head *bh, *head;
sector_t b;
bh = head = page_buffers(page); b = folio->index << (PAGE_SHIFT - inode->i_blkbits);
bh = head = folio_buffers(folio);
do { do {
if (b < start_blk) if (b < start_blk)
continue; continue;
@ -529,21 +524,17 @@ repeat:
} else { } else {
if (length > 0) if (length > 0)
goto out_locked; goto out_locked;
b += nblocks_in_page;
} }
unlock_page(page); folio_unlock(folio);
} while (++i < pagevec_count(&pvec)); } while (++i < nr_folios);
index = page->index + 1; folio_batch_release(&fbatch);
pagevec_release(&pvec);
cond_resched(); cond_resched();
goto repeat; goto repeat;
out_locked: out_locked:
unlock_page(page); folio_unlock(folio);
out: folio_batch_release(&fbatch);
pagevec_release(&pvec);
return length; return length;
} }