Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 09c543798c3c ("erofs: use meta buffers for
zmap operations").

Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20250716064152.3537457-1-hsiangkao@linux.alibaba.com

Gao Xiang df50848b 5e744cb6

+10 -13
+10 -13
fs/erofs/zmap.c
··· 620 620 return 0; 621 621 } 622 622 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) 624 624 { 625 625 struct erofs_inode *const vi = EROFS_I(inode); 626 626 struct super_block *const sb = inode->i_sb; 627 627 int err, headnr; 628 628 erofs_off_t pos; 629 - struct erofs_buf buf = __EROFS_BUF_INITIALIZER; 630 629 struct z_erofs_map_header *h; 631 630 632 631 if (test_bit(EROFS_I_Z_INITED_BIT, &vi->flags)) { ··· 645 646 goto out_unlock; 646 647 647 648 pos = ALIGN(erofs_iloc(inode) + vi->inode_isize + vi->xattr_isize, 8); 648 - h = erofs_read_metabuf(&buf, sb, pos); 649 + h = erofs_read_metabuf(&map->buf, sb, pos); 649 650 if (IS_ERR(h)) { 650 651 err = PTR_ERR(h); 651 652 goto out_unlock; ··· 683 684 erofs_err(sb, "unknown HEAD%u format %u for nid %llu, please upgrade kernel", 684 685 headnr + 1, vi->z_algorithmtype[headnr], vi->nid); 685 686 err = -EOPNOTSUPP; 686 - goto out_put_metabuf; 687 + goto out_unlock; 687 688 } 688 689 689 690 if (!erofs_sb_has_big_pcluster(EROFS_SB(sb)) && ··· 692 693 erofs_err(sb, "per-inode big pcluster without sb feature for nid %llu", 693 694 vi->nid); 694 695 err = -EFSCORRUPTED; 695 - goto out_put_metabuf; 696 + goto out_unlock; 696 697 } 697 698 if (vi->datalayout == EROFS_INODE_COMPRESSED_COMPACT && 698 699 !(vi->z_advise & Z_EROFS_ADVISE_BIG_PCLUSTER_1) ^ ··· 700 701 erofs_err(sb, "big pcluster head1/2 of compact indexes should be consistent for nid %llu", 701 702 vi->nid); 702 703 err = -EFSCORRUPTED; 703 - goto out_put_metabuf; 704 + goto out_unlock; 704 705 } 705 706 706 707 if (vi->z_idata_size || 707 708 (vi->z_advise & Z_EROFS_ADVISE_FRAGMENT_PCLUSTER)) { 708 - struct erofs_map_blocks map = { 709 + struct erofs_map_blocks tm = { 709 710 .buf = __EROFS_BUF_INITIALIZER 710 711 }; 711 712 712 - err = z_erofs_map_blocks_fo(inode, &map, 713 + err = z_erofs_map_blocks_fo(inode, &tm, 713 714 EROFS_GET_BLOCKS_FINDTAIL); 714 - erofs_put_metabuf(&map.buf); 715 + erofs_put_metabuf(&tm.buf); 715 716 if (err < 0) 716 - goto out_put_metabuf; 717 + goto out_unlock; 717 718 } 718 719 done: 719 720 /* paired with smp_mb() at the beginning of the function */ 720 721 smp_mb(); 721 722 set_bit(EROFS_I_Z_INITED_BIT, &vi->flags); 722 - out_put_metabuf: 723 - erofs_put_metabuf(&buf); 724 723 out_unlock: 725 724 clear_and_wake_up_bit(EROFS_I_BL_Z_BIT, &vi->flags); 726 725 return err; ··· 736 739 map->m_la = inode->i_size; 737 740 map->m_flags = 0; 738 741 } else { 739 - err = z_erofs_fill_inode_lazy(inode); 742 + err = z_erofs_fill_inode(inode, map); 740 743 if (!err) { 741 744 if (vi->datalayout == EROFS_INODE_COMPRESSED_FULL && 742 745 (vi->z_advise & Z_EROFS_ADVISE_EXTENTS))