Commit 90cd33d7 authored by Gao Xiang's avatar Gao Xiang

erofs: convert z_erofs_read_fragment() to folios

Just a straight-forward conversion.  No logic changes.
Signed-off-by: default avatarGao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20240703120051.3653452-2-hsiangkao@linux.alibaba.com
parent 1a4821a0
...@@ -925,7 +925,7 @@ static void z_erofs_pcluster_end(struct z_erofs_decompress_frontend *fe) ...@@ -925,7 +925,7 @@ static void z_erofs_pcluster_end(struct z_erofs_decompress_frontend *fe)
fe->pcl = NULL; fe->pcl = NULL;
} }
static int z_erofs_read_fragment(struct super_block *sb, struct page *page, static int z_erofs_read_fragment(struct super_block *sb, struct folio *folio,
unsigned int cur, unsigned int end, erofs_off_t pos) unsigned int cur, unsigned int end, erofs_off_t pos)
{ {
struct inode *packed_inode = EROFS_SB(sb)->packed_inode; struct inode *packed_inode = EROFS_SB(sb)->packed_inode;
...@@ -938,14 +938,13 @@ static int z_erofs_read_fragment(struct super_block *sb, struct page *page, ...@@ -938,14 +938,13 @@ static int z_erofs_read_fragment(struct super_block *sb, struct page *page,
buf.mapping = packed_inode->i_mapping; buf.mapping = packed_inode->i_mapping;
for (; cur < end; cur += cnt, pos += cnt) { for (; cur < end; cur += cnt, pos += cnt) {
cnt = min_t(unsigned int, end - cur, cnt = min(end - cur, sb->s_blocksize - erofs_blkoff(sb, pos));
sb->s_blocksize - erofs_blkoff(sb, pos));
src = erofs_bread(&buf, pos, EROFS_KMAP); src = erofs_bread(&buf, pos, EROFS_KMAP);
if (IS_ERR(src)) { if (IS_ERR(src)) {
erofs_put_metabuf(&buf); erofs_put_metabuf(&buf);
return PTR_ERR(src); return PTR_ERR(src);
} }
memcpy_to_page(page, cur, src, cnt); memcpy_to_folio(folio, cur, src, cnt);
} }
erofs_put_metabuf(&buf); erofs_put_metabuf(&buf);
return 0; return 0;
...@@ -959,7 +958,7 @@ static int z_erofs_scan_folio(struct z_erofs_decompress_frontend *fe, ...@@ -959,7 +958,7 @@ static int z_erofs_scan_folio(struct z_erofs_decompress_frontend *fe,
const loff_t offset = folio_pos(folio); const loff_t offset = folio_pos(folio);
const unsigned int bs = i_blocksize(inode), fs = folio_size(folio); const unsigned int bs = i_blocksize(inode), fs = folio_size(folio);
bool tight = true, exclusive; bool tight = true, exclusive;
unsigned int cur, end, len, split; unsigned int cur, end, split;
int err = 0; int err = 0;
z_erofs_onlinefolio_init(folio); z_erofs_onlinefolio_init(folio);
...@@ -989,9 +988,9 @@ static int z_erofs_scan_folio(struct z_erofs_decompress_frontend *fe, ...@@ -989,9 +988,9 @@ static int z_erofs_scan_folio(struct z_erofs_decompress_frontend *fe,
if (map->m_flags & EROFS_MAP_FRAGMENT) { if (map->m_flags & EROFS_MAP_FRAGMENT) {
erofs_off_t fpos = offset + cur - map->m_la; erofs_off_t fpos = offset + cur - map->m_la;
len = min_t(unsigned int, map->m_llen - fpos, end - cur); err = z_erofs_read_fragment(inode->i_sb, folio, cur,
err = z_erofs_read_fragment(inode->i_sb, &folio->page, cur, cur + min(map->m_llen - fpos, end - cur),
cur + len, EROFS_I(inode)->z_fragmentoff + fpos); EROFS_I(inode)->z_fragmentoff + fpos);
if (err) if (err)
goto out; goto out;
tight = false; tight = false;
......
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