*/
struct btrfs_disk_key {
__le64 objectid;
- __le64 offset;
__le32 flags;
+ __le64 offset;
} __attribute__ ((__packed__));
struct btrfs_key {
u64 objectid;
- u64 offset;
u32 flags;
+ u64 offset;
} __attribute__ ((__packed__));
/*
/* 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
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);
}
((type *)(btrfs_leaf_data(leaf) + \
btrfs_item_offset((leaf)->items + (slot))))
-/* extent-item.c */
+/* extent-tree.c */
int btrfs_inc_root_ref(struct btrfs_trans_handle *trans,
struct btrfs_root *root);
struct buffer_head *btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
*root, u64 blocknr, u64 num_blocks, int pin);
int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans, struct
btrfs_root *root);
+int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root,
+ u64 blocknr, u64 num_blocks);
/* ctree.c */
+int btrfs_extend_item(struct btrfs_trans_handle *trans, struct btrfs_root
+ *root, struct btrfs_path *path, u32 data_size);
+int btrfs_truncate_item(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root,
+ struct btrfs_path *path,
+ u32 new_size);
int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root
*root, struct btrfs_key *key, struct btrfs_path *p, int
ins_len, int cow);
struct btrfs_key *location, int mod);
/* file-item.c */
-int btrfs_alloc_file_extent(struct btrfs_trans_handle *trans,
+int btrfs_insert_file_extent(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
- u64 objectid, u64 offset,
- u64 num_blocks, u64 hint_block,
- u64 *result);
+ u64 objectid, u64 pos, u64 offset,
+ u64 num_blocks);
int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
struct btrfs_path *path, u64 objectid,
int btrfs_csum_verify_file_block(struct btrfs_root *root,
u64 objectid, u64 offset,
char *data, size_t len);
+struct btrfs_csum_item *btrfs_lookup_csum(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root,
+ struct btrfs_path *path,
+ u64 objectid, u64 offset,
+ int cow);
/* super.c */
extern struct subsystem btrfs_subsys;