summaryrefslogtreecommitdiffstats
path: root/fs/erofs/internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/erofs/internal.h')
-rw-r--r--fs/erofs/internal.h31
1 files changed, 15 insertions, 16 deletions
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 7ff36f404ec3..0f5cbf0a7570 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -285,7 +285,7 @@ struct erofs_vnode {
285 /* atomic flags (including bitlocks) */ 285 /* atomic flags (including bitlocks) */
286 unsigned long flags; 286 unsigned long flags;
287 287
288 unsigned char datamode; 288 unsigned char datalayout;
289 unsigned char inode_isize; 289 unsigned char inode_isize;
290 unsigned short xattr_isize; 290 unsigned short xattr_isize;
291 291
@@ -310,31 +310,30 @@ struct erofs_vnode {
310#define EROFS_V(ptr) \ 310#define EROFS_V(ptr) \
311 container_of(ptr, struct erofs_vnode, vfs_inode) 311 container_of(ptr, struct erofs_vnode, vfs_inode)
312 312
313#define __inode_advise(x, bit, bits) \
314 (((x) >> (bit)) & ((1 << (bits)) - 1))
315
316#define __inode_version(advise) \
317 __inode_advise(advise, EROFS_I_VERSION_BIT, \
318 EROFS_I_VERSION_BITS)
319
320#define __inode_data_mapping(advise) \
321 __inode_advise(advise, EROFS_I_DATA_MAPPING_BIT,\
322 EROFS_I_DATA_MAPPING_BITS)
323
324static inline unsigned long inode_datablocks(struct inode *inode) 313static inline unsigned long inode_datablocks(struct inode *inode)
325{ 314{
326 /* since i_size cannot be changed */ 315 /* since i_size cannot be changed */
327 return DIV_ROUND_UP(inode->i_size, EROFS_BLKSIZ); 316 return DIV_ROUND_UP(inode->i_size, EROFS_BLKSIZ);
328} 317}
329 318
330static inline bool is_inode_layout_compression(struct inode *inode) 319static inline unsigned int erofs_bitrange(unsigned int value, unsigned int bit,
320 unsigned int bits)
321{
322
323 return (value >> bit) & ((1 << bits) - 1);
324}
325
326
327static inline unsigned int erofs_inode_version(unsigned int value)
331{ 328{
332 return erofs_inode_is_data_compressed(EROFS_V(inode)->datamode); 329 return erofs_bitrange(value, EROFS_I_VERSION_BIT,
330 EROFS_I_VERSION_BITS);
333} 331}
334 332
335static inline bool is_inode_flat_inline(struct inode *inode) 333static inline unsigned int erofs_inode_datalayout(unsigned int value)
336{ 334{
337 return EROFS_V(inode)->datamode == EROFS_INODE_FLAT_INLINE; 335 return erofs_bitrange(value, EROFS_I_DATALAYOUT_BIT,
336 EROFS_I_DATALAYOUT_BITS);
338} 337}
339 338
340extern const struct super_operations erofs_sops; 339extern const struct super_operations erofs_sops;