Commit 46a75ef8 authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

f2fs: convert f2fs_write_single_data_page() to use folio

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: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent b0846621
...@@ -1543,7 +1543,8 @@ static int f2fs_write_raw_pages(struct compress_ctx *cc, ...@@ -1543,7 +1543,8 @@ static int f2fs_write_raw_pages(struct compress_ctx *cc,
if (!clear_page_dirty_for_io(cc->rpages[i])) if (!clear_page_dirty_for_io(cc->rpages[i]))
goto continue_unlock; goto continue_unlock;
ret = f2fs_write_single_data_page(cc->rpages[i], &submitted, ret = f2fs_write_single_data_page(page_folio(cc->rpages[i]),
&submitted,
NULL, NULL, wbc, io_type, NULL, NULL, wbc, io_type,
compr_blocks, false); compr_blocks, false);
if (ret) { if (ret) {
......
...@@ -2764,7 +2764,7 @@ int f2fs_do_write_data_page(struct f2fs_io_info *fio) ...@@ -2764,7 +2764,7 @@ int f2fs_do_write_data_page(struct f2fs_io_info *fio)
return err; return err;
} }
int f2fs_write_single_data_page(struct page *page, int *submitted, int f2fs_write_single_data_page(struct folio *folio, int *submitted,
struct bio **bio, struct bio **bio,
sector_t *last_block, sector_t *last_block,
struct writeback_control *wbc, struct writeback_control *wbc,
...@@ -2772,12 +2772,13 @@ int f2fs_write_single_data_page(struct page *page, int *submitted, ...@@ -2772,12 +2772,13 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,
int compr_blocks, int compr_blocks,
bool allow_balance) bool allow_balance)
{ {
struct inode *inode = page->mapping->host; struct inode *inode = folio->mapping->host;
struct page *page = folio_page(folio, 0);
struct f2fs_sb_info *sbi = F2FS_I_SB(inode); struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
loff_t i_size = i_size_read(inode); loff_t i_size = i_size_read(inode);
const pgoff_t end_index = ((unsigned long long)i_size) const pgoff_t end_index = ((unsigned long long)i_size)
>> PAGE_SHIFT; >> PAGE_SHIFT;
loff_t psize = (loff_t)(page->index + 1) << PAGE_SHIFT; loff_t psize = (loff_t)(folio->index + 1) << PAGE_SHIFT;
unsigned offset = 0; unsigned offset = 0;
bool need_balance_fs = false; bool need_balance_fs = false;
bool quota_inode = IS_NOQUOTA(inode); bool quota_inode = IS_NOQUOTA(inode);
...@@ -2801,11 +2802,11 @@ int f2fs_write_single_data_page(struct page *page, int *submitted, ...@@ -2801,11 +2802,11 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,
.last_block = last_block, .last_block = last_block,
}; };
trace_f2fs_writepage(page_folio(page), DATA); trace_f2fs_writepage(folio, DATA);
/* we should bypass data pages to proceed the kworker jobs */ /* we should bypass data pages to proceed the kworker jobs */
if (unlikely(f2fs_cp_error(sbi))) { if (unlikely(f2fs_cp_error(sbi))) {
mapping_set_error(page->mapping, -EIO); mapping_set_error(folio->mapping, -EIO);
/* /*
* don't drop any dirty dentry pages for keeping lastest * don't drop any dirty dentry pages for keeping lastest
* directory structure. * directory structure.
...@@ -2823,7 +2824,7 @@ int f2fs_write_single_data_page(struct page *page, int *submitted, ...@@ -2823,7 +2824,7 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,
if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING))) if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
goto redirty_out; goto redirty_out;
if (page->index < end_index || if (folio->index < end_index ||
f2fs_verity_in_progress(inode) || f2fs_verity_in_progress(inode) ||
compr_blocks) compr_blocks)
goto write; goto write;
...@@ -2833,10 +2834,10 @@ int f2fs_write_single_data_page(struct page *page, int *submitted, ...@@ -2833,10 +2834,10 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,
* this page does not have to be written to disk. * this page does not have to be written to disk.
*/ */
offset = i_size & (PAGE_SIZE - 1); offset = i_size & (PAGE_SIZE - 1);
if ((page->index >= end_index + 1) || !offset) if ((folio->index >= end_index + 1) || !offset)
goto out; goto out;
zero_user_segment(page, offset, PAGE_SIZE); folio_zero_segment(folio, offset, folio_size(folio));
write: write:
/* Dentry/quota blocks are controlled by checkpoint */ /* Dentry/quota blocks are controlled by checkpoint */
if (S_ISDIR(inode->i_mode) || quota_inode) { if (S_ISDIR(inode->i_mode) || quota_inode) {
...@@ -2896,7 +2897,7 @@ int f2fs_write_single_data_page(struct page *page, int *submitted, ...@@ -2896,7 +2897,7 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,
out: out:
inode_dec_dirty_pages(inode); inode_dec_dirty_pages(inode);
if (err) { if (err) {
ClearPageUptodate(page); folio_clear_uptodate(folio);
clear_page_private_gcing(page); clear_page_private_gcing(page);
} }
...@@ -2906,7 +2907,7 @@ int f2fs_write_single_data_page(struct page *page, int *submitted, ...@@ -2906,7 +2907,7 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,
f2fs_remove_dirty_inode(inode); f2fs_remove_dirty_inode(inode);
submitted = NULL; submitted = NULL;
} }
unlock_page(page); folio_unlock(folio);
if (!S_ISDIR(inode->i_mode) && !IS_NOQUOTA(inode) && if (!S_ISDIR(inode->i_mode) && !IS_NOQUOTA(inode) &&
!F2FS_I(inode)->wb_task && allow_balance) !F2FS_I(inode)->wb_task && allow_balance)
f2fs_balance_fs(sbi, need_balance_fs); f2fs_balance_fs(sbi, need_balance_fs);
...@@ -2924,7 +2925,7 @@ int f2fs_write_single_data_page(struct page *page, int *submitted, ...@@ -2924,7 +2925,7 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,
return 0; return 0;
redirty_out: redirty_out:
redirty_page_for_writepage(wbc, page); folio_redirty_for_writepage(wbc, folio);
/* /*
* pageout() in MM translates EAGAIN, so calls handle_write_error() * pageout() in MM translates EAGAIN, so calls handle_write_error()
* -> mapping_set_error() -> set_bit(AS_EIO, ...). * -> mapping_set_error() -> set_bit(AS_EIO, ...).
...@@ -2933,7 +2934,7 @@ int f2fs_write_single_data_page(struct page *page, int *submitted, ...@@ -2933,7 +2934,7 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,
*/ */
if (!err || wbc->for_reclaim) if (!err || wbc->for_reclaim)
return AOP_WRITEPAGE_ACTIVATE; return AOP_WRITEPAGE_ACTIVATE;
unlock_page(page); folio_unlock(folio);
return err; return err;
} }
...@@ -2955,7 +2956,7 @@ static int f2fs_write_data_page(struct page *page, ...@@ -2955,7 +2956,7 @@ static int f2fs_write_data_page(struct page *page,
out: out:
#endif #endif
return f2fs_write_single_data_page(page, NULL, NULL, NULL, return f2fs_write_single_data_page(page_folio(page), NULL, NULL, NULL,
wbc, FS_DATA_IO, 0, true); wbc, FS_DATA_IO, 0, true);
} }
...@@ -3165,7 +3166,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping, ...@@ -3165,7 +3166,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
continue; continue;
} }
#endif #endif
ret = f2fs_write_single_data_page(&folio->page, ret = f2fs_write_single_data_page(folio,
&submitted, &bio, &last_block, &submitted, &bio, &last_block,
wbc, io_type, 0, true); wbc, io_type, 0, true);
if (ret == AOP_WRITEPAGE_ACTIVATE) if (ret == AOP_WRITEPAGE_ACTIVATE)
......
...@@ -3881,7 +3881,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, ...@@ -3881,7 +3881,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
int f2fs_encrypt_one_page(struct f2fs_io_info *fio); int f2fs_encrypt_one_page(struct f2fs_io_info *fio);
bool f2fs_should_update_inplace(struct inode *inode, struct f2fs_io_info *fio); bool f2fs_should_update_inplace(struct inode *inode, struct f2fs_io_info *fio);
bool f2fs_should_update_outplace(struct inode *inode, struct f2fs_io_info *fio); bool f2fs_should_update_outplace(struct inode *inode, struct f2fs_io_info *fio);
int f2fs_write_single_data_page(struct page *page, int *submitted, int f2fs_write_single_data_page(struct folio *folio, int *submitted,
struct bio **bio, sector_t *last_block, struct bio **bio, sector_t *last_block,
struct writeback_control *wbc, struct writeback_control *wbc,
enum iostat_type io_type, enum iostat_type io_type,
......
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