Skip to content

Commit b36425d

Browse files
author
Kent Overstreet
committed
bcachefs: inode_format.h
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 82de620 commit b36425d

File tree

2 files changed

+167
-164
lines changed

2 files changed

+167
-164
lines changed

fs/bcachefs/bcachefs_format.h

Lines changed: 1 addition & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -710,170 +710,6 @@ struct bch_reservation {
710710
#define BKEY_BTREE_PTR_U64s_MAX \
711711
(BKEY_U64s + BKEY_BTREE_PTR_VAL_U64s_MAX)
712712

713-
/* Inodes */
714-
715-
#define BLOCKDEV_INODE_MAX 4096
716-
717-
#define BCACHEFS_ROOT_INO 4096
718-
719-
struct bch_inode {
720-
struct bch_val v;
721-
722-
__le64 bi_hash_seed;
723-
__le32 bi_flags;
724-
__le16 bi_mode;
725-
__u8 fields[];
726-
} __packed __aligned(8);
727-
728-
struct bch_inode_v2 {
729-
struct bch_val v;
730-
731-
__le64 bi_journal_seq;
732-
__le64 bi_hash_seed;
733-
__le64 bi_flags;
734-
__le16 bi_mode;
735-
__u8 fields[];
736-
} __packed __aligned(8);
737-
738-
struct bch_inode_v3 {
739-
struct bch_val v;
740-
741-
__le64 bi_journal_seq;
742-
__le64 bi_hash_seed;
743-
__le64 bi_flags;
744-
__le64 bi_sectors;
745-
__le64 bi_size;
746-
__le64 bi_version;
747-
__u8 fields[];
748-
} __packed __aligned(8);
749-
750-
#define INODEv3_FIELDS_START_INITIAL 6
751-
#define INODEv3_FIELDS_START_CUR (offsetof(struct bch_inode_v3, fields) / sizeof(__u64))
752-
753-
struct bch_inode_generation {
754-
struct bch_val v;
755-
756-
__le32 bi_generation;
757-
__le32 pad;
758-
} __packed __aligned(8);
759-
760-
/*
761-
* bi_subvol and bi_parent_subvol are only set for subvolume roots:
762-
*/
763-
764-
#define BCH_INODE_FIELDS_v2() \
765-
x(bi_atime, 96) \
766-
x(bi_ctime, 96) \
767-
x(bi_mtime, 96) \
768-
x(bi_otime, 96) \
769-
x(bi_size, 64) \
770-
x(bi_sectors, 64) \
771-
x(bi_uid, 32) \
772-
x(bi_gid, 32) \
773-
x(bi_nlink, 32) \
774-
x(bi_generation, 32) \
775-
x(bi_dev, 32) \
776-
x(bi_data_checksum, 8) \
777-
x(bi_compression, 8) \
778-
x(bi_project, 32) \
779-
x(bi_background_compression, 8) \
780-
x(bi_data_replicas, 8) \
781-
x(bi_promote_target, 16) \
782-
x(bi_foreground_target, 16) \
783-
x(bi_background_target, 16) \
784-
x(bi_erasure_code, 16) \
785-
x(bi_fields_set, 16) \
786-
x(bi_dir, 64) \
787-
x(bi_dir_offset, 64) \
788-
x(bi_subvol, 32) \
789-
x(bi_parent_subvol, 32)
790-
791-
#define BCH_INODE_FIELDS_v3() \
792-
x(bi_atime, 96) \
793-
x(bi_ctime, 96) \
794-
x(bi_mtime, 96) \
795-
x(bi_otime, 96) \
796-
x(bi_uid, 32) \
797-
x(bi_gid, 32) \
798-
x(bi_nlink, 32) \
799-
x(bi_generation, 32) \
800-
x(bi_dev, 32) \
801-
x(bi_data_checksum, 8) \
802-
x(bi_compression, 8) \
803-
x(bi_project, 32) \
804-
x(bi_background_compression, 8) \
805-
x(bi_data_replicas, 8) \
806-
x(bi_promote_target, 16) \
807-
x(bi_foreground_target, 16) \
808-
x(bi_background_target, 16) \
809-
x(bi_erasure_code, 16) \
810-
x(bi_fields_set, 16) \
811-
x(bi_dir, 64) \
812-
x(bi_dir_offset, 64) \
813-
x(bi_subvol, 32) \
814-
x(bi_parent_subvol, 32) \
815-
x(bi_nocow, 8)
816-
817-
/* subset of BCH_INODE_FIELDS */
818-
#define BCH_INODE_OPTS() \
819-
x(data_checksum, 8) \
820-
x(compression, 8) \
821-
x(project, 32) \
822-
x(background_compression, 8) \
823-
x(data_replicas, 8) \
824-
x(promote_target, 16) \
825-
x(foreground_target, 16) \
826-
x(background_target, 16) \
827-
x(erasure_code, 16) \
828-
x(nocow, 8)
829-
830-
enum inode_opt_id {
831-
#define x(name, ...) \
832-
Inode_opt_##name,
833-
BCH_INODE_OPTS()
834-
#undef x
835-
Inode_opt_nr,
836-
};
837-
838-
#define BCH_INODE_FLAGS() \
839-
x(sync, 0) \
840-
x(immutable, 1) \
841-
x(append, 2) \
842-
x(nodump, 3) \
843-
x(noatime, 4) \
844-
x(i_size_dirty, 5) \
845-
x(i_sectors_dirty, 6) \
846-
x(unlinked, 7) \
847-
x(backptr_untrusted, 8)
848-
849-
/* bits 20+ reserved for packed fields below: */
850-
851-
enum bch_inode_flags {
852-
#define x(t, n) BCH_INODE_##t = 1U << n,
853-
BCH_INODE_FLAGS()
854-
#undef x
855-
};
856-
857-
enum __bch_inode_flags {
858-
#define x(t, n) __BCH_INODE_##t = n,
859-
BCH_INODE_FLAGS()
860-
#undef x
861-
};
862-
863-
LE32_BITMASK(INODE_STR_HASH, struct bch_inode, bi_flags, 20, 24);
864-
LE32_BITMASK(INODE_NR_FIELDS, struct bch_inode, bi_flags, 24, 31);
865-
LE32_BITMASK(INODE_NEW_VARINT, struct bch_inode, bi_flags, 31, 32);
866-
867-
LE64_BITMASK(INODEv2_STR_HASH, struct bch_inode_v2, bi_flags, 20, 24);
868-
LE64_BITMASK(INODEv2_NR_FIELDS, struct bch_inode_v2, bi_flags, 24, 31);
869-
870-
LE64_BITMASK(INODEv3_STR_HASH, struct bch_inode_v3, bi_flags, 20, 24);
871-
LE64_BITMASK(INODEv3_NR_FIELDS, struct bch_inode_v3, bi_flags, 24, 31);
872-
873-
LE64_BITMASK(INODEv3_FIELDS_START,
874-
struct bch_inode_v3, bi_flags, 31, 36);
875-
LE64_BITMASK(INODEv3_MODE, struct bch_inode_v3, bi_flags, 36, 52);
876-
877713
/* Dirents */
878714

879715
/*
@@ -1209,6 +1045,7 @@ struct bch_sb_field {
12091045
x(ext, 13) \
12101046
x(downgrade, 14)
12111047

1048+
#include "inode_format.h"
12121049
#include "quota_format.h"
12131050
#include "sb-counters_format.h"
12141051

fs/bcachefs/inode_format.h

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _BCACHEFS_INODE_FORMAT_H
3+
#define _BCACHEFS_INODE_FORMAT_H
4+
5+
#define BLOCKDEV_INODE_MAX 4096
6+
#define BCACHEFS_ROOT_INO 4096
7+
8+
struct bch_inode {
9+
struct bch_val v;
10+
11+
__le64 bi_hash_seed;
12+
__le32 bi_flags;
13+
__le16 bi_mode;
14+
__u8 fields[];
15+
} __packed __aligned(8);
16+
17+
struct bch_inode_v2 {
18+
struct bch_val v;
19+
20+
__le64 bi_journal_seq;
21+
__le64 bi_hash_seed;
22+
__le64 bi_flags;
23+
__le16 bi_mode;
24+
__u8 fields[];
25+
} __packed __aligned(8);
26+
27+
struct bch_inode_v3 {
28+
struct bch_val v;
29+
30+
__le64 bi_journal_seq;
31+
__le64 bi_hash_seed;
32+
__le64 bi_flags;
33+
__le64 bi_sectors;
34+
__le64 bi_size;
35+
__le64 bi_version;
36+
__u8 fields[];
37+
} __packed __aligned(8);
38+
39+
#define INODEv3_FIELDS_START_INITIAL 6
40+
#define INODEv3_FIELDS_START_CUR (offsetof(struct bch_inode_v3, fields) / sizeof(__u64))
41+
42+
struct bch_inode_generation {
43+
struct bch_val v;
44+
45+
__le32 bi_generation;
46+
__le32 pad;
47+
} __packed __aligned(8);
48+
49+
/*
50+
* bi_subvol and bi_parent_subvol are only set for subvolume roots:
51+
*/
52+
53+
#define BCH_INODE_FIELDS_v2() \
54+
x(bi_atime, 96) \
55+
x(bi_ctime, 96) \
56+
x(bi_mtime, 96) \
57+
x(bi_otime, 96) \
58+
x(bi_size, 64) \
59+
x(bi_sectors, 64) \
60+
x(bi_uid, 32) \
61+
x(bi_gid, 32) \
62+
x(bi_nlink, 32) \
63+
x(bi_generation, 32) \
64+
x(bi_dev, 32) \
65+
x(bi_data_checksum, 8) \
66+
x(bi_compression, 8) \
67+
x(bi_project, 32) \
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) \
75+
x(bi_dir, 64) \
76+
x(bi_dir_offset, 64) \
77+
x(bi_subvol, 32) \
78+
x(bi_parent_subvol, 32)
79+
80+
#define BCH_INODE_FIELDS_v3() \
81+
x(bi_atime, 96) \
82+
x(bi_ctime, 96) \
83+
x(bi_mtime, 96) \
84+
x(bi_otime, 96) \
85+
x(bi_uid, 32) \
86+
x(bi_gid, 32) \
87+
x(bi_nlink, 32) \
88+
x(bi_generation, 32) \
89+
x(bi_dev, 32) \
90+
x(bi_data_checksum, 8) \
91+
x(bi_compression, 8) \
92+
x(bi_project, 32) \
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) \
100+
x(bi_dir, 64) \
101+
x(bi_dir_offset, 64) \
102+
x(bi_subvol, 32) \
103+
x(bi_parent_subvol, 32) \
104+
x(bi_nocow, 8)
105+
106+
/* subset of BCH_INODE_FIELDS */
107+
#define BCH_INODE_OPTS() \
108+
x(data_checksum, 8) \
109+
x(compression, 8) \
110+
x(project, 32) \
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) \
117+
x(nocow, 8)
118+
119+
enum inode_opt_id {
120+
#define x(name, ...) \
121+
Inode_opt_##name,
122+
BCH_INODE_OPTS()
123+
#undef x
124+
Inode_opt_nr,
125+
};
126+
127+
#define BCH_INODE_FLAGS() \
128+
x(sync, 0) \
129+
x(immutable, 1) \
130+
x(append, 2) \
131+
x(nodump, 3) \
132+
x(noatime, 4) \
133+
x(i_size_dirty, 5) \
134+
x(i_sectors_dirty, 6) \
135+
x(unlinked, 7) \
136+
x(backptr_untrusted, 8)
137+
138+
/* bits 20+ reserved for packed fields below: */
139+
140+
enum bch_inode_flags {
141+
#define x(t, n) BCH_INODE_##t = 1U << n,
142+
BCH_INODE_FLAGS()
143+
#undef x
144+
};
145+
146+
enum __bch_inode_flags {
147+
#define x(t, n) __BCH_INODE_##t = n,
148+
BCH_INODE_FLAGS()
149+
#undef x
150+
};
151+
152+
LE32_BITMASK(INODE_STR_HASH, struct bch_inode, bi_flags, 20, 24);
153+
LE32_BITMASK(INODE_NR_FIELDS, struct bch_inode, bi_flags, 24, 31);
154+
LE32_BITMASK(INODE_NEW_VARINT, struct bch_inode, bi_flags, 31, 32);
155+
156+
LE64_BITMASK(INODEv2_STR_HASH, struct bch_inode_v2, bi_flags, 20, 24);
157+
LE64_BITMASK(INODEv2_NR_FIELDS, struct bch_inode_v2, bi_flags, 24, 31);
158+
159+
LE64_BITMASK(INODEv3_STR_HASH, struct bch_inode_v3, bi_flags, 20, 24);
160+
LE64_BITMASK(INODEv3_NR_FIELDS, struct bch_inode_v3, bi_flags, 24, 31);
161+
162+
LE64_BITMASK(INODEv3_FIELDS_START,
163+
struct bch_inode_v3, bi_flags, 31, 36);
164+
LE64_BITMASK(INODEv3_MODE, struct bch_inode_v3, bi_flags, 36, 52);
165+
166+
#endif /* _BCACHEFS_INODE_FORMAT_H */

0 commit comments

Comments
 (0)