aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-04-01 11:21:32 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:01 -0400
commit63b10fc4874a014e22bc4c64e3d92b71180661fe (patch)
tree683a7b414f269f8b999b666d5f2d6c9fb74a1ee8 /fs/btrfs/ctree.h
parent2d2ae547979854d10b75d557b3abdb3eb7511bbc (diff)
Reorder the flags field in struct btrfs_header and record a flag on writeout
This allows detection of blocks that have already been written in the running transaction so they can be recowed instead of modified again. It is step one in trusting the transid field of the block pointers. Signed-off-by: Chris Mason <chris.mason@oracle.com>
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);