summaryrefslogtreecommitdiff
path: root/ctree.h
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-04-18 16:15:47 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-04-18 16:15:47 -0400
commit8c973943bb862d466967f28d87e23b889ea5693f (patch)
tree2863b79886821ad5299b7a89b6f4d97287a38775 /ctree.h
parent8d1d13c786b6edca8c8fa3d4f4c8763948f43502 (diff)
key flag reorg
Diffstat (limited to 'ctree.h')
-rw-r--r--ctree.h52
1 files changed, 26 insertions, 26 deletions
diff --git a/ctree.h b/ctree.h
index 64ce3a74..1dca9cb0 100644
--- a/ctree.h
+++ b/ctree.h
@@ -270,11 +270,12 @@ struct btrfs_root {
/* the lower bits in the key flags defines the item type */
#define BTRFS_KEY_TYPE_MAX 256
-#define BTRFS_KEY_TYPE_MASK (BTRFS_KEY_TYPE_MAX - 1)
+#define BTRFS_KEY_TYPE_SHIFT 24
+#define BTRFS_KEY_TYPE_MASK (((u32)BTRFS_KEY_TYPE_MAX - 1) << \
+ BTRFS_KEY_TYPE_SHIFT)
#define BTRFS_KEY_OVERFLOW_MAX 128
-#define BTRFS_KEY_OVERFLOW_SHIFT 8
-#define BTRFS_KEY_OVERFLOW_MASK (0x7FULL << BTRFS_KEY_OVERFLOW_SHIFT)
+#define BTRFS_KEY_OVERFLOW_MASK ((u32)BTRFS_KEY_OVERFLOW_MAX - 1)
/*
* inode items have the data typically returned from stat and store other
@@ -574,56 +575,55 @@ static inline void btrfs_set_disk_key_flags(struct btrfs_disk_key *disk,
disk->flags = cpu_to_le32(val);
}
-static inline u32 btrfs_key_overflow(struct btrfs_key *key)
+static inline u32 btrfs_disk_key_type(struct btrfs_disk_key *key)
{
- u32 over = key->flags & BTRFS_KEY_OVERFLOW_MASK;
- return over >> BTRFS_KEY_OVERFLOW_SHIFT;
+ return le32_to_cpu(key->flags) >> BTRFS_KEY_TYPE_SHIFT;
}
-static inline void btrfs_set_key_overflow(struct btrfs_key *key, u32 over)
+static inline void btrfs_set_disk_key_type(struct btrfs_disk_key *key,
+ u32 val)
{
- BUG_ON(over >= BTRFS_KEY_OVERFLOW_MAX);
- over = over << BTRFS_KEY_OVERFLOW_SHIFT;
- key->flags = (key->flags & ~((u64)BTRFS_KEY_OVERFLOW_MASK)) | over;
+ u32 flags = btrfs_disk_key_flags(key);
+ BUG_ON(val >= BTRFS_KEY_TYPE_MAX);
+ val = val << BTRFS_KEY_TYPE_SHIFT;
+ flags = (flags & ~BTRFS_KEY_TYPE_MASK) | val;
+ btrfs_set_disk_key_flags(key, flags);
}
static inline u32 btrfs_key_type(struct btrfs_key *key)
{
- return key->flags & BTRFS_KEY_TYPE_MASK;
+ return key->flags >> BTRFS_KEY_TYPE_SHIFT;
}
-static inline u32 btrfs_disk_key_type(struct btrfs_disk_key *key)
+static inline void btrfs_set_key_type(struct btrfs_key *key, u32 val)
{
- return le32_to_cpu(key->flags) & BTRFS_KEY_TYPE_MASK;
+ BUG_ON(val >= BTRFS_KEY_TYPE_MAX);
+ val = val << BTRFS_KEY_TYPE_SHIFT;
+ key->flags = (key->flags & ~(BTRFS_KEY_TYPE_MASK)) | val;
}
-static inline void btrfs_set_key_type(struct btrfs_key *key, u32 type)
+static inline u32 btrfs_key_overflow(struct btrfs_key *key)
{
- BUG_ON(type >= BTRFS_KEY_TYPE_MAX);
- key->flags = (key->flags & ~((u64)BTRFS_KEY_TYPE_MASK)) | type;
+ return key->flags & BTRFS_KEY_OVERFLOW_MASK;
}
-static inline void btrfs_set_disk_key_type(struct btrfs_disk_key *key, u32 type)
+static inline void btrfs_set_key_overflow(struct btrfs_key *key, u32 over)
{
- u32 flags = btrfs_disk_key_flags(key);
- BUG_ON(type >= BTRFS_KEY_TYPE_MAX);
- flags = (flags & ~((u64)BTRFS_KEY_TYPE_MASK)) | type;
- btrfs_set_disk_key_flags(key, flags);
+ BUG_ON(over >= BTRFS_KEY_OVERFLOW_MAX);
+ key->flags = (key->flags & ~BTRFS_KEY_OVERFLOW_MASK) | over;
}
static inline u32 btrfs_disk_key_overflow(struct btrfs_disk_key *key)
{
- u32 over = le32_to_cpu(key->flags) & BTRFS_KEY_OVERFLOW_MASK;
- return over >> BTRFS_KEY_OVERFLOW_SHIFT;
+ return le32_to_cpu(key->flags) & BTRFS_KEY_OVERFLOW_MASK;
}
-static inline void btrfs_set_disK_key_overflow(struct btrfs_disk_key *key,
+static inline void btrfs_set_disk_key_overflow(struct btrfs_disk_key *key,
u32 over)
{
u32 flags = btrfs_disk_key_flags(key);
BUG_ON(over >= BTRFS_KEY_OVERFLOW_MAX);
- over = over << BTRFS_KEY_OVERFLOW_SHIFT;
- flags = (flags & ~((u64)BTRFS_KEY_OVERFLOW_MASK)) | over;
+ flags = (flags & ~BTRFS_KEY_OVERFLOW_MASK) | over;
btrfs_set_disk_key_flags(key, flags);
}