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

nilfs2: convert nilfs_lookup_dirty_data_buffers() 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 4 calls
to compound_head().

Link: https://lkml.kernel.org/r/20230104211448.4804-19-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 87ed37e6
...@@ -680,7 +680,7 @@ static size_t nilfs_lookup_dirty_data_buffers(struct inode *inode, ...@@ -680,7 +680,7 @@ static size_t nilfs_lookup_dirty_data_buffers(struct inode *inode,
loff_t start, loff_t end) loff_t start, loff_t end)
{ {
struct address_space *mapping = inode->i_mapping; struct address_space *mapping = inode->i_mapping;
struct pagevec pvec; struct folio_batch fbatch;
pgoff_t index = 0, last = ULONG_MAX; pgoff_t index = 0, last = ULONG_MAX;
size_t ndirties = 0; size_t ndirties = 0;
int i; int i;
...@@ -694,23 +694,26 @@ static size_t nilfs_lookup_dirty_data_buffers(struct inode *inode, ...@@ -694,23 +694,26 @@ static size_t nilfs_lookup_dirty_data_buffers(struct inode *inode,
index = start >> PAGE_SHIFT; index = start >> PAGE_SHIFT;
last = end >> PAGE_SHIFT; last = end >> PAGE_SHIFT;
} }
pagevec_init(&pvec); folio_batch_init(&fbatch);
repeat: repeat:
if (unlikely(index > last) || if (unlikely(index > last) ||
!pagevec_lookup_range_tag(&pvec, mapping, &index, last, !filemap_get_folios_tag(mapping, &index, last,
PAGECACHE_TAG_DIRTY)) PAGECACHE_TAG_DIRTY, &fbatch))
return ndirties; return ndirties;
for (i = 0; i < pagevec_count(&pvec); i++) { for (i = 0; i < folio_batch_count(&fbatch); i++) {
struct buffer_head *bh, *head; struct buffer_head *bh, *head;
struct page *page = pvec.pages[i]; struct folio *folio = fbatch.folios[i];
lock_page(page); folio_lock(folio);
if (!page_has_buffers(page)) head = folio_buffers(folio);
create_empty_buffers(page, i_blocksize(inode), 0); if (!head) {
unlock_page(page); create_empty_buffers(&folio->page, i_blocksize(inode), 0);
head = folio_buffers(folio);
}
folio_unlock(folio);
bh = head = page_buffers(page); bh = head;
do { do {
if (!buffer_dirty(bh) || buffer_async_write(bh)) if (!buffer_dirty(bh) || buffer_async_write(bh))
continue; continue;
...@@ -718,13 +721,13 @@ static size_t nilfs_lookup_dirty_data_buffers(struct inode *inode, ...@@ -718,13 +721,13 @@ static size_t nilfs_lookup_dirty_data_buffers(struct inode *inode,
list_add_tail(&bh->b_assoc_buffers, listp); list_add_tail(&bh->b_assoc_buffers, listp);
ndirties++; ndirties++;
if (unlikely(ndirties >= nlimit)) { if (unlikely(ndirties >= nlimit)) {
pagevec_release(&pvec); folio_batch_release(&fbatch);
cond_resched(); cond_resched();
return ndirties; return ndirties;
} }
} while (bh = bh->b_this_page, bh != head); } while (bh = bh->b_this_page, bh != head);
} }
pagevec_release(&pvec); folio_batch_release(&fbatch);
cond_resched(); cond_resched();
goto repeat; goto repeat;
} }
......
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