summaryrefslogtreecommitdiff
path: root/ctree.h
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-04-01 10:20:06 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2008-04-01 10:20:06 -0400
commitad67cd73b7c1ab043f0c27570750f6d2becd7f03 (patch)
tree6c1e0daf85186558d8f24f868a9fe19bda44d863 /ctree.h
parente9e3422f85877e813e9217f5dc8eb189f0643d65 (diff)
Update struct btrfs_header flags, and use it to indicate buffers are written
Diffstat (limited to 'ctree.h')
-rw-r--r--ctree.h26
1 files changed, 24 insertions, 2 deletions
diff --git a/ctree.h b/ctree.h
index 80397fb6..1e4c84a1 100644
--- a/ctree.h
+++ b/ctree.h
@@ -182,6 +182,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.
*/
@@ -189,10 +191,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__));
@@ -220,6 +222,7 @@ struct btrfs_super_block {
/* the first 3 fields must match struct btrfs_header */
u8 fsid[BTRFS_FSID_SIZE]; /* FS specific uuid */
__le64 bytenr; /* this block number */
+ __le64 flags;
__le64 magic;
__le64 generation;
__le64 root;
@@ -1027,9 +1030,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);