aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h28
1 files changed, 25 insertions, 3 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index fec96ba7c23b..67d533cf8f47 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -193,6 +193,8 @@ static inline unsigned long btrfs_chunk_item_size(int num_stripes)
193} 193}
194 194
195#define BTRFS_FSID_SIZE 16 195#define BTRFS_FSID_SIZE 16
196#define BTRFS_HEADER_FLAG_WRITTEN (1 << 0)
197
196/* 198/*
197 * every tree block (leaf or node) starts with this header. 199 * every tree block (leaf or node) starts with this header.
198 */ 200 */
@@ -200,10 +202,10 @@ struct btrfs_header {
200 u8 csum[BTRFS_CSUM_SIZE]; 202 u8 csum[BTRFS_CSUM_SIZE];
201 u8 fsid[BTRFS_FSID_SIZE]; /* FS specific uuid */ 203 u8 fsid[BTRFS_FSID_SIZE]; /* FS specific uuid */
202 __le64 bytenr; /* which block this node is supposed to live in */ 204 __le64 bytenr; /* which block this node is supposed to live in */
205 __le64 flags;
203 __le64 generation; 206 __le64 generation;
204 __le64 owner; 207 __le64 owner;
205 __le32 nritems; 208 __le32 nritems;
206 __le16 flags;
207 u8 level; 209 u8 level;
208} __attribute__ ((__packed__)); 210} __attribute__ ((__packed__));
209 211
@@ -229,9 +231,10 @@ struct btrfs_header {
229 */ 231 */
230struct btrfs_super_block { 232struct btrfs_super_block {
231 u8 csum[BTRFS_CSUM_SIZE]; 233 u8 csum[BTRFS_CSUM_SIZE];
232 /* the first 3 fields must match struct btrfs_header */ 234 /* the first 4 fields must match struct btrfs_header */
233 u8 fsid[16]; /* FS specific uuid */ 235 u8 fsid[16]; /* FS specific uuid */
234 __le64 bytenr; /* this block number */ 236 __le64 bytenr; /* this block number */
237 __le64 flags;
235 __le64 magic; 238 __le64 magic;
236 __le64 generation; 239 __le64 generation;
237 __le64 root; 240 __le64 root;
@@ -1045,9 +1048,28 @@ BTRFS_SETGET_HEADER_FUNCS(header_generation, struct btrfs_header,
1045 generation, 64); 1048 generation, 64);
1046BTRFS_SETGET_HEADER_FUNCS(header_owner, struct btrfs_header, owner, 64); 1049BTRFS_SETGET_HEADER_FUNCS(header_owner, struct btrfs_header, owner, 64);
1047BTRFS_SETGET_HEADER_FUNCS(header_nritems, struct btrfs_header, nritems, 32); 1050BTRFS_SETGET_HEADER_FUNCS(header_nritems, struct btrfs_header, nritems, 32);
1048BTRFS_SETGET_HEADER_FUNCS(header_flags, struct btrfs_header, flags, 16); 1051BTRFS_SETGET_HEADER_FUNCS(header_flags, struct btrfs_header, flags, 64);
1049BTRFS_SETGET_HEADER_FUNCS(header_level, struct btrfs_header, level, 8); 1052BTRFS_SETGET_HEADER_FUNCS(header_level, struct btrfs_header, level, 8);
1050 1053
1054static inline int btrfs_header_flag(struct extent_buffer *eb, u64 flag)
1055{
1056 return (btrfs_header_flags(eb) & flag) == flag;
1057}
1058
1059static inline int btrfs_set_header_flag(struct extent_buffer *eb, u64 flag)
1060{
1061 u64 flags = btrfs_header_flags(eb);
1062 btrfs_set_header_flags(eb, flags | flag);
1063 return (flags & flag) == flag;
1064}
1065
1066static inline int btrfs_clear_header_flag(struct extent_buffer *eb, u64 flag)
1067{
1068 u64 flags = btrfs_header_flags(eb);
1069 btrfs_set_header_flags(eb, flags & ~flag);
1070 return (flags & flag) == flag;
1071}
1072
1051static inline u8 *btrfs_header_fsid(struct extent_buffer *eb) 1073static inline u8 *btrfs_header_fsid(struct extent_buffer *eb)
1052{ 1074{
1053 unsigned long ptr = offsetof(struct btrfs_header, fsid); 1075 unsigned long ptr = offsetof(struct btrfs_header, fsid);