Skip to content

Commit 1d5a938

Browse files
hsiangkaogregkh
authored andcommitted
erofs: remove need_kmap in erofs_read_metabuf()
[ Upstream commit 5e744cb ] - 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 <hsiangkao@linux.alibaba.com> Reviewed-by: Chao Yu <chao@kernel.org> Link: https://lore.kernel.org/r/20250714090907.4095645-1-hsiangkao@linux.alibaba.com Stable-dep-of: 131897c ("erofs: fix invalid algorithm for encoded extents") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 30fb1a3 commit 1d5a938

8 files changed

Lines changed: 22 additions & 21 deletions

File tree

fs/erofs/data.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ void erofs_init_metabuf(struct erofs_buf *buf, struct super_block *sb)
6565
}
6666

6767
void *erofs_read_metabuf(struct erofs_buf *buf, struct super_block *sb,
68-
erofs_off_t offset, bool need_kmap)
68+
erofs_off_t offset)
6969
{
7070
erofs_init_metabuf(buf, sb);
71-
return erofs_bread(buf, offset, need_kmap);
71+
return erofs_bread(buf, offset, true);
7272
}
7373

7474
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)
118118
pos = ALIGN(erofs_iloc(inode) + vi->inode_isize +
119119
vi->xattr_isize, unit) + unit * chunknr;
120120

121-
idx = erofs_read_metabuf(&buf, sb, pos, true);
121+
idx = erofs_read_metabuf(&buf, sb, pos);
122122
if (IS_ERR(idx)) {
123123
err = PTR_ERR(idx);
124124
goto out;
@@ -299,7 +299,7 @@ static int erofs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
299299
struct erofs_buf buf = __EROFS_BUF_INITIALIZER;
300300

301301
iomap->type = IOMAP_INLINE;
302-
ptr = erofs_read_metabuf(&buf, sb, mdev.m_pa, true);
302+
ptr = erofs_read_metabuf(&buf, sb, mdev.m_pa);
303303
if (IS_ERR(ptr))
304304
return PTR_ERR(ptr);
305305
iomap->inline_data = ptr;

fs/erofs/fileio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static int erofs_fileio_scan_folio(struct erofs_fileio *io, struct folio *folio)
115115
void *src;
116116

117117
src = erofs_read_metabuf(&buf, inode->i_sb,
118-
map->m_pa + ofs, true);
118+
map->m_pa + ofs);
119119
if (IS_ERR(src)) {
120120
err = PTR_ERR(src);
121121
break;

fs/erofs/fscache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ static int erofs_fscache_data_read_slice(struct erofs_fscache_rq *req)
274274
size_t size = map.m_llen;
275275
void *src;
276276

277-
src = erofs_read_metabuf(&buf, sb, map.m_pa, true);
277+
src = erofs_read_metabuf(&buf, sb, map.m_pa);
278278
if (IS_ERR(src))
279279
return PTR_ERR(src);
280280

fs/erofs/inode.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ static int erofs_read_inode(struct inode *inode)
3939
void *ptr;
4040
int err = 0;
4141

42-
ptr = erofs_read_metabuf(&buf, sb, erofs_pos(sb, blkaddr), true);
42+
ptr = erofs_read_metabuf(&buf, sb, erofs_pos(sb, blkaddr));
4343
if (IS_ERR(ptr)) {
4444
err = PTR_ERR(ptr);
45-
erofs_err(sb, "failed to get inode (nid: %llu) page, err %d",
45+
erofs_err(sb, "failed to read inode meta block (nid: %llu): %d",
4646
vi->nid, err);
4747
goto err_out;
4848
}
@@ -78,10 +78,10 @@ static int erofs_read_inode(struct inode *inode)
7878

7979
memcpy(&copied, dic, gotten);
8080
ptr = erofs_read_metabuf(&buf, sb,
81-
erofs_pos(sb, blkaddr + 1), true);
81+
erofs_pos(sb, blkaddr + 1));
8282
if (IS_ERR(ptr)) {
8383
err = PTR_ERR(ptr);
84-
erofs_err(sb, "failed to get inode payload block (nid: %llu), err %d",
84+
erofs_err(sb, "failed to read inode payload block (nid: %llu): %d",
8585
vi->nid, err);
8686
goto err_out;
8787
}

fs/erofs/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ void erofs_put_metabuf(struct erofs_buf *buf);
385385
void *erofs_bread(struct erofs_buf *buf, erofs_off_t offset, bool need_kmap);
386386
void erofs_init_metabuf(struct erofs_buf *buf, struct super_block *sb);
387387
void *erofs_read_metabuf(struct erofs_buf *buf, struct super_block *sb,
388-
erofs_off_t offset, bool need_kmap);
388+
erofs_off_t offset);
389389
int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *dev);
390390
int erofs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
391391
u64 start, u64 len);

