Skip to content

Commit 745ed7d

Browse files
committed
erofs: cleanup i_format-related stuffs
Switch EROFS_I_{VERSION,DATALAYOUT}_BITS into EROFS_I_{VERSION,DATALAYOUT}_MASK. Also avoid erofs_bitrange() since its functionality is simple enough. Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com> Reviewed-by: Chao Yu <chao@kernel.org> Link: https://lore.kernel.org/r/20230414083027.12307-2-hsiangkao@linux.alibaba.com
1 parent 10656f9 commit 745ed7d

2 files changed

Lines changed: 8 additions & 18 deletions

File tree

fs/erofs/erofs_fs.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ static inline bool erofs_inode_is_data_compressed(unsigned int datamode)
109109
}
110110

111111
/* bit definitions of inode i_format */
112-
#define EROFS_I_VERSION_BITS 1
113-
#define EROFS_I_DATALAYOUT_BITS 3
112+
#define EROFS_I_VERSION_MASK 0x01
113+
#define EROFS_I_DATALAYOUT_MASK 0x07
114114

115115
#define EROFS_I_VERSION_BIT 0
116116
#define EROFS_I_DATALAYOUT_BIT 1
117+
#define EROFS_I_ALL_BIT 4
117118

118-
#define EROFS_I_ALL \
119-
((1 << (EROFS_I_DATALAYOUT_BIT + EROFS_I_DATALAYOUT_BITS)) - 1)
119+
#define EROFS_I_ALL ((1 << EROFS_I_ALL_BIT) - 1)
120120

121121
/* indicate chunk blkbits, thus 'chunksize = blocksize << chunk blkbits' */
122122
#define EROFS_CHUNK_FORMAT_BLKBITS_MASK 0x001F

fs/erofs/internal.h

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -343,24 +343,14 @@ static inline erofs_off_t erofs_iloc(struct inode *inode)
343343
(EROFS_I(inode)->nid << sbi->islotbits);
344344
}
345345

346-
static inline unsigned int erofs_bitrange(unsigned int value, unsigned int bit,
347-
unsigned int bits)
346+
static inline unsigned int erofs_inode_version(unsigned int ifmt)
348347
{
349-
350-
return (value >> bit) & ((1 << bits) - 1);
351-
}
352-
353-
354-
static inline unsigned int erofs_inode_version(unsigned int value)
355-
{
356-
return erofs_bitrange(value, EROFS_I_VERSION_BIT,
357-
EROFS_I_VERSION_BITS);
348+
return (ifmt >> EROFS_I_VERSION_BIT) & EROFS_I_VERSION_MASK;
358349
}
359350

360-
static inline unsigned int erofs_inode_datalayout(unsigned int value)
351+
static inline unsigned int erofs_inode_datalayout(unsigned int ifmt)
361352
{
362-
return erofs_bitrange(value, EROFS_I_DATALAYOUT_BIT,
363-
EROFS_I_DATALAYOUT_BITS);
353+
return (ifmt >> EROFS_I_DATALAYOUT_BIT) & EROFS_I_DATALAYOUT_MASK;
364354
}
365355

366356
/*

0 commit comments

Comments
 (0)