Btrfs: Add sparse endian annotations to struct header
rename struct header to btrfs_header Signed-off-by: Chris Mason <chris.mason@oracle.com>
This commit is contained in:
committed by
David Woodhouse
parent
7518a238ea
commit
bb492bb0a5
@@ -24,19 +24,19 @@ struct key {
|
|||||||
/*
|
/*
|
||||||
* every tree block (leaf or node) starts with this header.
|
* every tree block (leaf or node) starts with this header.
|
||||||
*/
|
*/
|
||||||
struct header {
|
struct btrfs_header {
|
||||||
u64 fsid[2]; /* FS specific uuid */
|
__le64 fsid[2]; /* FS specific uuid */
|
||||||
u64 blocknr; /* which block this node is supposed to live in */
|
__le64 blocknr; /* which block this node is supposed to live in */
|
||||||
u64 parentid; /* objectid of the tree root */
|
__le64 parentid; /* objectid of the tree root */
|
||||||
u32 csum;
|
__le32 csum;
|
||||||
u32 ham;
|
__le32 ham;
|
||||||
u16 nritems;
|
__le16 nritems;
|
||||||
u16 flags;
|
__le16 flags;
|
||||||
/* generation flags to be added */
|
/* generation flags to be added */
|
||||||
} __attribute__ ((__packed__));
|
} __attribute__ ((__packed__));
|
||||||
|
|
||||||
#define MAX_LEVEL 8
|
#define MAX_LEVEL 8
|
||||||
#define NODEPTRS_PER_BLOCK ((CTREE_BLOCKSIZE - sizeof(struct header)) / \
|
#define NODEPTRS_PER_BLOCK ((CTREE_BLOCKSIZE - sizeof(struct btrfs_header)) / \
|
||||||
(sizeof(struct key) + sizeof(u64)))
|
(sizeof(struct key) + sizeof(u64)))
|
||||||
|
|
||||||
struct tree_buffer;
|
struct tree_buffer;
|
||||||
@@ -100,12 +100,12 @@ struct item {
|
|||||||
* The data is separate from the items to get the keys closer together
|
* The data is separate from the items to get the keys closer together
|
||||||
* during searches.
|
* during searches.
|
||||||
*/
|
*/
|
||||||
#define LEAF_DATA_SIZE (CTREE_BLOCKSIZE - sizeof(struct header))
|
#define LEAF_DATA_SIZE (CTREE_BLOCKSIZE - sizeof(struct btrfs_header))
|
||||||
struct leaf {
|
struct leaf {
|
||||||
struct header header;
|
struct btrfs_header header;
|
||||||
union {
|
union {
|
||||||
struct item items[LEAF_DATA_SIZE/sizeof(struct item)];
|
struct item items[LEAF_DATA_SIZE/sizeof(struct item)];
|
||||||
u8 data[CTREE_BLOCKSIZE-sizeof(struct header)];
|
u8 data[CTREE_BLOCKSIZE-sizeof(struct btrfs_header)];
|
||||||
};
|
};
|
||||||
} __attribute__ ((__packed__));
|
} __attribute__ ((__packed__));
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ struct leaf {
|
|||||||
* other blocks
|
* other blocks
|
||||||
*/
|
*/
|
||||||
struct node {
|
struct node {
|
||||||
struct header header;
|
struct btrfs_header header;
|
||||||
struct key keys[NODEPTRS_PER_BLOCK];
|
struct key keys[NODEPTRS_PER_BLOCK];
|
||||||
u64 blockptrs[NODEPTRS_PER_BLOCK];
|
u64 blockptrs[NODEPTRS_PER_BLOCK];
|
||||||
} __attribute__ ((__packed__));
|
} __attribute__ ((__packed__));
|
||||||
@@ -141,54 +141,55 @@ struct ctree_path {
|
|||||||
int slots[MAX_LEVEL];
|
int slots[MAX_LEVEL];
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline u64 btrfs_header_blocknr(struct header *h)
|
static inline u64 btrfs_header_blocknr(struct btrfs_header *h)
|
||||||
{
|
{
|
||||||
return h->blocknr;
|
return le64_to_cpu(h->blocknr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void btrfs_set_header_blocknr(struct header *h, u64 blocknr)
|
static inline void btrfs_set_header_blocknr(struct btrfs_header *h, u64 blocknr)
|
||||||
{
|
{
|
||||||
h->blocknr = blocknr;
|
h->blocknr = cpu_to_le64(blocknr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u64 btrfs_header_parentid(struct header *h)
|
static inline u64 btrfs_header_parentid(struct btrfs_header *h)
|
||||||
{
|
{
|
||||||
return h->parentid;
|
return le64_to_cpu(h->parentid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void btrfs_set_header_parentid(struct header *h, u64 parentid)
|
static inline void btrfs_set_header_parentid(struct btrfs_header *h,
|
||||||
|
u64 parentid)
|
||||||
{
|
{
|
||||||
h->parentid = parentid;
|
h->parentid = cpu_to_le64(parentid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32 btrfs_header_nritems(struct header *h)
|
static inline u16 btrfs_header_nritems(struct btrfs_header *h)
|
||||||
{
|
{
|
||||||
return h->nritems;
|
return le16_to_cpu(h->nritems);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void btrfs_set_header_nritems(struct header *h, u32 val)
|
static inline void btrfs_set_header_nritems(struct btrfs_header *h, u16 val)
|
||||||
{
|
{
|
||||||
h->nritems = val;
|
h->nritems = cpu_to_le16(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32 btrfs_header_flags(struct header *h)
|
static inline u16 btrfs_header_flags(struct btrfs_header *h)
|
||||||
{
|
{
|
||||||
return h->flags;
|
return le16_to_cpu(h->flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void btrfs_set_header_flags(struct header *h, u32 val)
|
static inline void btrfs_set_header_flags(struct btrfs_header *h, u16 val)
|
||||||
{
|
{
|
||||||
h->flags = val;
|
h->flags = cpu_to_le16(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int btrfs_header_level(struct header *h)
|
static inline int btrfs_header_level(struct btrfs_header *h)
|
||||||
{
|
{
|
||||||
return btrfs_header_flags(h) & (MAX_LEVEL - 1);
|
return btrfs_header_flags(h) & (MAX_LEVEL - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void btrfs_set_header_level(struct header *h, int level)
|
static inline void btrfs_set_header_level(struct btrfs_header *h, int level)
|
||||||
{
|
{
|
||||||
u32 flags;
|
u16 flags;
|
||||||
BUG_ON(level > MAX_LEVEL);
|
BUG_ON(level > MAX_LEVEL);
|
||||||
flags = btrfs_header_flags(h) & ~(MAX_LEVEL - 1);
|
flags = btrfs_header_flags(h) & ~(MAX_LEVEL - 1);
|
||||||
btrfs_set_header_flags(h, flags | level);
|
btrfs_set_header_flags(h, flags | level);
|
||||||
|
@@ -9,10 +9,16 @@
|
|||||||
#define GFP_KERNEL 0
|
#define GFP_KERNEL 0
|
||||||
#define __read_mostly
|
#define __read_mostly
|
||||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||||
#define __force
|
|
||||||
#define PAGE_SHIFT 12
|
#define PAGE_SHIFT 12
|
||||||
#define ULONG_MAX (~0UL)
|
#define ULONG_MAX (~0UL)
|
||||||
#define BUG() abort()
|
#define BUG() abort()
|
||||||
|
#ifdef __CHECKER__
|
||||||
|
#define __force __attribute__((force))
|
||||||
|
#define __bitwise__ __attribute__((bitwise))
|
||||||
|
#else
|
||||||
|
#define __force
|
||||||
|
#define __bitwise__
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef unsigned int u32;
|
typedef unsigned int u32;
|
||||||
typedef unsigned long long u64;
|
typedef unsigned long long u64;
|
||||||
@@ -67,3 +73,24 @@ static inline void __clear_bit(int bit, unsigned long *map) {
|
|||||||
|
|
||||||
#define ENOMEM 5
|
#define ENOMEM 5
|
||||||
#define EEXIST 6
|
#define EEXIST 6
|
||||||
|
|
||||||
|
#define __CHECK_ENDIAN__
|
||||||
|
#ifdef __CHECK_ENDIAN__
|
||||||
|
#define __bitwise __bitwise__
|
||||||
|
#else
|
||||||
|
#define __bitwise
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef u16 __bitwise __le16;
|
||||||
|
typedef u16 __bitwise __be16;
|
||||||
|
typedef u32 __bitwise __le32;
|
||||||
|
typedef u32 __bitwise __be32;
|
||||||
|
typedef u64 __bitwise __le64;
|
||||||
|
typedef u64 __bitwise __be64;
|
||||||
|
|
||||||
|
#define cpu_to_le64(x) ((__force __le64)(u64)(x))
|
||||||
|
#define le64_to_cpu(x) ((__force u64)(__le64)(x))
|
||||||
|
#define cpu_to_le32(x) ((__force __le32)(u32)(x))
|
||||||
|
#define le32_to_cpu(x) ((__force u32)(__le32)(x))
|
||||||
|
#define cpu_to_le16(x) ((__force __le16)(u16)(x))
|
||||||
|
#define le16_to_cpu(x) ((__force u16)(__le16)(x))
|
||||||
|
Reference in New Issue
Block a user