* [PATCH 1/2] erofs: remove need_kmap in erofs_read_metabuf()
@ 2025-07-14 9:09 Gao Xiang
2025-07-14 9:09 ` [PATCH 2/2] erofs: unify meta buffers in z_erofs_fill_inode() Gao Xiang
2025-07-15 2:36 ` [PATCH 1/2] erofs: remove need_kmap in erofs_read_metabuf() Chao Yu
0 siblings, 2 replies; 6+ messages in thread
From: Gao Xiang @ 2025-07-14 9:09 UTC (permalink / raw)
To: linux-erofs; +Cc: LKML, Gao Xiang
- 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>
---
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] erofs: unify meta buffers in z_erofs_fill_inode()
2025-07-14 9:09 [PATCH 1/2] erofs: remove need_kmap in erofs_read_metabuf() Gao Xiang
@ 2025-07-14 9:09 ` Gao Xiang
2025-07-15 2:40 ` Chao Yu
` (2 more replies)
2025-07-15 2:36 ` [PATCH 1/2] erofs: remove need_kmap in erofs_read_metabuf() Chao Yu
1 sibling, 3 replies; 6+ messages in thread
From: Gao Xiang @ 2025-07-14 9:09 UTC (permalink / raw)
To: linux-erofs; +Cc: LKML, Gao Xiang
There is no need to keep additional local metabufs since we already
have one in `struct erofs_map_blocks`.
This was actually a leftover when applying meta buffers to zmap
operations, see commit 09c543798c3c ("erofs: use meta buffers for
zmap operations").
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
fs/erofs/zmap.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c
index ff1d0751fc61..9afc8a68bacb 100644
--- a/fs/erofs/zmap.c
+++ b/fs/erofs/zmap.c
@@ -620,13 +620,12 @@ static int z_erofs_map_blocks_ext(struct inode *inode,
return 0;
}
-static int z_erofs_fill_inode_lazy(struct inode *inode)
+static int z_erofs_fill_inode(struct inode *inode, struct erofs_map_blocks *map)
{
struct erofs_inode *const vi = EROFS_I(inode);
struct super_block *const sb = inode->i_sb;
int err, headnr;
erofs_off_t pos;
- struct erofs_buf buf = __EROFS_BUF_INITIALIZER;
struct z_erofs_map_header *h;
if (test_bit(EROFS_I_Z_INITED_BIT, &vi->flags)) {
@@ -646,7 +645,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);
+ h = erofs_read_metabuf(&map->buf, sb, pos);
if (IS_ERR(h)) {
err = PTR_ERR(h);
goto out_unlock;
@@ -684,7 +683,7 @@ static int z_erofs_fill_inode_lazy(struct inode *inode)
erofs_err(sb, "unknown HEAD%u format %u for nid %llu, please upgrade kernel",
headnr + 1, vi->z_algorithmtype[headnr], vi->nid);
err = -EOPNOTSUPP;
- goto out_put_metabuf;
+ goto out_unlock;
}
if (!erofs_sb_has_big_pcluster(EROFS_SB(sb)) &&
@@ -693,7 +692,7 @@ static int z_erofs_fill_inode_lazy(struct inode *inode)
erofs_err(sb, "per-inode big pcluster without sb feature for nid %llu",
vi->nid);
err = -EFSCORRUPTED;
- goto out_put_metabuf;
+ goto out_unlock;
}
if (vi->datalayout == EROFS_INODE_COMPRESSED_COMPACT &&
!(vi->z_advise & Z_EROFS_ADVISE_BIG_PCLUSTER_1) ^
@@ -701,27 +700,20 @@ static int z_erofs_fill_inode_lazy(struct inode *inode)
erofs_err(sb, "big pcluster head1/2 of compact indexes should be consistent for nid %llu",
vi->nid);
err = -EFSCORRUPTED;
- goto out_put_metabuf;
+ goto out_unlock;
}
if (vi->z_idata_size ||
(vi->z_advise & Z_EROFS_ADVISE_FRAGMENT_PCLUSTER)) {
- struct erofs_map_blocks map = {
- .buf = __EROFS_BUF_INITIALIZER
- };
-
- err = z_erofs_map_blocks_fo(inode, &map,
+ err = z_erofs_map_blocks_fo(inode, map,
EROFS_GET_BLOCKS_FINDTAIL);
- erofs_put_metabuf(&map.buf);
if (err < 0)
- goto out_put_metabuf;
+ goto out_unlock;
}
done:
/* paired with smp_mb() at the beginning of the function */
smp_mb();
set_bit(EROFS_I_Z_INITED_BIT, &vi->flags);
-out_put_metabuf:
- erofs_put_metabuf(&buf);
out_unlock:
clear_and_wake_up_bit(EROFS_I_BL_Z_BIT, &vi->flags);
return err;
@@ -739,7 +731,7 @@ int z_erofs_map_blocks_iter(struct inode *inode, struct erofs_map_blocks *map,
map->m_la = inode->i_size;
map->m_flags = 0;
} else {
- err = z_erofs_fill_inode_lazy(inode);
+ err = z_erofs_fill_inode(inode, map);
if (!err) {
if (vi->datalayout == EROFS_INODE_COMPRESSED_FULL &&
(vi->z_advise & Z_EROFS_ADVISE_EXTENTS))
--
2.43.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] erofs: remove need_kmap in erofs_read_metabuf()
2025-07-14 9:09 [PATCH 1/2] erofs: remove need_kmap in erofs_read_metabuf() Gao Xiang
2025-07-14 9:09 ` [PATCH 2/2] erofs: unify meta buffers in z_erofs_fill_inode() Gao Xiang
@ 2025-07-15 2:36 ` Chao Yu
1 sibling, 0 replies; 6+ messages in thread
From: Chao Yu @ 2025-07-15 2:36 UTC (permalink / raw)
To: Gao Xiang, linux-erofs; +Cc: chao, LKML
On 7/14/25 17:09, Gao Xiang wrote:
> - 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>
Thanks,
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] erofs: unify meta buffers in z_erofs_fill_inode()
2025-07-14 9:09 ` [PATCH 2/2] erofs: unify meta buffers in z_erofs_fill_inode() Gao Xiang
@ 2025-07-15 2:40 ` Chao Yu
2025-07-15 2:40 ` Gao Xiang
2025-07-16 6:41 ` [PATCH v2 " Gao Xiang
2 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2025-07-15 2:40 UTC (permalink / raw)
To: Gao Xiang, linux-erofs; +Cc: chao, LKML
On 7/14/25 17:09, Gao Xiang wrote:
> There is no need to keep additional local metabufs since we already
> have one in `struct erofs_map_blocks`.
>
> This was actually a leftover when applying meta buffers to zmap
> operations, see commit 09c543798c3c ("erofs: use meta buffers for
> zmap operations").
>
> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] erofs: unify meta buffers in z_erofs_fill_inode()
2025-07-14 9:09 ` [PATCH 2/2] erofs: unify meta buffers in z_erofs_fill_inode() Gao Xiang
2025-07-15 2:40 ` Chao Yu
@ 2025-07-15 2:40 ` Gao Xiang
2025-07-16 6:41 ` [PATCH v2 " Gao Xiang
2 siblings, 0 replies; 6+ messages in thread
From: Gao Xiang @ 2025-07-15 2:40 UTC (permalink / raw)
To: linux-erofs; +Cc: LKML
On 2025/7/14 17:09, Gao Xiang wrote:
> There is no need to keep additional local metabufs since we already
> have one in `struct erofs_map_blocks`.
>
> This was actually a leftover when applying meta buffers to zmap
> operations, see commit 09c543798c3c ("erofs: use meta buffers for
> zmap operations").
>
> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
> ---
> fs/erofs/zmap.c | 24 ++++++++----------------
> 1 file changed, 8 insertions(+), 16 deletions(-)
>
> diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c
> index ff1d0751fc61..9afc8a68bacb 100644
> --- a/fs/erofs/zmap.c
> +++ b/fs/erofs/zmap.c
> @@ -620,13 +620,12 @@ static int z_erofs_map_blocks_ext(struct inode *inode,
> return 0;
> }
>
> -static int z_erofs_fill_inode_lazy(struct inode *inode)
> +static int z_erofs_fill_inode(struct inode *inode, struct erofs_map_blocks *map)
> {
> struct erofs_inode *const vi = EROFS_I(inode);
> struct super_block *const sb = inode->i_sb;
> int err, headnr;
> erofs_off_t pos;
> - struct erofs_buf buf = __EROFS_BUF_INITIALIZER;
> struct z_erofs_map_header *h;
>
> if (test_bit(EROFS_I_Z_INITED_BIT, &vi->flags)) {
> @@ -646,7 +645,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);
> + h = erofs_read_metabuf(&map->buf, sb, pos);
> if (IS_ERR(h)) {
> err = PTR_ERR(h);
> goto out_unlock;
> @@ -684,7 +683,7 @@ static int z_erofs_fill_inode_lazy(struct inode *inode)
> erofs_err(sb, "unknown HEAD%u format %u for nid %llu, please upgrade kernel",
> headnr + 1, vi->z_algorithmtype[headnr], vi->nid);
> err = -EOPNOTSUPP;
> - goto out_put_metabuf;
> + goto out_unlock;
> }
>
> if (!erofs_sb_has_big_pcluster(EROFS_SB(sb)) &&
> @@ -693,7 +692,7 @@ static int z_erofs_fill_inode_lazy(struct inode *inode)
> erofs_err(sb, "per-inode big pcluster without sb feature for nid %llu",
> vi->nid);
> err = -EFSCORRUPTED;
> - goto out_put_metabuf;
> + goto out_unlock;
> }
> if (vi->datalayout == EROFS_INODE_COMPRESSED_COMPACT &&
> !(vi->z_advise & Z_EROFS_ADVISE_BIG_PCLUSTER_1) ^
> @@ -701,27 +700,20 @@ static int z_erofs_fill_inode_lazy(struct inode *inode)
> erofs_err(sb, "big pcluster head1/2 of compact indexes should be consistent for nid %llu",
> vi->nid);
> err = -EFSCORRUPTED;
> - goto out_put_metabuf;
> + goto out_unlock;
> }
>
> if (vi->z_idata_size ||
> (vi->z_advise & Z_EROFS_ADVISE_FRAGMENT_PCLUSTER)) {
> - struct erofs_map_blocks map = {
> - .buf = __EROFS_BUF_INITIALIZER
> - };
> -
> - err = z_erofs_map_blocks_fo(inode, &map,
> + err = z_erofs_map_blocks_fo(inode, map,
> EROFS_GET_BLOCKS_FINDTAIL);
> - erofs_put_metabuf(&map.buf);
> if (err < 0)
> - goto out_put_metabuf;
> + goto out_unlock;
Note that it has a regression, so need to discard this part.
Thanks,
Gao Xiang
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] erofs: unify meta buffers in z_erofs_fill_inode()
2025-07-14 9:09 ` [PATCH 2/2] erofs: unify meta buffers in z_erofs_fill_inode() Gao Xiang
2025-07-15 2:40 ` Chao Yu
2025-07-15 2:40 ` Gao Xiang
@ 2025-07-16 6:41 ` Gao Xiang
2 siblings, 0 replies; 6+ messages in thread
From: Gao Xiang @ 2025-07-16 6:41 UTC (permalink / raw)
To: linux-erofs; +Cc: LMKL, Gao Xiang
There is no need to keep additional local metabufs since we already
have one in `struct erofs_map_blocks`.
This was actually a leftover when applying meta buffers to zmap
operations, see commit 09c543798c3c ("erofs: use meta buffers for
zmap operations").
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
v1: https://lore.kernel.org/r/20250714090907.4095645-2-hsiangkao@linux.alibaba.com
change since v1:
- Fix a regresssion since EROFS_GET_BLOCKS_FINDTAIL will update the
original map to the tail extent so just keep using a new `map`.
fs/erofs/zmap.c | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c
index ff1d0751fc61..b72a0e3f9362 100644
--- a/fs/erofs/zmap.c
+++ b/fs/erofs/zmap.c
@@ -620,13 +620,12 @@ static int z_erofs_map_blocks_ext(struct inode *inode,
return 0;
}
-static int z_erofs_fill_inode_lazy(struct inode *inode)
+static int z_erofs_fill_inode(struct inode *inode, struct erofs_map_blocks *map)
{
struct erofs_inode *const vi = EROFS_I(inode);
struct super_block *const sb = inode->i_sb;
int err, headnr;
erofs_off_t pos;
- struct erofs_buf buf = __EROFS_BUF_INITIALIZER;
struct z_erofs_map_header *h;
if (test_bit(EROFS_I_Z_INITED_BIT, &vi->flags)) {
@@ -646,7 +645,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);
+ h = erofs_read_metabuf(&map->buf, sb, pos);
if (IS_ERR(h)) {
err = PTR_ERR(h);
goto out_unlock;
@@ -684,7 +683,7 @@ static int z_erofs_fill_inode_lazy(struct inode *inode)
erofs_err(sb, "unknown HEAD%u format %u for nid %llu, please upgrade kernel",
headnr + 1, vi->z_algorithmtype[headnr], vi->nid);
err = -EOPNOTSUPP;
- goto out_put_metabuf;
+ goto out_unlock;
}
if (!erofs_sb_has_big_pcluster(EROFS_SB(sb)) &&
@@ -693,7 +692,7 @@ static int z_erofs_fill_inode_lazy(struct inode *inode)
erofs_err(sb, "per-inode big pcluster without sb feature for nid %llu",
vi->nid);
err = -EFSCORRUPTED;
- goto out_put_metabuf;
+ goto out_unlock;
}
if (vi->datalayout == EROFS_INODE_COMPRESSED_COMPACT &&
!(vi->z_advise & Z_EROFS_ADVISE_BIG_PCLUSTER_1) ^
@@ -701,27 +700,25 @@ static int z_erofs_fill_inode_lazy(struct inode *inode)
erofs_err(sb, "big pcluster head1/2 of compact indexes should be consistent for nid %llu",
vi->nid);
err = -EFSCORRUPTED;
- goto out_put_metabuf;
+ goto out_unlock;
}
if (vi->z_idata_size ||
(vi->z_advise & Z_EROFS_ADVISE_FRAGMENT_PCLUSTER)) {
- struct erofs_map_blocks map = {
+ struct erofs_map_blocks tm = {
.buf = __EROFS_BUF_INITIALIZER
};
- err = z_erofs_map_blocks_fo(inode, &map,
+ err = z_erofs_map_blocks_fo(inode, &tm,
EROFS_GET_BLOCKS_FINDTAIL);
- erofs_put_metabuf(&map.buf);
+ erofs_put_metabuf(&tm.buf);
if (err < 0)
- goto out_put_metabuf;
+ goto out_unlock;
}
done:
/* paired with smp_mb() at the beginning of the function */
smp_mb();
set_bit(EROFS_I_Z_INITED_BIT, &vi->flags);
-out_put_metabuf:
- erofs_put_metabuf(&buf);
out_unlock:
clear_and_wake_up_bit(EROFS_I_BL_Z_BIT, &vi->flags);
return err;
@@ -739,7 +736,7 @@ int z_erofs_map_blocks_iter(struct inode *inode, struct erofs_map_blocks *map,
map->m_la = inode->i_size;
map->m_flags = 0;
} else {
- err = z_erofs_fill_inode_lazy(inode);
+ err = z_erofs_fill_inode(inode, map);
if (!err) {
if (vi->datalayout == EROFS_INODE_COMPRESSED_FULL &&
(vi->z_advise & Z_EROFS_ADVISE_EXTENTS))
--
2.43.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-07-16 6:41 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-14 9:09 [PATCH 1/2] erofs: remove need_kmap in erofs_read_metabuf() Gao Xiang
2025-07-14 9:09 ` [PATCH 2/2] erofs: unify meta buffers in z_erofs_fill_inode() Gao Xiang
2025-07-15 2:40 ` Chao Yu
2025-07-15 2:40 ` Gao Xiang
2025-07-16 6:41 ` [PATCH v2 " Gao Xiang
2025-07-15 2:36 ` [PATCH 1/2] erofs: remove need_kmap in erofs_read_metabuf() Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).