fs/erofs/super.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ static int erofs_init_device(struct erofs_buf *buf, struct super_block *sb,
141141
struct erofs_deviceslot *dis;
142142
struct file *file;
143143

144-
dis = erofs_read_metabuf(buf, sb, *pos, true);
144+
dis = erofs_read_metabuf(buf, sb, *pos);
145145
if (IS_ERR(dis))
146146
return PTR_ERR(dis);
147147

@@ -268,7 +268,7 @@ static int erofs_read_superblock(struct super_block *sb)
268268
void *data;
269269
int ret;
270270

271-
data = erofs_read_metabuf(&buf, sb, 0, true);
271+
data = erofs_read_metabuf(&buf, sb, 0);
272272
if (IS_ERR(data)) {
273273
erofs_err(sb, "cannot read erofs superblock");
274274
return PTR_ERR(data);

fs/erofs/zdata.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -855,10 +855,11 @@ static int z_erofs_pcluster_begin(struct z_erofs_frontend *fe)
855855
/* bind cache first when cached decompression is preferred */
856856
z_erofs_bind_cache(fe);
857857
} else {
858-
ptr = erofs_read_metabuf(&map->buf, sb, map->m_pa, false);
858+
erofs_init_metabuf(&map->buf, sb);
859+
ptr = erofs_bread(&map->buf, map->m_pa, false);
859860
if (IS_ERR(ptr)) {
860861
ret = PTR_ERR(ptr);
861-
erofs_err(sb, "failed to get inline data %d", ret);
862+
erofs_err(sb, "failed to get inline folio %d", ret);
862863
return ret;
863864
}
864865
folio_get(page_folio(map->buf.page));

fs/erofs/zmap.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static int z_erofs_load_full_lcluster(struct z_erofs_maprecorder *m,
3131
struct z_erofs_lcluster_index *di;
3232
unsigned int advise;
3333

34-
di = erofs_read_metabuf(&m->map->buf, inode->i_sb, pos, true);
34+
di = erofs_read_metabuf(&m->map->buf, inode->i_sb, pos);
3535
if (IS_ERR(di))
3636
return PTR_ERR(di);
3737
m->lcn = lcn;
@@ -146,7 +146,7 @@ static int z_erofs_load_compact_lcluster(struct z_erofs_maprecorder *m,
146146
else
147147
return -EOPNOTSUPP;
148148

149-
in = erofs_read_metabuf(&m->map->buf, m->inode->i_sb, pos, true);
149+
in = erofs_read_metabuf(&m->map->buf, m->inode->i_sb, pos);
150150
if (IS_ERR(in))
151151
return PTR_ERR(in);
152152

@@ -551,7 +551,7 @@ static int z_erofs_map_blocks_ext(struct inode *inode,
551551
map->m_flags = 0;
552552
if (recsz <= offsetof(struct z_erofs_extent, pstart_hi)) {
553553
if (recsz <= offsetof(struct z_erofs_extent, pstart_lo)) {
554-
ext = erofs_read_metabuf(&map->buf, sb, pos, true);
554+
ext = erofs_read_metabuf(&map->buf, sb, pos);
555555
if (IS_ERR(ext))
556556
return PTR_ERR(ext);
557557
pa = le64_to_cpu(*(__le64 *)ext);
@@ -564,7 +564,7 @@ static int z_erofs_map_blocks_ext(struct inode *inode,
564564
}
565565

566566
for (; lstart <= map->m_la; lstart += 1 << vi->z_lclusterbits) {
567-
ext = erofs_read_metabuf(&map->buf, sb, pos, true);
567+
ext = erofs_read_metabuf(&map->buf, sb, pos);
568568
if (IS_ERR(ext))
569569
return PTR_ERR(ext);
570570
map->m_plen = le32_to_cpu(ext->plen);
@@ -584,7 +584,7 @@ static int z_erofs_map_blocks_ext(struct inode *inode,
584584
for (l = 0, r = vi->z_extents; l < r; ) {
585585
mid = l + (r - l) / 2;
586586
ext = erofs_read_metabuf(&map->buf, sb,
587-
pos + mid * recsz, true);
587+
pos + mid * recsz);
588588
if (IS_ERR(ext))
589589
return PTR_ERR(ext);
590590

@@ -667,7 +667,7 @@ static int z_erofs_fill_inode_lazy(struct inode *inode)
667667
goto out_unlock;
668668

669669
pos = ALIGN(erofs_iloc(inode) + vi->inode_isize + vi->xattr_isize, 8);
670-
h = erofs_read_metabuf(&buf, sb, pos, true);
670+
h = erofs_read_metabuf(&buf, sb, pos);
671671
if (IS_ERR(h)) {
672672
err = PTR_ERR(h);
673673
goto out_unlock;

0 commit comments

Comments
 (0)