Commit 96ea46f3 authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

f2fs: convert f2fs_read_inline_data() to use folio

Convert f2fs_read_inline_data() to use folio and related
functionality, and also convert its caller to use folio.
Signed-off-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent ed54eed3
...@@ -2458,20 +2458,19 @@ static int f2fs_mpage_readpages(struct inode *inode, ...@@ -2458,20 +2458,19 @@ static int f2fs_mpage_readpages(struct inode *inode,
static int f2fs_read_data_folio(struct file *file, struct folio *folio) static int f2fs_read_data_folio(struct file *file, struct folio *folio)
{ {
struct page *page = &folio->page; struct inode *inode = folio_file_mapping(folio)->host;
struct inode *inode = page_file_mapping(page)->host;
int ret = -EAGAIN; int ret = -EAGAIN;
trace_f2fs_readpage(page, DATA); trace_f2fs_readpage(&folio->page, DATA);
if (!f2fs_is_compress_backend_ready(inode)) { if (!f2fs_is_compress_backend_ready(inode)) {
unlock_page(page); folio_unlock(folio);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
/* If the file has inline data, try to read it directly */ /* If the file has inline data, try to read it directly */
if (f2fs_has_inline_data(inode)) if (f2fs_has_inline_data(inode))
ret = f2fs_read_inline_data(inode, page); ret = f2fs_read_inline_data(inode, folio);
if (ret == -EAGAIN) if (ret == -EAGAIN)
ret = f2fs_mpage_readpages(inode, NULL, folio); ret = f2fs_mpage_readpages(inode, NULL, folio);
return ret; return ret;
...@@ -3400,7 +3399,7 @@ static int prepare_write_begin(struct f2fs_sb_info *sbi, ...@@ -3400,7 +3399,7 @@ static int prepare_write_begin(struct f2fs_sb_info *sbi,
if (f2fs_has_inline_data(inode)) { if (f2fs_has_inline_data(inode)) {
if (pos + len <= MAX_INLINE_DATA(inode)) { if (pos + len <= MAX_INLINE_DATA(inode)) {
f2fs_do_read_inline_data(page, ipage); f2fs_do_read_inline_data(page_folio(page), ipage);
set_inode_flag(inode, FI_DATA_EXIST); set_inode_flag(inode, FI_DATA_EXIST);
if (inode->i_nlink) if (inode->i_nlink)
set_page_private_inline(ipage); set_page_private_inline(ipage);
......
...@@ -4154,10 +4154,10 @@ extern struct kmem_cache *f2fs_inode_entry_slab; ...@@ -4154,10 +4154,10 @@ extern struct kmem_cache *f2fs_inode_entry_slab;
bool f2fs_may_inline_data(struct inode *inode); bool f2fs_may_inline_data(struct inode *inode);
bool f2fs_sanity_check_inline_data(struct inode *inode); bool f2fs_sanity_check_inline_data(struct inode *inode);
bool f2fs_may_inline_dentry(struct inode *inode); bool f2fs_may_inline_dentry(struct inode *inode);
void f2fs_do_read_inline_data(struct page *page, struct page *ipage); void f2fs_do_read_inline_data(struct folio *folio, struct page *ipage);
void f2fs_truncate_inline_inode(struct inode *inode, void f2fs_truncate_inline_inode(struct inode *inode,
struct page *ipage, u64 from); struct page *ipage, u64 from);
int f2fs_read_inline_data(struct inode *inode, struct page *page); int f2fs_read_inline_data(struct inode *inode, struct folio *folio);
int f2fs_convert_inline_page(struct dnode_of_data *dn, struct page *page); int f2fs_convert_inline_page(struct dnode_of_data *dn, struct page *page);
int f2fs_convert_inline_inode(struct inode *inode); int f2fs_convert_inline_inode(struct inode *inode);
int f2fs_try_convert_inline_dir(struct inode *dir, struct dentry *dentry); int f2fs_try_convert_inline_dir(struct inode *dir, struct dentry *dentry);
......
...@@ -61,22 +61,22 @@ bool f2fs_may_inline_dentry(struct inode *inode) ...@@ -61,22 +61,22 @@ bool f2fs_may_inline_dentry(struct inode *inode)
return true; return true;
} }
void f2fs_do_read_inline_data(struct page *page, struct page *ipage) void f2fs_do_read_inline_data(struct folio *folio, struct page *ipage)
{ {
struct inode *inode = page->mapping->host; struct inode *inode = folio_file_mapping(folio)->host;
if (PageUptodate(page)) if (folio_test_uptodate(folio))
return; return;
f2fs_bug_on(F2FS_P_SB(page), page->index); f2fs_bug_on(F2FS_I_SB(inode), folio_index(folio));
zero_user_segment(page, MAX_INLINE_DATA(inode), PAGE_SIZE); folio_zero_segment(folio, MAX_INLINE_DATA(inode), folio_size(folio));
/* Copy the whole inline data block */ /* Copy the whole inline data block */
memcpy_to_page(page, 0, inline_data_addr(inode, ipage), memcpy_to_folio(folio, 0, inline_data_addr(inode, ipage),
MAX_INLINE_DATA(inode)); MAX_INLINE_DATA(inode));
if (!PageUptodate(page)) if (!folio_test_uptodate(folio))
SetPageUptodate(page); folio_mark_uptodate(folio);
} }
void f2fs_truncate_inline_inode(struct inode *inode, void f2fs_truncate_inline_inode(struct inode *inode,
...@@ -97,13 +97,13 @@ void f2fs_truncate_inline_inode(struct inode *inode, ...@@ -97,13 +97,13 @@ void f2fs_truncate_inline_inode(struct inode *inode,
clear_inode_flag(inode, FI_DATA_EXIST); clear_inode_flag(inode, FI_DATA_EXIST);
} }
int f2fs_read_inline_data(struct inode *inode, struct page *page) int f2fs_read_inline_data(struct inode *inode, struct folio *folio)
{ {
struct page *ipage; struct page *ipage;
ipage = f2fs_get_node_page(F2FS_I_SB(inode), inode->i_ino); ipage = f2fs_get_node_page(F2FS_I_SB(inode), inode->i_ino);
if (IS_ERR(ipage)) { if (IS_ERR(ipage)) {
unlock_page(page); folio_unlock(folio);
return PTR_ERR(ipage); return PTR_ERR(ipage);
} }
...@@ -112,15 +112,15 @@ int f2fs_read_inline_data(struct inode *inode, struct page *page) ...@@ -112,15 +112,15 @@ int f2fs_read_inline_data(struct inode *inode, struct page *page)
return -EAGAIN; return -EAGAIN;
} }
if (page->index) if (folio_index(folio))
zero_user_segment(page, 0, PAGE_SIZE); folio_zero_segment(folio, 0, folio_size(folio));
else else
f2fs_do_read_inline_data(page, ipage); f2fs_do_read_inline_data(folio, ipage);
if (!PageUptodate(page)) if (!folio_test_uptodate(folio))
SetPageUptodate(page); folio_mark_uptodate(folio);
f2fs_put_page(ipage, 1); f2fs_put_page(ipage, 1);
unlock_page(page); folio_unlock(folio);
return 0; return 0;
} }
...@@ -166,7 +166,7 @@ int f2fs_convert_inline_page(struct dnode_of_data *dn, struct page *page) ...@@ -166,7 +166,7 @@ int f2fs_convert_inline_page(struct dnode_of_data *dn, struct page *page)
f2fs_bug_on(F2FS_P_SB(page), folio_test_writeback(page_folio(page))); f2fs_bug_on(F2FS_P_SB(page), folio_test_writeback(page_folio(page)));
f2fs_do_read_inline_data(page, dn->inode_page); f2fs_do_read_inline_data(page_folio(page), dn->inode_page);
set_page_dirty(page); set_page_dirty(page);
/* clear dirty state */ /* clear dirty state */
......
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