Skip to content

Commit df50848

Browse files
committed
erofs: unify meta buffers in z_erofs_fill_inode()
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 09c5437 ("erofs: use meta buffers for zmap operations"). Signed-off-by: Gao Xiang <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 5e744cb commit df50848

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

fs/erofs/zmap.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -620,13 +620,12 @@ static int z_erofs_map_blocks_ext(struct inode *inode,
620620
return 0;
621621
}
622622

623-
static int z_erofs_fill_inode_lazy(struct inode *inode)
623+
static int z_erofs_fill_inode(struct inode *inode, struct erofs_map_blocks *map)
624624
{
625625
struct erofs_inode *const vi = EROFS_I(inode);
626626
struct super_block *const sb = inode->i_sb;
627627
int err, headnr;
628628
erofs_off_t pos;
629-
struct erofs_buf buf = __EROFS_BUF_INITIALIZER;
630629
struct z_erofs_map_header *h;
631630

632631
if (test_bit(EROFS_I_Z_INITED_BIT, &vi->flags)) {
@@ -646,7 +645,7 @@ static int z_erofs_fill_inode_lazy(struct inode *inode)
646645
goto out_unlock;
647646

648647
pos = ALIGN(erofs_iloc(inode) + vi->inode_isize + vi->xattr_isize, 8);
649-
h = erofs_read_metabuf(&buf, sb, pos);
648+
h = erofs_read_metabuf(&map->buf, sb, pos);
650649
if (IS_ERR(h)) {
651650
err = PTR_ERR(h);
652651
goto out_unlock;
@@ -684,7 +683,7 @@ static int z_erofs_fill_inode_lazy(struct inode *inode)
684683
erofs_err(sb, "unknown HEAD%u format %u for nid %llu, please upgrade kernel",
685684
headnr + 1, vi->z_algorithmtype[headnr], vi->nid);
686685
err = -EOPNOTSUPP;
687-
goto out_put_metabuf;
686+
goto out_unlock;
688687
}
689688

690689
if (!erofs_sb_has_big_pcluster(EROFS_SB(sb)) &&
@@ -693,35 +692,33 @@ static int z_erofs_fill_inode_lazy(struct inode *inode)
693692
erofs_err(sb, "per-inode big pcluster without sb feature for nid %llu",
694693
vi->nid);
695694
err = -EFSCORRUPTED;
696-
goto out_put_metabuf;
695+
goto out_unlock;
697696
}
698697
if (vi->datalayout == EROFS_INODE_COMPRESSED_COMPACT &&
699698
!(vi->z_advise & Z_EROFS_ADVISE_BIG_PCLUSTER_1) ^
700699
!(vi->z_advise & Z_EROFS_ADVISE_BIG_PCLUSTER_2)) {
701700
erofs_err(sb, "big pcluster head1/2 of compact indexes should be consistent for nid %llu",
702701
vi->nid);
703702
err = -EFSCORRUPTED;
704-
goto out_put_metabuf;
703+
goto out_unlock;
705704
}
706705

707706
if (vi->z_idata_size ||
708707
(vi->z_advise & Z_EROFS_ADVISE_FRAGMENT_PCLUSTER)) {
709-
struct erofs_map_blocks map = {
708+
struct erofs_map_blocks tm = {
710709
.buf = __EROFS_BUF_INITIALIZER
711710
};
712711

713-
err = z_erofs_map_blocks_fo(inode, &map,
712+
err = z_erofs_map_blocks_fo(inode, &tm,
714713
EROFS_GET_BLOCKS_FINDTAIL);
715-
erofs_put_metabuf(&map.buf);
714+
erofs_put_metabuf(&tm.buf);
716715
if (err < 0)
717-
goto out_put_metabuf;
716+
goto out_unlock;
718717
}
719718
done:
720719
/* paired with smp_mb() at the beginning of the function */
721720
smp_mb();
722721
set_bit(EROFS_I_Z_INITED_BIT, &vi->flags);
723-
out_put_metabuf:
724-
erofs_put_metabuf(&buf);
725722
out_unlock:
726723
clear_and_wake_up_bit(EROFS_I_BL_Z_BIT, &vi->flags);
727724
return err;
@@ -739,7 +736,7 @@ int z_erofs_map_blocks_iter(struct inode *inode, struct erofs_map_blocks *map,
739736
map->m_la = inode->i_size;
740737
map->m_flags = 0;
741738
} else {
742-
err = z_erofs_fill_inode_lazy(inode);
739+
err = z_erofs_fill_inode(inode, map);
743740
if (!err) {
744741
if (vi->datalayout == EROFS_INODE_COMPRESSED_FULL &&
745742
(vi->z_advise & Z_EROFS_ADVISE_EXTENTS))

0 commit comments

Comments
 (0)