Skip to content

Commit

Permalink
f2fs: convert __write_node_page() to use folio
Browse files Browse the repository at this point in the history
Convert to use folio, so that we can get rid of 'page->index' to
prepare for removal of 'index' field in structure page [1].

[1] https://lore.kernel.org/all/Zp8fgUSIBGQ1TN0D@casper.infradead.org/

Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Chao Yu <chao@kernel.org>
Reviewed-by: Li Zetao <lizetao1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
  • Loading branch information
chaseyu authored and Jaegeuk Kim committed Sep 6, 2024
1 parent 2ac0aa3 commit 4deccfb
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions fs/f2fs/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -1608,6 +1608,7 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted,
enum iostat_type io_type, unsigned int *seq_id)
{
struct f2fs_sb_info *sbi = F2FS_P_SB(page);
struct folio *folio = page_folio(page);
nid_t nid;
struct node_info ni;
struct f2fs_io_info fio = {
Expand All @@ -1624,15 +1625,15 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted,
};
unsigned int seq;

trace_f2fs_writepage(page_folio(page), NODE);
trace_f2fs_writepage(folio, NODE);

if (unlikely(f2fs_cp_error(sbi))) {
/* keep node pages in remount-ro mode */
if (F2FS_OPTION(sbi).errors == MOUNT_ERRORS_READONLY)
goto redirty_out;
ClearPageUptodate(page);
folio_clear_uptodate(folio);
dec_page_count(sbi, F2FS_DIRTY_NODES);
unlock_page(page);
folio_unlock(folio);
return 0;
}

Expand All @@ -1646,7 +1647,7 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted,

/* get old block addr of this node page */
nid = nid_of_node(page);
f2fs_bug_on(sbi, page->index != nid);
f2fs_bug_on(sbi, folio->index != nid);

if (f2fs_get_node_info(sbi, nid, &ni, !do_balance))
goto redirty_out;
Expand All @@ -1660,10 +1661,10 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted,

/* This page is already truncated */
if (unlikely(ni.blk_addr == NULL_ADDR)) {
ClearPageUptodate(page);
folio_clear_uptodate(folio);
dec_page_count(sbi, F2FS_DIRTY_NODES);
f2fs_up_read(&sbi->node_write);
unlock_page(page);
folio_unlock(folio);
return 0;
}

Expand All @@ -1684,7 +1685,7 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted,
*seq_id = seq;
}

set_page_writeback(page);
folio_start_writeback(folio);

fio.old_blkaddr = ni.blk_addr;
f2fs_do_write_node_page(nid, &fio);
Expand All @@ -1697,7 +1698,7 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted,
submitted = NULL;
}

unlock_page(page);
folio_unlock(folio);

if (unlikely(f2fs_cp_error(sbi))) {
f2fs_submit_merged_write(sbi, NODE);
Expand All @@ -1711,7 +1712,7 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted,
return 0;

redirty_out:
redirty_page_for_writepage(wbc, page);
folio_redirty_for_writepage(wbc, folio);
return AOP_WRITEPAGE_ACTIVATE;
}

Expand Down

0 comments on commit 4deccfb

Please sign in to comment.