Skip to content

Commit 8bdb6a8

Browse files
Hongzhen Luohsiangkao
authored andcommitted
erofs: simplify erofs_map_blocks_flatmode()
Get rid of redundant variables (nblocks, offset) and a dead branch (!tailendpacking). Signed-off-by: Hongzhen Luo <[email protected]> Reviewed-by: Gao Xiang <[email protected]> Reviewed-by: Chao Yu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Gao Xiang <[email protected]>
1 parent 53d514b commit 8bdb6a8

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

fs/erofs/data.c

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,38 +79,28 @@ void *erofs_read_metabuf(struct erofs_buf *buf, struct super_block *sb,
7979
static int erofs_map_blocks_flatmode(struct inode *inode,
8080
struct erofs_map_blocks *map)
8181
{
82-
erofs_blk_t nblocks, lastblk;
83-
u64 offset = map->m_la;
8482
struct erofs_inode *vi = EROFS_I(inode);
8583
struct super_block *sb = inode->i_sb;
8684
bool tailendpacking = (vi->datalayout == EROFS_INODE_FLAT_INLINE);
85+
erofs_blk_t lastblk = erofs_iblks(inode) - tailendpacking;
8786

88-
nblocks = erofs_iblks(inode);
89-
lastblk = nblocks - tailendpacking;
90-
91-
/* there is no hole in flatmode */
92-
map->m_flags = EROFS_MAP_MAPPED;
93-
if (offset < erofs_pos(sb, lastblk)) {
87+
map->m_flags = EROFS_MAP_MAPPED; /* no hole in flat inodes */
88+
if (map->m_la < erofs_pos(sb, lastblk)) {
9489
map->m_pa = erofs_pos(sb, vi->raw_blkaddr) + map->m_la;
95-
map->m_plen = erofs_pos(sb, lastblk) - offset;
96-
} else if (tailendpacking) {
90+
map->m_plen = erofs_pos(sb, lastblk) - map->m_la;
91+
} else {
92+
DBG_BUGON(!tailendpacking);
9793
map->m_pa = erofs_iloc(inode) + vi->inode_isize +
98-
vi->xattr_isize + erofs_blkoff(sb, offset);
99-
map->m_plen = inode->i_size - offset;
94+
vi->xattr_isize + erofs_blkoff(sb, map->m_la);
95+
map->m_plen = inode->i_size - map->m_la;
10096

10197
/* inline data should be located in the same meta block */
10298
if (erofs_blkoff(sb, map->m_pa) + map->m_plen > sb->s_blocksize) {
103-
erofs_err(sb, "inline data cross block boundary @ nid %llu",
104-
vi->nid);
99+
erofs_err(sb, "inline data across blocks @ nid %llu", vi->nid);
105100
DBG_BUGON(1);
106101
return -EFSCORRUPTED;
107102
}
108103
map->m_flags |= EROFS_MAP_META;
109-
} else {
110-
erofs_err(sb, "internal error @ nid: %llu (size %llu), m_la 0x%llx",
111-
vi->nid, inode->i_size, map->m_la);
112-
DBG_BUGON(1);
113-
return -EIO;
114104
}
115105
return 0;
116106
}

0 commit comments

Comments
 (0)