1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _BCACHEFS_INODE_FORMAT_H
3 #define _BCACHEFS_INODE_FORMAT_H
5 #define BLOCKDEV_INODE_MAX 4096
6 #define BCACHEFS_ROOT_INO 4096
15 } __packed
__aligned(8);
20 __le64 bi_journal_seq
;
25 } __packed
__aligned(8);
30 __le64 bi_journal_seq
;
37 } __packed
__aligned(8);
39 #define INODEv3_FIELDS_START_INITIAL 6
40 #define INODEv3_FIELDS_START_CUR (offsetof(struct bch_inode_v3, fields) / sizeof(__u64))
42 struct bch_inode_generation
{
47 } __packed
__aligned(8);
50 * bi_subvol and bi_parent_subvol are only set for subvolume roots:
53 #define BCH_INODE_FIELDS_v2() \
63 x(bi_generation, 32) \
65 x(bi_data_checksum, 8) \
66 x(bi_compression, 8) \
68 x(bi_background_compression, 8) \
69 x(bi_data_replicas, 8) \
70 x(bi_promote_target, 16) \
71 x(bi_foreground_target, 16) \
72 x(bi_background_target, 16) \
73 x(bi_erasure_code, 16) \
74 x(bi_fields_set, 16) \
76 x(bi_dir_offset, 64) \
78 x(bi_parent_subvol, 32)
80 #define BCH_INODE_FIELDS_v3() \
88 x(bi_generation, 32) \
90 x(bi_data_checksum, 8) \
91 x(bi_compression, 8) \
93 x(bi_background_compression, 8) \
94 x(bi_data_replicas, 8) \
95 x(bi_promote_target, 16) \
96 x(bi_foreground_target, 16) \
97 x(bi_background_target, 16) \
98 x(bi_erasure_code, 16) \
99 x(bi_fields_set, 16) \
101 x(bi_dir_offset, 64) \
103 x(bi_parent_subvol, 32) \
106 /* subset of BCH_INODE_FIELDS */
107 #define BCH_INODE_OPTS() \
108 x(data_checksum, 8) \
111 x(background_compression, 8) \
112 x(data_replicas, 8) \
113 x(promote_target, 16) \
114 x(foreground_target, 16) \
115 x(background_target, 16) \
116 x(erasure_code, 16) \
120 #define x(name, ...) \
127 #define BCH_INODE_FLAGS() \
134 x(i_sectors_dirty, 6) \
136 x(backptr_untrusted, 8) \
137 x(has_child_snapshot, 9)
139 /* bits 20+ reserved for packed fields below: */
141 enum bch_inode_flags
{
142 #define x(t, n) BCH_INODE_##t = 1U << n,
147 enum __bch_inode_flags
{
148 #define x(t, n) __BCH_INODE_##t = n,
153 LE32_BITMASK(INODEv1_STR_HASH
, struct bch_inode
, bi_flags
, 20, 24);
154 LE32_BITMASK(INODEv1_NR_FIELDS
, struct bch_inode
, bi_flags
, 24, 31);
155 LE32_BITMASK(INODEv1_NEW_VARINT
,struct bch_inode
, bi_flags
, 31, 32);
157 LE64_BITMASK(INODEv2_STR_HASH
, struct bch_inode_v2
, bi_flags
, 20, 24);
158 LE64_BITMASK(INODEv2_NR_FIELDS
, struct bch_inode_v2
, bi_flags
, 24, 31);
160 LE64_BITMASK(INODEv3_STR_HASH
, struct bch_inode_v3
, bi_flags
, 20, 24);
161 LE64_BITMASK(INODEv3_NR_FIELDS
, struct bch_inode_v3
, bi_flags
, 24, 31);
163 LE64_BITMASK(INODEv3_FIELDS_START
,
164 struct bch_inode_v3
, bi_flags
, 31, 36);
165 LE64_BITMASK(INODEv3_MODE
, struct bch_inode_v3
, bi_flags
, 36, 52);
167 #endif /* _BCACHEFS_INODE_FORMAT_H */