mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-04 04:04:19 +00:00
erofs: simplify erofs_map_blocks_flatmode()
Get rid of redundant variables (nblocks, offset) and a dead branch (!tailendpacking). Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com> Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com> Reviewed-by: Chao Yu <chao@kernel.org> Link: https://lore.kernel.org/r/20240905030339.1474396-1-hongzhen@linux.alibaba.com Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
This commit is contained in:
parent
53d514b970
commit
8bdb6a8393
@ -79,38 +79,28 @@ void *erofs_read_metabuf(struct erofs_buf *buf, struct super_block *sb,
|
|||||||
static int erofs_map_blocks_flatmode(struct inode *inode,
|
static int erofs_map_blocks_flatmode(struct inode *inode,
|
||||||
struct erofs_map_blocks *map)
|
struct erofs_map_blocks *map)
|
||||||
{
|
{
|
||||||
erofs_blk_t nblocks, lastblk;
|
|
||||||
u64 offset = map->m_la;
|
|
||||||
struct erofs_inode *vi = EROFS_I(inode);
|
struct erofs_inode *vi = EROFS_I(inode);
|
||||||
struct super_block *sb = inode->i_sb;
|
struct super_block *sb = inode->i_sb;
|
||||||
bool tailendpacking = (vi->datalayout == EROFS_INODE_FLAT_INLINE);
|
bool tailendpacking = (vi->datalayout == EROFS_INODE_FLAT_INLINE);
|
||||||
|
erofs_blk_t lastblk = erofs_iblks(inode) - tailendpacking;
|
||||||
|
|
||||||
nblocks = erofs_iblks(inode);
|
map->m_flags = EROFS_MAP_MAPPED; /* no hole in flat inodes */
|
||||||
lastblk = nblocks - tailendpacking;
|
if (map->m_la < erofs_pos(sb, lastblk)) {
|
||||||
|
|
||||||
/* there is no hole in flatmode */
|
|
||||||
map->m_flags = EROFS_MAP_MAPPED;
|
|
||||||
if (offset < erofs_pos(sb, lastblk)) {
|
|
||||||
map->m_pa = erofs_pos(sb, vi->raw_blkaddr) + map->m_la;
|
map->m_pa = erofs_pos(sb, vi->raw_blkaddr) + map->m_la;
|
||||||
map->m_plen = erofs_pos(sb, lastblk) - offset;
|
map->m_plen = erofs_pos(sb, lastblk) - map->m_la;
|
||||||
} else if (tailendpacking) {
|
} else {
|
||||||
|
DBG_BUGON(!tailendpacking);
|
||||||
map->m_pa = erofs_iloc(inode) + vi->inode_isize +
|
map->m_pa = erofs_iloc(inode) + vi->inode_isize +
|
||||||
vi->xattr_isize + erofs_blkoff(sb, offset);
|
vi->xattr_isize + erofs_blkoff(sb, map->m_la);
|
||||||
map->m_plen = inode->i_size - offset;
|
map->m_plen = inode->i_size - map->m_la;
|
||||||
|
|
||||||
/* inline data should be located in the same meta block */
|
/* inline data should be located in the same meta block */
|
||||||
if (erofs_blkoff(sb, map->m_pa) + map->m_plen > sb->s_blocksize) {
|
if (erofs_blkoff(sb, map->m_pa) + map->m_plen > sb->s_blocksize) {
|
||||||
erofs_err(sb, "inline data cross block boundary @ nid %llu",
|
erofs_err(sb, "inline data across blocks @ nid %llu", vi->nid);
|
||||||
vi->nid);
|
|
||||||
DBG_BUGON(1);
|
DBG_BUGON(1);
|
||||||
return -EFSCORRUPTED;
|
return -EFSCORRUPTED;
|
||||||
}
|
}
|
||||||
map->m_flags |= EROFS_MAP_META;
|
map->m_flags |= EROFS_MAP_META;
|
||||||
} else {
|
|
||||||
erofs_err(sb, "internal error @ nid: %llu (size %llu), m_la 0x%llx",
|
|
||||||
vi->nid, inode->i_size, map->m_la);
|
|
||||||
DBG_BUGON(1);
|
|
||||||
return -EIO;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user