- need_kmap is always true except for a ztailpacking case; thus, just
   open-code that one;

 - The upcoming metadata compression will add a new boolean, so simplify
   this first.

Signed-off-by: Gao Xiang <[email protected]>
---
 fs/erofs/data.c     |  8 ++++----
 fs/erofs/fileio.c   |  2 +-
 fs/erofs/fscache.c  |  2 +-
 fs/erofs/inode.c    |  8 ++++----
 fs/erofs/internal.h |  2 +-
 fs/erofs/super.c    |  4 ++--
 fs/erofs/zdata.c    |  5 +++--
 fs/erofs/zmap.c     | 12 ++++++------
 8 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 16e4a6bd9b97..dd7d86809c18 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -65,10 +65,10 @@ void erofs_init_metabuf(struct erofs_buf *buf, struct 
super_block *sb)
 }
 
 void *erofs_read_metabuf(struct erofs_buf *buf, struct super_block *sb,
-                        erofs_off_t offset, bool need_kmap)
+                        erofs_off_t offset)
 {
        erofs_init_metabuf(buf, sb);
-       return erofs_bread(buf, offset, need_kmap);
+       return erofs_bread(buf, offset, true);
 }
 
 int erofs_map_blocks(struct inode *inode, struct erofs_map_blocks *map)
@@ -118,7 +118,7 @@ int erofs_map_blocks(struct inode *inode, struct 
erofs_map_blocks *map)
        pos = ALIGN(erofs_iloc(inode) + vi->inode_isize +
                    vi->xattr_isize, unit) + unit * chunknr;
 
-       idx = erofs_read_metabuf(&buf, sb, pos, true);
+       idx = erofs_read_metabuf(&buf, sb, pos);
        if (IS_ERR(idx)) {
                err = PTR_ERR(idx);
                goto out;
@@ -299,7 +299,7 @@ static int erofs_iomap_begin(struct inode *inode, loff_t 
offset, loff_t length,
                struct erofs_buf buf = __EROFS_BUF_INITIALIZER;
 
                iomap->type = IOMAP_INLINE;
-               ptr = erofs_read_metabuf(&buf, sb, mdev.m_pa, true);
+               ptr = erofs_read_metabuf(&buf, sb, mdev.m_pa);
                if (IS_ERR(ptr))
                        return PTR_ERR(ptr);
                iomap->inline_data = ptr;
diff --git a/fs/erofs/fileio.c b/fs/erofs/fileio.c
index 91781718199e..3ee082476c8c 100644
--- a/fs/erofs/fileio.c
+++ b/fs/erofs/fileio.c
@@ -115,7 +115,7 @@ static int erofs_fileio_scan_folio(struct erofs_fileio *io, 
struct folio *folio)
                        void *src;
 
                        src = erofs_read_metabuf(&buf, inode->i_sb,
-                                                map->m_pa + ofs, true);
+                                                map->m_pa + ofs);
                        if (IS_ERR(src)) {
                                err = PTR_ERR(src);
                                break;
diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
index 34517ca9df91..9a8ee646e51d 100644
--- a/fs/erofs/fscache.c
+++ b/fs/erofs/fscache.c
@@ -274,7 +274,7 @@ static int erofs_fscache_data_read_slice(struct 
erofs_fscache_rq *req)
                size_t size = map.m_llen;
                void *src;
 
-               src = erofs_read_metabuf(&buf, sb, map.m_pa, true);
+               src = erofs_read_metabuf(&buf, sb, map.m_pa);
                if (IS_ERR(src))
                        return PTR_ERR(src);
 
diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
index a0ae0b4f7b01..47215c5e3385 100644
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -39,10 +39,10 @@ static int erofs_read_inode(struct inode *inode)
        void *ptr;
        int err = 0;
 
-       ptr = erofs_read_metabuf(&buf, sb, erofs_pos(sb, blkaddr), true);
+       ptr = erofs_read_metabuf(&buf, sb, erofs_pos(sb, blkaddr));
        if (IS_ERR(ptr)) {
                err = PTR_ERR(ptr);
-               erofs_err(sb, "failed to get inode (nid: %llu) page, err %d",
+               erofs_err(sb, "failed to read inode meta block (nid: %llu): %d",
                          vi->nid, err);
                goto err_out;
        }
@@ -78,10 +78,10 @@ static int erofs_read_inode(struct inode *inode)
 
                        memcpy(&copied, dic, gotten);
                        ptr = erofs_read_metabuf(&buf, sb,
-                                       erofs_pos(sb, blkaddr + 1), true);
+                                       erofs_pos(sb, blkaddr + 1));
                        if (IS_ERR(ptr)) {
                                err = PTR_ERR(ptr);
-                               erofs_err(sb, "failed to get inode payload 
block (nid: %llu), err %d",
+                               erofs_err(sb, "failed to read inode payload 
block (nid: %llu): %d",
                                          vi->nid, err);
                                goto err_out;
                        }
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 06b867d2fc3b..a7699114f6fe 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -385,7 +385,7 @@ void erofs_put_metabuf(struct erofs_buf *buf);
 void *erofs_bread(struct erofs_buf *buf, erofs_off_t offset, bool need_kmap);
 void erofs_init_metabuf(struct erofs_buf *buf, struct super_block *sb);
 void *erofs_read_metabuf(struct erofs_buf *buf, struct super_block *sb,
-                        erofs_off_t offset, bool need_kmap);
+                        erofs_off_t offset);
 int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *dev);
 int erofs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
                 u64 start, u64 len);
diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index e1e9f06e8342..bc27fa3bd678 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -141,7 +141,7 @@ static int erofs_init_device(struct erofs_buf *buf, struct 
super_block *sb,
        struct erofs_deviceslot *dis;
        struct file *file;
 
-       dis = erofs_read_metabuf(buf, sb, *pos, true);
+       dis = erofs_read_metabuf(buf, sb, *pos);
        if (IS_ERR(dis))
                return PTR_ERR(dis);
 
@@ -258,7 +258,7 @@ static int erofs_read_superblock(struct super_block *sb)
        void *data;
        int ret;
 
-       data = erofs_read_metabuf(&buf, sb, 0, true);
+       data = erofs_read_metabuf(&buf, sb, 0);
        if (IS_ERR(data)) {
                erofs_err(sb, "cannot read erofs superblock");
                return PTR_ERR(data);
diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index 5e0240b7b7db..0d1ddd9b15de 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -855,10 +855,11 @@ static int z_erofs_pcluster_begin(struct z_erofs_frontend 
*fe)
                /* bind cache first when cached decompression is preferred */
                z_erofs_bind_cache(fe);
        } else {
-               ptr = erofs_read_metabuf(&map->buf, sb, map->m_pa, false);
+               erofs_init_metabuf(&map->buf, sb);
+               ptr = erofs_bread(&map->buf, map->m_pa, false);
                if (IS_ERR(ptr)) {
                        ret = PTR_ERR(ptr);
-                       erofs_err(sb, "failed to get inline data %d", ret);
+                       erofs_err(sb, "failed to get inline folio %d", ret);
                        return ret;
                }
                folio_get(page_folio(map->buf.page));
diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c
index 312ec54668aa..ff1d0751fc61 100644
--- a/fs/erofs/zmap.c
+++ b/fs/erofs/zmap.c
@@ -31,7 +31,7 @@ static int z_erofs_load_full_lcluster(struct 
z_erofs_maprecorder *m,
        struct z_erofs_lcluster_index *di;
        unsigned int advise;
 
-       di = erofs_read_metabuf(&m->map->buf, inode->i_sb, pos, true);
+       di = erofs_read_metabuf(&m->map->buf, inode->i_sb, pos);
        if (IS_ERR(di))
                return PTR_ERR(di);
        m->lcn = lcn;
@@ -146,7 +146,7 @@ static int z_erofs_load_compact_lcluster(struct 
z_erofs_maprecorder *m,
        else
                return -EOPNOTSUPP;
 
-       in = erofs_read_metabuf(&m->map->buf, m->inode->i_sb, pos, true);
+       in = erofs_read_metabuf(&m->map->buf, m->inode->i_sb, pos);
        if (IS_ERR(in))
                return PTR_ERR(in);
 
@@ -530,7 +530,7 @@ static int z_erofs_map_blocks_ext(struct inode *inode,
        map->m_flags = 0;
        if (recsz <= offsetof(struct z_erofs_extent, pstart_hi)) {
                if (recsz <= offsetof(struct z_erofs_extent, pstart_lo)) {
-                       ext = erofs_read_metabuf(&map->buf, sb, pos, true);
+                       ext = erofs_read_metabuf(&map->buf, sb, pos);
                        if (IS_ERR(ext))
                                return PTR_ERR(ext);
                        pa = le64_to_cpu(*(__le64 *)ext);
@@ -543,7 +543,7 @@ static int z_erofs_map_blocks_ext(struct inode *inode,
                }
 
                for (; lstart <= map->m_la; lstart += 1 << vi->z_lclusterbits) {
-                       ext = erofs_read_metabuf(&map->buf, sb, pos, true);
+                       ext = erofs_read_metabuf(&map->buf, sb, pos);
                        if (IS_ERR(ext))
                                return PTR_ERR(ext);
                        map->m_plen = le32_to_cpu(ext->plen);
@@ -563,7 +563,7 @@ static int z_erofs_map_blocks_ext(struct inode *inode,
                for (l = 0, r = vi->z_extents; l < r; ) {
                        mid = l + (r - l) / 2;
                        ext = erofs_read_metabuf(&map->buf, sb,
-                                                pos + mid * recsz, true);
+                                                pos + mid * recsz);
                        if (IS_ERR(ext))
                                return PTR_ERR(ext);
 
@@ -646,7 +646,7 @@ static int z_erofs_fill_inode_lazy(struct inode *inode)
                goto out_unlock;
 
        pos = ALIGN(erofs_iloc(inode) + vi->inode_isize + vi->xattr_isize, 8);
-       h = erofs_read_metabuf(&buf, sb, pos, true);
+       h = erofs_read_metabuf(&buf, sb, pos);
        if (IS_ERR(h)) {
                err = PTR_ERR(h);
                goto out_unlock;
-- 
2.43.5


Reply via email to