gfs2: Convert gfs2_jhead_process_page() to use a folio

Use folio_put_refs() to perform only one atomic operation instead of two.
The other changes are straightforward conversions from page APIs to
their folio equivalents.
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
parent 9bb88987
...@@ -452,36 +452,36 @@ static bool gfs2_jhead_pg_srch(struct gfs2_jdesc *jd, ...@@ -452,36 +452,36 @@ static bool gfs2_jhead_pg_srch(struct gfs2_jdesc *jd,
* @head: The journal head to start from * @head: The journal head to start from
* @done: If set, perform only cleanup, else search and set if found. * @done: If set, perform only cleanup, else search and set if found.
* *
* Find the page with 'index' in the journal's mapping. Search the page for * Find the folio with 'index' in the journal's mapping. Search the folio for
* the journal head if requested (cleanup == false). Release refs on the * the journal head if requested (cleanup == false). Release refs on the
* page so the page cache can reclaim it (put_page() twice). We grabbed a * folio so the page cache can reclaim it. We grabbed a
* reference on this page two times, first when we did a find_or_create_page() * reference on this folio twice, first when we did a find_or_create_page()
* to obtain the page to add it to the bio and second when we do a * to obtain the folio to add it to the bio and second when we do a
* find_get_page() here to get the page to wait on while I/O on it is being * filemap_get_folio() here to get the folio to wait on while I/O on it is being
* completed. * completed.
* This function is also used to free up a page we might've grabbed but not * This function is also used to free up a folio we might've grabbed but not
* used. Maybe we added it to a bio, but not submitted it for I/O. Or we * used. Maybe we added it to a bio, but not submitted it for I/O. Or we
* submitted the I/O, but we already found the jhead so we only need to drop * submitted the I/O, but we already found the jhead so we only need to drop
* our references to the page. * our references to the folio.
*/ */
static void gfs2_jhead_process_page(struct gfs2_jdesc *jd, unsigned long index, static void gfs2_jhead_process_page(struct gfs2_jdesc *jd, unsigned long index,
struct gfs2_log_header_host *head, struct gfs2_log_header_host *head,
bool *done) bool *done)
{ {
struct page *page; struct folio *folio;
page = find_get_page(jd->jd_inode->i_mapping, index); folio = filemap_get_folio(jd->jd_inode->i_mapping, index);
wait_on_page_locked(page);
if (PageError(page)) folio_wait_locked(folio);
if (folio_test_error(folio))
*done = true; *done = true;
if (!*done) if (!*done)
*done = gfs2_jhead_pg_srch(jd, head, page); *done = gfs2_jhead_pg_srch(jd, head, &folio->page);
put_page(page); /* Once for find_get_page */ /* filemap_get_folio() and the earlier find_or_create_page() */
put_page(page); /* Once more for find_or_create_page */ folio_put_refs(folio, 2);
} }
static struct bio *gfs2_chain_bio(struct bio *prev, unsigned int nr_iovecs) static struct bio *gfs2_chain_bio(struct bio *prev, unsigned int nr_iovecs)
......
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