summaryrefslogtreecommitdiffstats
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)
downloadop-kernel-dev-63b10fc4874a014e22bc4c64e3d92b71180661fe.zip
op-kernel-dev-63b10fc4874a014e22bc4c64e3d92b71180661fe.tar.gz
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 fec96ba..67d533c 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)
}
#define BTRFS_FSID_SIZE 16
+#define BTRFS_HEADER_FLAG_WRITTEN (1 << 0)
+
/*
* every tree block (leaf or node) starts with this header.
*/
@@ -200,10 +202,10 @@ struct btrfs_header {
u8 csum[BTRFS_CSUM_SIZE];
u8 fsid[BTRFS_FSID_SIZE]; /* FS specific uuid */
__le64 bytenr; /* which block this node is supposed to live in */
+ __le64 flags;
__le64 generation;
__le64 owner;
__le32 nritems;
- __le16 flags;
u8 level;
} __attribute__ ((__packed__));
@@ -229,9 +231,10 @@ struct btrfs_header {
*/
struct btrfs_super_block {
u8 csum[BTRFS_CSUM_SIZE];
- /* the first 3 fields must match struct btrfs_header */
+ /* the first 4 fields must match struct btrfs_header */
u8 fsid[16]; /* FS specific uuid */
__le64 bytenr; /* this block number */
+ __le64 flags;
__le64 magic;
__le64 generation;
__le64 root;
@@ -1045,9 +1048,28 @@ BTRFS_SETGET_HEADER_FUNCS(header_generation, struct btrfs_header,
generation, 64);
BTRFS_SETGET_HEADER_FUNCS(header_owner, struct btrfs_header, owner, 64);
BTRFS_SETGET_HEADER_FUNCS(header_nritems, struct btrfs_header, nritems, 32);
-BTRFS_SETGET_HEADER_FUNCS(header_flags, struct btrfs_header, flags, 16);
+BTRFS_SETGET_HEADER_FUNCS(header_flags, struct btrfs_header, flags, 64);
BTRFS_SETGET_HEADER_FUNCS(header_level, struct btrfs_header, level, 8);
+static inline int btrfs_header_flag(struct extent_buffer *eb, u64 flag)
+{
+ return (btrfs_header_flags(eb) & flag) == flag;
+}
+
+static inline int btrfs_set_header_flag(struct extent_buffer *eb, u64 flag)
+{
+ u64 flags = btrfs_header_flags(eb);
+ btrfs_set_header_flags(eb, flags | flag);
+ return (flags & flag) == flag;
+}
+
+static inline int btrfs_clear_header_flag(struct extent_buffer *eb, u64 flag)
+{
+ u64 flags = btrfs_header_flags(eb);
+ btrfs_set_header_flags(eb, flags & ~flag);
+ return (flags & flag) == flag;
+}
+
static inline u8 *btrfs_header_fsid(struct extent_buffer *eb)
{
unsigned long ptr = offsetof(struct btrfs_header, fsid);
OpenPOWER on IntegriCloud