erofs: clean up z_erofs_load_full_lcluster()
PATCH 1/1 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]>
---
Some random cleanup out of the upcoming big lclusters..
fs/erofs/erofs_fs.h | 5 +---- fs/erofs/zmap.c | 21 +++++---------------- 2 files changed, 6 insertions(+), 20 deletions(-)
fs/erofs/erofs_fs.h +1 -4
@@ -406,8 +406,7 @@ enum { Z_EROFS_LCLUSTER_TYPE_MAX }; -#define Z_EROFS_LI_LCLUSTER_TYPE_BITS 2 -#define Z_EROFS_LI_LCLUSTER_TYPE_BIT 0 +#define Z_EROFS_LI_LCLUSTER_TYPE_MASK (Z_EROFS_LCLUSTER_TYPE_MAX - 1)/* (noncompact only, HEAD) This pcluster refers to partial decompressed data */ #define Z_EROFS_LI_PARTIAL_REF (1 << 15)
@@ -461,8 +460,6 @@ static inline void erofs_check_ondisk_layout_definitions(void) sizeof(struct z_erofs_lcluster_index));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 */ BUILD_BUG_ON (__builtin_constant_p (fmh) ? fmh !=cpu_to_le64 (1ULL <<63 ) :0 );
fs/erofs/zmap.c +5 -16
@@ -31,7 +31,7 @@ static int z_erofs_load_full_lcluster(struct z_erofs_maprecorder *m, vi->inode_isize + vi->xattr_isize) + lcn *sizeof (struct z_erofs_lcluster_index );struct z_erofs_lcluster_index *di; -unsigned int advise, type; +unsigned int advise; m->kaddr =erofs_read_metabuf (&m->map->buf, inode->i_sb,erofs_blknr (inode->i_sb, pos),EROFS_KMAP );
@@ -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); advise =le16_to_cpu (di->di_advise); - type = (advise >>Z_EROFS_LI_LCLUSTER_TYPE_BIT ) & - ((1 <<Z_EROFS_LI_LCLUSTER_TYPE_BITS ) -1 ); -switch (type) { -case Z_EROFS_LCLUSTER_TYPE_NONHEAD : + m->type = advise &Z_EROFS_LI_LCLUSTER_TYPE_MASK ; +if (m->type ==Z_EROFS_LCLUSTER_TYPE_NONHEAD ) { m->clusterofs =1 << vi->z_logical_clusterbits; m->delta[0 ] =le16_to_cpu (di->di_u.delta[0 ]);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, m->delta[0 ] =1 ; } m->delta[1 ] =le16_to_cpu (di->di_u.delta[1 ]); -break ; -case Z_EROFS_LCLUSTER_TYPE_PLAIN : -case Z_EROFS_LCLUSTER_TYPE_HEAD1 : -case Z_EROFS_LCLUSTER_TYPE_HEAD2 : -if (advise &Z_EROFS_LI_PARTIAL_REF ) - m->partialref = true; + }else { + m->partialref = !!(advise &Z_EROFS_LI_PARTIAL_REF ); m->clusterofs =le16_to_cpu (di->di_clusterofs);if (m->clusterofs >=1 << vi->z_logical_clusterbits) {DBG_BUGON (1 );return -EFSCORRUPTED ; } m->pblk =le32_to_cpu (di->di_u.blkaddr); -break ; -default : -DBG_BUGON (1 ); -return -EOPNOTSUPP ; } - m->type = type;return 0 ; }
Signature · 1 line
2.39.3