Skip to content

Commit d691894

Browse files
committed
erofs: clean up z_erofs_load_full_lcluster()
Only four lcluster types here, remove redundant code. No real logic changes. Signed-off-by: Gao Xiang <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 1872df8 commit d691894

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

fs/erofs/erofs_fs.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,7 @@ enum {
396396
Z_EROFS_LCLUSTER_TYPE_MAX
397397
};
398398

399-
#define Z_EROFS_LI_LCLUSTER_TYPE_BITS 2
400-
#define Z_EROFS_LI_LCLUSTER_TYPE_BIT 0
399+
#define Z_EROFS_LI_LCLUSTER_TYPE_MASK (Z_EROFS_LCLUSTER_TYPE_MAX - 1)
401400

402401
/* (noncompact only, HEAD) This pcluster refers to partial decompressed data */
403402
#define Z_EROFS_LI_PARTIAL_REF (1 << 15)
@@ -451,8 +450,6 @@ static inline void erofs_check_ondisk_layout_definitions(void)
451450
sizeof(struct z_erofs_lcluster_index));
452451
BUILD_BUG_ON(sizeof(struct erofs_deviceslot) != 128);
453452

454-
BUILD_BUG_ON(BIT(Z_EROFS_LI_LCLUSTER_TYPE_BITS) <
455-
Z_EROFS_LCLUSTER_TYPE_MAX - 1);
456453
/* exclude old compiler versions like gcc 7.5.0 */
457454
BUILD_BUG_ON(__builtin_constant_p(fmh) ?
458455
fmh != cpu_to_le64(1ULL << 63) : 0);

fs/erofs/zmap.c

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static int z_erofs_load_full_lcluster(struct z_erofs_maprecorder *m,
3131
vi->inode_isize + vi->xattr_isize) +
3232
lcn * sizeof(struct z_erofs_lcluster_index);
3333
struct z_erofs_lcluster_index *di;
34-
unsigned int advise, type;
34+
unsigned int advise;
3535

3636
m->kaddr = erofs_read_metabuf(&m->map->buf, inode->i_sb,
3737
erofs_blknr(inode->i_sb, pos), EROFS_KMAP);
@@ -43,10 +43,8 @@ static int z_erofs_load_full_lcluster(struct z_erofs_maprecorder *m,
4343
di = m->kaddr + erofs_blkoff(inode->i_sb, pos);
4444

4545
advise = le16_to_cpu(di->di_advise);
46-
type = (advise >> Z_EROFS_LI_LCLUSTER_TYPE_BIT) &
47-
((1 << Z_EROFS_LI_LCLUSTER_TYPE_BITS) - 1);
48-
switch (type) {
49-
case Z_EROFS_LCLUSTER_TYPE_NONHEAD:
46+
m->type = advise & Z_EROFS_LI_LCLUSTER_TYPE_MASK;
47+
if (m->type == Z_EROFS_LCLUSTER_TYPE_NONHEAD) {
5048
m->clusterofs = 1 << vi->z_logical_clusterbits;
5149
m->delta[0] = le16_to_cpu(di->di_u.delta[0]);
5250
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,
6058
m->delta[0] = 1;
6159
}
6260
m->delta[1] = le16_to_cpu(di->di_u.delta[1]);
63-
break;
64-
case Z_EROFS_LCLUSTER_TYPE_PLAIN:
65-
case Z_EROFS_LCLUSTER_TYPE_HEAD1:
66-
case Z_EROFS_LCLUSTER_TYPE_HEAD2:
67-
if (advise & Z_EROFS_LI_PARTIAL_REF)
68-
m->partialref = true;
61+
} else {
62+
m->partialref = !!(advise & Z_EROFS_LI_PARTIAL_REF);
6963
m->clusterofs = le16_to_cpu(di->di_clusterofs);
7064
if (m->clusterofs >= 1 << vi->z_logical_clusterbits) {
7165
DBG_BUGON(1);
7266
return -EFSCORRUPTED;
7367
}
7468
m->pblk = le32_to_cpu(di->di_u.blkaddr);
75-
break;
76-
default:
77-
DBG_BUGON(1);
78-
return -EOPNOTSUPP;
7969
}
80-
m->type = type;
8170
return 0;
8271
}
8372

0 commit comments

Comments
 (0)