mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-09 23:39:18 +00:00
gfs2: convert gfs2_write_cache_jdata() to use filemap_get_folios_tag()
Convert function to use folios throughout. This is in preparation for the removal of find_get_pgaes_range_tag(). This change removes 8 calls to compound_head(). Also had to modify and rename gfs2_write_jdata_pagevec() to take in and utilize folio_batch rather than pagevec and use folios rather than pages. gfs2_write_jdata_batch() now supports large folios. Link: https://lkml.kernel.org/r/20230104211448.4804-18-vishal.moola@gmail.com Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com> Reviewed-by: Andreas Gruenbacher <agruenba@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
580e7a4926
commit
87ed37e66d
@ -195,67 +195,71 @@ static int gfs2_writepages(struct address_space *mapping,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gfs2_write_jdata_pagevec - Write back a pagevec's worth of pages
|
* gfs2_write_jdata_batch - Write back a folio batch's worth of folios
|
||||||
* @mapping: The mapping
|
* @mapping: The mapping
|
||||||
* @wbc: The writeback control
|
* @wbc: The writeback control
|
||||||
* @pvec: The vector of pages
|
* @fbatch: The batch of folios
|
||||||
* @nr_pages: The number of pages to write
|
|
||||||
* @done_index: Page index
|
* @done_index: Page index
|
||||||
*
|
*
|
||||||
* Returns: non-zero if loop should terminate, zero otherwise
|
* Returns: non-zero if loop should terminate, zero otherwise
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int gfs2_write_jdata_pagevec(struct address_space *mapping,
|
static int gfs2_write_jdata_batch(struct address_space *mapping,
|
||||||
struct writeback_control *wbc,
|
struct writeback_control *wbc,
|
||||||
struct pagevec *pvec,
|
struct folio_batch *fbatch,
|
||||||
int nr_pages,
|
|
||||||
pgoff_t *done_index)
|
pgoff_t *done_index)
|
||||||
{
|
{
|
||||||
struct inode *inode = mapping->host;
|
struct inode *inode = mapping->host;
|
||||||
struct gfs2_sbd *sdp = GFS2_SB(inode);
|
struct gfs2_sbd *sdp = GFS2_SB(inode);
|
||||||
unsigned nrblocks = nr_pages * (PAGE_SIZE >> inode->i_blkbits);
|
unsigned nrblocks;
|
||||||
int i;
|
int i;
|
||||||
int ret;
|
int ret;
|
||||||
|
int nr_pages = 0;
|
||||||
|
int nr_folios = folio_batch_count(fbatch);
|
||||||
|
|
||||||
|
for (i = 0; i < nr_folios; i++)
|
||||||
|
nr_pages += folio_nr_pages(fbatch->folios[i]);
|
||||||
|
nrblocks = nr_pages * (PAGE_SIZE >> inode->i_blkbits);
|
||||||
|
|
||||||
ret = gfs2_trans_begin(sdp, nrblocks, nrblocks);
|
ret = gfs2_trans_begin(sdp, nrblocks, nrblocks);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
for(i = 0; i < nr_pages; i++) {
|
for (i = 0; i < nr_folios; i++) {
|
||||||
struct page *page = pvec->pages[i];
|
struct folio *folio = fbatch->folios[i];
|
||||||
|
|
||||||
*done_index = page->index;
|
*done_index = folio->index;
|
||||||
|
|
||||||
lock_page(page);
|
folio_lock(folio);
|
||||||
|
|
||||||
if (unlikely(page->mapping != mapping)) {
|
if (unlikely(folio->mapping != mapping)) {
|
||||||
continue_unlock:
|
continue_unlock:
|
||||||
unlock_page(page);
|
folio_unlock(folio);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PageDirty(page)) {
|
if (!folio_test_dirty(folio)) {
|
||||||
/* someone wrote it for us */
|
/* someone wrote it for us */
|
||||||
goto continue_unlock;
|
goto continue_unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PageWriteback(page)) {
|
if (folio_test_writeback(folio)) {
|
||||||
if (wbc->sync_mode != WB_SYNC_NONE)
|
if (wbc->sync_mode != WB_SYNC_NONE)
|
||||||
wait_on_page_writeback(page);
|
folio_wait_writeback(folio);
|
||||||
else
|
else
|
||||||
goto continue_unlock;
|
goto continue_unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
BUG_ON(PageWriteback(page));
|
BUG_ON(folio_test_writeback(folio));
|
||||||
if (!clear_page_dirty_for_io(page))
|
if (!folio_clear_dirty_for_io(folio))
|
||||||
goto continue_unlock;
|
goto continue_unlock;
|
||||||
|
|
||||||
trace_wbc_writepage(wbc, inode_to_bdi(inode));
|
trace_wbc_writepage(wbc, inode_to_bdi(inode));
|
||||||
|
|
||||||
ret = __gfs2_jdata_writepage(page, wbc);
|
ret = __gfs2_jdata_writepage(&folio->page, wbc);
|
||||||
if (unlikely(ret)) {
|
if (unlikely(ret)) {
|
||||||
if (ret == AOP_WRITEPAGE_ACTIVATE) {
|
if (ret == AOP_WRITEPAGE_ACTIVATE) {
|
||||||
unlock_page(page);
|
folio_unlock(folio);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -268,7 +272,8 @@ continue_unlock:
|
|||||||
* not be suitable for data integrity
|
* not be suitable for data integrity
|
||||||
* writeout).
|
* writeout).
|
||||||
*/
|
*/
|
||||||
*done_index = page->index + 1;
|
*done_index = folio->index +
|
||||||
|
folio_nr_pages(folio);
|
||||||
ret = 1;
|
ret = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -305,8 +310,8 @@ static int gfs2_write_cache_jdata(struct address_space *mapping,
|
|||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int done = 0;
|
int done = 0;
|
||||||
struct pagevec pvec;
|
struct folio_batch fbatch;
|
||||||
int nr_pages;
|
int nr_folios;
|
||||||
pgoff_t writeback_index;
|
pgoff_t writeback_index;
|
||||||
pgoff_t index;
|
pgoff_t index;
|
||||||
pgoff_t end;
|
pgoff_t end;
|
||||||
@ -315,7 +320,7 @@ static int gfs2_write_cache_jdata(struct address_space *mapping,
|
|||||||
int range_whole = 0;
|
int range_whole = 0;
|
||||||
xa_mark_t tag;
|
xa_mark_t tag;
|
||||||
|
|
||||||
pagevec_init(&pvec);
|
folio_batch_init(&fbatch);
|
||||||
if (wbc->range_cyclic) {
|
if (wbc->range_cyclic) {
|
||||||
writeback_index = mapping->writeback_index; /* prev offset */
|
writeback_index = mapping->writeback_index; /* prev offset */
|
||||||
index = writeback_index;
|
index = writeback_index;
|
||||||
@ -341,17 +346,18 @@ retry:
|
|||||||
tag_pages_for_writeback(mapping, index, end);
|
tag_pages_for_writeback(mapping, index, end);
|
||||||
done_index = index;
|
done_index = index;
|
||||||
while (!done && (index <= end)) {
|
while (!done && (index <= end)) {
|
||||||
nr_pages = pagevec_lookup_range_tag(&pvec, mapping, &index, end,
|
nr_folios = filemap_get_folios_tag(mapping, &index, end,
|
||||||
tag);
|
tag, &fbatch);
|
||||||
if (nr_pages == 0)
|
if (nr_folios == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
ret = gfs2_write_jdata_pagevec(mapping, wbc, &pvec, nr_pages, &done_index);
|
ret = gfs2_write_jdata_batch(mapping, wbc, &fbatch,
|
||||||
|
&done_index);
|
||||||
if (ret)
|
if (ret)
|
||||||
done = 1;
|
done = 1;
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
ret = 0;
|
ret = 0;
|
||||||
pagevec_release(&pvec);
|
folio_batch_release(&fbatch);
|
||||||
cond_resched();
|
cond_resched();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user