summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-04-18 16:15:28 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-04-18 16:15:28 -0400
commita429e51371eee3c989160c003ee40bc3947c6a76 (patch)
tree863b55de8823be579264260a51407cd90aac103d /fs/btrfs/ctree.h
parent70b2befd0c8a4064715d8b340270650cc9d15af8 (diff)
downloadop-kernel-dev-a429e51371eee3c989160c003ee40bc3947c6a76.zip
op-kernel-dev-a429e51371eee3c989160c003ee40bc3947c6a76.tar.gz
Btrfs: working file_write, reorganized key flags
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h52
1 files changed, 26 insertions, 26 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index d75a4d5..8a329d3 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -282,11 +282,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
@@ -586,56 +587,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);
}
OpenPOWER on IntegriCloud