Skip to content

Commit c5fff1c

Browse files
hsiangkaogregkh
authored andcommitted
erofs: unify meta buffers in z_erofs_fill_inode()
[ Upstream commit df50848 ] 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] Stable-dep-of: 131897c ("erofs: fix invalid algorithm for encoded extents") Signed-off-by: Sasha Levin <[email protected]>
1 parent 1d5a938 commit c5fff1c

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
@@ -641,13 +641,12 @@ static int z_erofs_map_blocks_ext(struct inode *inode,
641641
return 0;
642642
}
643643

644-
static int z_erofs_fill_inode_lazy(struct inode *inode)
644+
static int z_erofs_fill_inode(struct inode *inode, struct erofs_map_blocks *map)
645645
{
646646
struct erofs_inode *const vi = EROFS_I(inode);
647647
struct super_block *const sb = inode->i_sb;
648648
int err, headnr;
649649
erofs_off_t pos;
650-
struct erofs_buf buf = __EROFS_BUF_INITIALIZER;
651650
struct z_erofs_map_header *h;
652651

653652
if (test_bit(EROFS_I_Z_INITED_BIT, &vi->flags)) {
@@ -667,7 +666,7 @@ static int z_erofs_fill_inode_lazy(struct inode *inode)
667666
goto out_unlock;
668667

669668
pos = ALIGN(erofs_iloc(inode) + vi->inode_isize + vi->xattr_isize, 8);
670-
h = erofs_read_metabuf(&buf, sb, pos);
669+
h = erofs_read_metabuf(&map->buf, sb, pos);
671670
if (IS_ERR(h)) {
672671
err = PTR_ERR(h);
673672
goto out_unlock;
@@ -705,7 +704,7 @@ static int z_erofs_fill_inode_lazy(struct inode *inode)
705704
erofs_err(sb, "unknown HEAD%u format %u for nid %llu, please upgrade kernel",
706705
headnr + 1, vi->z_algorithmtype[headnr], vi->nid);
707706
err = -EOPNOTSUPP;
708-
goto out_put_metabuf;
707+
goto out_unlock;
709708
}
710709

711710
if (!erofs_sb_has_big_pcluster(EROFS_SB(sb)) &&
@@ -714,35 +713,33 @@ static int z_erofs_fill_inode_lazy(struct inode *inode)
714713
erofs_err(sb, "per-inode big pcluster without sb feature for nid %llu",
715714
vi->nid);
716715
err = -EFSCORRUPTED;
717-
goto out_put_metabuf;
716+
goto out_unlock;
718717
}
719718
if (vi->datalayout == EROFS_INODE_COMPRESSED_COMPACT &&
720719
!(vi->z_advise & Z_EROFS_ADVISE_BIG_PCLUSTER_1) ^
721720
!(vi->z_advise & Z_EROFS_ADVISE_BIG_PCLUSTER_2)) {
722721
erofs_err(sb, "big pcluster head1/2 of compact indexes should be consistent for nid %llu",
723722
vi->nid);
724723
err = -EFSCORRUPTED;
725-
goto out_put_metabuf;
724+
goto out_unlock;
726725
}
727726

728727
if (vi->z_idata_size ||
729728
(vi->z_advise & Z_EROFS_ADVISE_FRAGMENT_PCLUSTER)) {
730-
struct erofs_map_blocks map = {
729+
struct erofs_map_blocks tm = {
731730
.buf = __EROFS_BUF_INITIALIZER
732731
};
733732

734-
err = z_erofs_map_blocks_fo(inode, &map,
733+
err = z_erofs_map_blocks_fo(inode, &tm,
735734
EROFS_GET_BLOCKS_FINDTAIL);
736-
erofs_put_metabuf(&map.buf);
735+
erofs_put_metabuf(&tm.buf);
737736
if (err < 0)
738-
goto out_put_metabuf;
737+
goto out_unlock;
739738
}
740739
done:
741740
/* paired with smp_mb() at the beginning of the function */
742741
smp_mb();
743742
set_bit(EROFS_I_Z_INITED_BIT, &vi->flags);
744-
out_put_metabuf:
745-
erofs_put_metabuf(&buf);
746743
out_unlock:
747744
clear_and_wake_up_bit(EROFS_I_BL_Z_BIT, &vi->flags);
748745
return err;
@@ -760,7 +757,7 @@ int z_erofs_map_blocks_iter(struct inode *inode, struct erofs_map_blocks *map,
760757
map->m_la = inode->i_size;
761758
map->m_flags = 0;
762759
} else {
763-
err = z_erofs_fill_inode_lazy(inode);
760+
err = z_erofs_fill_inode(inode, map);
764761
if (!err) {
765762
if (vi->datalayout == EROFS_INODE_COMPRESSED_FULL &&
766763
(vi->z_advise & Z_EROFS_ADVISE_EXTENTS))

0 commit comments

Comments
 (0)