mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-08-31 14:13:39 +00:00
f2fs: convert f2fs_mpage_readpages() to use folio
Convert f2fs_mpage_readpages() to use folio and related functionality. Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
7643f3fe27
commit
db92e6c729
@ -2345,7 +2345,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
|
|||||||
* Major change was from block_size == page_size in f2fs by default.
|
* Major change was from block_size == page_size in f2fs by default.
|
||||||
*/
|
*/
|
||||||
static int f2fs_mpage_readpages(struct inode *inode,
|
static int f2fs_mpage_readpages(struct inode *inode,
|
||||||
struct readahead_control *rac, struct page *page)
|
struct readahead_control *rac, struct folio *folio)
|
||||||
{
|
{
|
||||||
struct bio *bio = NULL;
|
struct bio *bio = NULL;
|
||||||
sector_t last_block_in_bio = 0;
|
sector_t last_block_in_bio = 0;
|
||||||
@ -2365,6 +2365,7 @@ static int f2fs_mpage_readpages(struct inode *inode,
|
|||||||
#endif
|
#endif
|
||||||
unsigned nr_pages = rac ? readahead_count(rac) : 1;
|
unsigned nr_pages = rac ? readahead_count(rac) : 1;
|
||||||
unsigned max_nr_pages = nr_pages;
|
unsigned max_nr_pages = nr_pages;
|
||||||
|
pgoff_t index;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
map.m_pblk = 0;
|
map.m_pblk = 0;
|
||||||
@ -2378,64 +2379,63 @@ static int f2fs_mpage_readpages(struct inode *inode,
|
|||||||
|
|
||||||
for (; nr_pages; nr_pages--) {
|
for (; nr_pages; nr_pages--) {
|
||||||
if (rac) {
|
if (rac) {
|
||||||
page = readahead_page(rac);
|
folio = readahead_folio(rac);
|
||||||
prefetchw(&page->flags);
|
prefetchw(&folio->flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
index = folio_index(folio);
|
||||||
|
|
||||||
#ifdef CONFIG_F2FS_FS_COMPRESSION
|
#ifdef CONFIG_F2FS_FS_COMPRESSION
|
||||||
if (f2fs_compressed_file(inode)) {
|
if (!f2fs_compressed_file(inode))
|
||||||
/* there are remained compressed pages, submit them */
|
goto read_single_page;
|
||||||
if (!f2fs_cluster_can_merge_page(&cc, page->index)) {
|
|
||||||
ret = f2fs_read_multi_pages(&cc, &bio,
|
|
||||||
max_nr_pages,
|
|
||||||
&last_block_in_bio,
|
|
||||||
rac != NULL, false);
|
|
||||||
f2fs_destroy_compress_ctx(&cc, false);
|
|
||||||
if (ret)
|
|
||||||
goto set_error_page;
|
|
||||||
}
|
|
||||||
if (cc.cluster_idx == NULL_CLUSTER) {
|
|
||||||
if (nc_cluster_idx ==
|
|
||||||
page->index >> cc.log_cluster_size) {
|
|
||||||
goto read_single_page;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = f2fs_is_compressed_cluster(inode, page->index);
|
/* there are remained compressed pages, submit them */
|
||||||
if (ret < 0)
|
if (!f2fs_cluster_can_merge_page(&cc, index)) {
|
||||||
goto set_error_page;
|
ret = f2fs_read_multi_pages(&cc, &bio,
|
||||||
else if (!ret) {
|
max_nr_pages,
|
||||||
nc_cluster_idx =
|
&last_block_in_bio,
|
||||||
page->index >> cc.log_cluster_size;
|
rac != NULL, false);
|
||||||
goto read_single_page;
|
f2fs_destroy_compress_ctx(&cc, false);
|
||||||
}
|
|
||||||
|
|
||||||
nc_cluster_idx = NULL_CLUSTER;
|
|
||||||
}
|
|
||||||
ret = f2fs_init_compress_ctx(&cc);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
goto set_error_page;
|
goto set_error_page;
|
||||||
|
|
||||||
f2fs_compress_ctx_add_page(&cc, page);
|
|
||||||
|
|
||||||
goto next_page;
|
|
||||||
}
|
}
|
||||||
|
if (cc.cluster_idx == NULL_CLUSTER) {
|
||||||
|
if (nc_cluster_idx == index >> cc.log_cluster_size)
|
||||||
|
goto read_single_page;
|
||||||
|
|
||||||
|
ret = f2fs_is_compressed_cluster(inode, index);
|
||||||
|
if (ret < 0)
|
||||||
|
goto set_error_page;
|
||||||
|
else if (!ret) {
|
||||||
|
nc_cluster_idx =
|
||||||
|
index >> cc.log_cluster_size;
|
||||||
|
goto read_single_page;
|
||||||
|
}
|
||||||
|
|
||||||
|
nc_cluster_idx = NULL_CLUSTER;
|
||||||
|
}
|
||||||
|
ret = f2fs_init_compress_ctx(&cc);
|
||||||
|
if (ret)
|
||||||
|
goto set_error_page;
|
||||||
|
|
||||||
|
f2fs_compress_ctx_add_page(&cc, &folio->page);
|
||||||
|
|
||||||
|
goto next_page;
|
||||||
read_single_page:
|
read_single_page:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ret = f2fs_read_single_page(inode, page, max_nr_pages, &map,
|
ret = f2fs_read_single_page(inode, &folio->page, max_nr_pages, &map,
|
||||||
&bio, &last_block_in_bio, rac);
|
&bio, &last_block_in_bio, rac);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
#ifdef CONFIG_F2FS_FS_COMPRESSION
|
#ifdef CONFIG_F2FS_FS_COMPRESSION
|
||||||
set_error_page:
|
set_error_page:
|
||||||
#endif
|
#endif
|
||||||
zero_user_segment(page, 0, PAGE_SIZE);
|
folio_zero_segment(folio, 0, folio_size(folio));
|
||||||
unlock_page(page);
|
folio_unlock(folio);
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_F2FS_FS_COMPRESSION
|
#ifdef CONFIG_F2FS_FS_COMPRESSION
|
||||||
next_page:
|
next_page:
|
||||||
#endif
|
#endif
|
||||||
if (rac)
|
|
||||||
put_page(page);
|
|
||||||
|
|
||||||
#ifdef CONFIG_F2FS_FS_COMPRESSION
|
#ifdef CONFIG_F2FS_FS_COMPRESSION
|
||||||
if (f2fs_compressed_file(inode)) {
|
if (f2fs_compressed_file(inode)) {
|
||||||
@ -2472,7 +2472,7 @@ static int f2fs_read_data_folio(struct file *file, struct folio *folio)
|
|||||||
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, page);
|
||||||
if (ret == -EAGAIN)
|
if (ret == -EAGAIN)
|
||||||
ret = f2fs_mpage_readpages(inode, NULL, page);
|
ret = f2fs_mpage_readpages(inode, NULL, folio);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user