Commit d6918942 authored by Gao Xiang's avatar Gao Xiang

erofs: clean up z_erofs_load_full_lcluster()

Only four lcluster types here, remove redundant code.
No real logic changes.
Signed-off-by: default avatarGao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20240508123357.3266173-1-hsiangkao@linux.alibaba.com
parent 1872df8d
...@@ -396,8 +396,7 @@ enum { ...@@ -396,8 +396,7 @@ enum {
Z_EROFS_LCLUSTER_TYPE_MAX Z_EROFS_LCLUSTER_TYPE_MAX
}; };
#define Z_EROFS_LI_LCLUSTER_TYPE_BITS 2 #define Z_EROFS_LI_LCLUSTER_TYPE_MASK (Z_EROFS_LCLUSTER_TYPE_MAX - 1)
#define Z_EROFS_LI_LCLUSTER_TYPE_BIT 0
/* (noncompact only, HEAD) This pcluster refers to partial decompressed data */ /* (noncompact only, HEAD) This pcluster refers to partial decompressed data */
#define Z_EROFS_LI_PARTIAL_REF (1 << 15) #define Z_EROFS_LI_PARTIAL_REF (1 << 15)
...@@ -451,8 +450,6 @@ static inline void erofs_check_ondisk_layout_definitions(void) ...@@ -451,8 +450,6 @@ static inline void erofs_check_ondisk_layout_definitions(void)
sizeof(struct z_erofs_lcluster_index)); sizeof(struct z_erofs_lcluster_index));
BUILD_BUG_ON(sizeof(struct erofs_deviceslot) != 128); BUILD_BUG_ON(sizeof(struct erofs_deviceslot) != 128);
BUILD_BUG_ON(BIT(Z_EROFS_LI_LCLUSTER_TYPE_BITS) <
Z_EROFS_LCLUSTER_TYPE_MAX - 1);
/* exclude old compiler versions like gcc 7.5.0 */ /* exclude old compiler versions like gcc 7.5.0 */
BUILD_BUG_ON(__builtin_constant_p(fmh) ? BUILD_BUG_ON(__builtin_constant_p(fmh) ?
fmh != cpu_to_le64(1ULL << 63) : 0); fmh != cpu_to_le64(1ULL << 63) : 0);
......
...@@ -31,7 +31,7 @@ static int z_erofs_load_full_lcluster(struct z_erofs_maprecorder *m, ...@@ -31,7 +31,7 @@ static int z_erofs_load_full_lcluster(struct z_erofs_maprecorder *m,
vi->inode_isize + vi->xattr_isize) + vi->inode_isize + vi->xattr_isize) +
lcn * sizeof(struct z_erofs_lcluster_index); lcn * sizeof(struct z_erofs_lcluster_index);
struct z_erofs_lcluster_index *di; struct z_erofs_lcluster_index *di;
unsigned int advise, type; unsigned int advise;
m->kaddr = erofs_read_metabuf(&m->map->buf, inode->i_sb, m->kaddr = erofs_read_metabuf(&m->map->buf, inode->i_sb,
erofs_blknr(inode->i_sb, pos), EROFS_KMAP); erofs_blknr(inode->i_sb, pos), EROFS_KMAP);
...@@ -43,10 +43,8 @@ static int z_erofs_load_full_lcluster(struct z_erofs_maprecorder *m, ...@@ -43,10 +43,8 @@ static int z_erofs_load_full_lcluster(struct z_erofs_maprecorder *m,
di = m->kaddr + erofs_blkoff(inode->i_sb, pos); di = m->kaddr + erofs_blkoff(inode->i_sb, pos);
advise = le16_to_cpu(di->di_advise); advise = le16_to_cpu(di->di_advise);
type = (advise >> Z_EROFS_LI_LCLUSTER_TYPE_BIT) & m->type = advise & Z_EROFS_LI_LCLUSTER_TYPE_MASK;
((1 << Z_EROFS_LI_LCLUSTER_TYPE_BITS) - 1); if (m->type == Z_EROFS_LCLUSTER_TYPE_NONHEAD) {
switch (type) {
case Z_EROFS_LCLUSTER_TYPE_NONHEAD:
m->clusterofs = 1 << vi->z_logical_clusterbits; m->clusterofs = 1 << vi->z_logical_clusterbits;
m->delta[0] = le16_to_cpu(di->di_u.delta[0]); m->delta[0] = le16_to_cpu(di->di_u.delta[0]);
if (m->delta[0] & Z_EROFS_LI_D0_CBLKCNT) { if (m->delta[0] & Z_EROFS_LI_D0_CBLKCNT) {
...@@ -60,24 +58,15 @@ static int z_erofs_load_full_lcluster(struct z_erofs_maprecorder *m, ...@@ -60,24 +58,15 @@ static int z_erofs_load_full_lcluster(struct z_erofs_maprecorder *m,
m->delta[0] = 1; m->delta[0] = 1;
} }
m->delta[1] = le16_to_cpu(di->di_u.delta[1]); m->delta[1] = le16_to_cpu(di->di_u.delta[1]);
break; } else {
case Z_EROFS_LCLUSTER_TYPE_PLAIN: m->partialref = !!(advise & Z_EROFS_LI_PARTIAL_REF);
case Z_EROFS_LCLUSTER_TYPE_HEAD1:
case Z_EROFS_LCLUSTER_TYPE_HEAD2:
if (advise & Z_EROFS_LI_PARTIAL_REF)
m->partialref = true;
m->clusterofs = le16_to_cpu(di->di_clusterofs); m->clusterofs = le16_to_cpu(di->di_clusterofs);
if (m->clusterofs >= 1 << vi->z_logical_clusterbits) { if (m->clusterofs >= 1 << vi->z_logical_clusterbits) {
DBG_BUGON(1); DBG_BUGON(1);
return -EFSCORRUPTED; return -EFSCORRUPTED;
} }
m->pblk = le32_to_cpu(di->di_u.blkaddr); m->pblk = le32_to_cpu(di->di_u.blkaddr);
break;
default:
DBG_BUGON(1);
return -EOPNOTSUPP;
} }
m->type = type;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment