Commit 844f8da7 authored by Jeff Mahoney's avatar Jeff Mahoney Committed by Stefan Bader

btrfs: struct-funcs, constify readers

BugLink: https://bugs.launchpad.net/bugs/1818237

commit 1cbb1f45 upstream.

We have reader helpers for most of the on-disk structures that use
an extent_buffer and pointer as offset into the buffer that are
read-only.  We should mark them as const and, in turn, allow consumers
of these interfaces to mark the buffers const as well.

No impact on code, but serves as documentation that a buffer is intended
not to be modified.
Signed-off-by: default avatarJeff Mahoney <jeffm@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent 3e09c643
...@@ -2283,7 +2283,7 @@ do { \ ...@@ -2283,7 +2283,7 @@ do { \
#define BTRFS_INODE_ROOT_ITEM_INIT (1 << 31) #define BTRFS_INODE_ROOT_ITEM_INIT (1 << 31)
struct btrfs_map_token { struct btrfs_map_token {
struct extent_buffer *eb; const struct extent_buffer *eb;
char *kaddr; char *kaddr;
unsigned long offset; unsigned long offset;
}; };
...@@ -2314,18 +2314,19 @@ static inline void btrfs_init_map_token (struct btrfs_map_token *token) ...@@ -2314,18 +2314,19 @@ static inline void btrfs_init_map_token (struct btrfs_map_token *token)
sizeof(((type *)0)->member))) sizeof(((type *)0)->member)))
#define DECLARE_BTRFS_SETGET_BITS(bits) \ #define DECLARE_BTRFS_SETGET_BITS(bits) \
u##bits btrfs_get_token_##bits(struct extent_buffer *eb, void *ptr, \ u##bits btrfs_get_token_##bits(const struct extent_buffer *eb, \
unsigned long off, \ const void *ptr, unsigned long off, \
struct btrfs_map_token *token); \ struct btrfs_map_token *token); \
void btrfs_set_token_##bits(struct extent_buffer *eb, void *ptr, \ void btrfs_set_token_##bits(struct extent_buffer *eb, const void *ptr, \
unsigned long off, u##bits val, \ unsigned long off, u##bits val, \
struct btrfs_map_token *token); \ struct btrfs_map_token *token); \
static inline u##bits btrfs_get_##bits(struct extent_buffer *eb, void *ptr, \ static inline u##bits btrfs_get_##bits(const struct extent_buffer *eb, \
const void *ptr, \
unsigned long off) \ unsigned long off) \
{ \ { \
return btrfs_get_token_##bits(eb, ptr, off, NULL); \ return btrfs_get_token_##bits(eb, ptr, off, NULL); \
} \ } \
static inline void btrfs_set_##bits(struct extent_buffer *eb, void *ptr, \ static inline void btrfs_set_##bits(struct extent_buffer *eb, void *ptr,\
unsigned long off, u##bits val) \ unsigned long off, u##bits val) \
{ \ { \
btrfs_set_token_##bits(eb, ptr, off, val, NULL); \ btrfs_set_token_##bits(eb, ptr, off, val, NULL); \
...@@ -2337,7 +2338,8 @@ DECLARE_BTRFS_SETGET_BITS(32) ...@@ -2337,7 +2338,8 @@ DECLARE_BTRFS_SETGET_BITS(32)
DECLARE_BTRFS_SETGET_BITS(64) DECLARE_BTRFS_SETGET_BITS(64)
#define BTRFS_SETGET_FUNCS(name, type, member, bits) \ #define BTRFS_SETGET_FUNCS(name, type, member, bits) \
static inline u##bits btrfs_##name(struct extent_buffer *eb, type *s) \ static inline u##bits btrfs_##name(const struct extent_buffer *eb, \
const type *s) \
{ \ { \
BUILD_BUG_ON(sizeof(u##bits) != sizeof(((type *)0))->member); \ BUILD_BUG_ON(sizeof(u##bits) != sizeof(((type *)0))->member); \
return btrfs_get_##bits(eb, s, offsetof(type, member)); \ return btrfs_get_##bits(eb, s, offsetof(type, member)); \
...@@ -2348,7 +2350,8 @@ static inline void btrfs_set_##name(struct extent_buffer *eb, type *s, \ ...@@ -2348,7 +2350,8 @@ static inline void btrfs_set_##name(struct extent_buffer *eb, type *s, \
BUILD_BUG_ON(sizeof(u##bits) != sizeof(((type *)0))->member); \ BUILD_BUG_ON(sizeof(u##bits) != sizeof(((type *)0))->member); \
btrfs_set_##bits(eb, s, offsetof(type, member), val); \ btrfs_set_##bits(eb, s, offsetof(type, member), val); \
} \ } \
static inline u##bits btrfs_token_##name(struct extent_buffer *eb, type *s, \ static inline u##bits btrfs_token_##name(const struct extent_buffer *eb,\
const type *s, \
struct btrfs_map_token *token) \ struct btrfs_map_token *token) \
{ \ { \
BUILD_BUG_ON(sizeof(u##bits) != sizeof(((type *)0))->member); \ BUILD_BUG_ON(sizeof(u##bits) != sizeof(((type *)0))->member); \
...@@ -2363,9 +2366,9 @@ static inline void btrfs_set_token_##name(struct extent_buffer *eb, \ ...@@ -2363,9 +2366,9 @@ static inline void btrfs_set_token_##name(struct extent_buffer *eb, \
} }
#define BTRFS_SETGET_HEADER_FUNCS(name, type, member, bits) \ #define BTRFS_SETGET_HEADER_FUNCS(name, type, member, bits) \
static inline u##bits btrfs_##name(struct extent_buffer *eb) \ static inline u##bits btrfs_##name(const struct extent_buffer *eb) \
{ \ { \
type *p = page_address(eb->pages[0]); \ const type *p = page_address(eb->pages[0]); \
u##bits res = le##bits##_to_cpu(p->member); \ u##bits res = le##bits##_to_cpu(p->member); \
return res; \ return res; \
} \ } \
...@@ -2377,7 +2380,7 @@ static inline void btrfs_set_##name(struct extent_buffer *eb, \ ...@@ -2377,7 +2380,7 @@ static inline void btrfs_set_##name(struct extent_buffer *eb, \
} }
#define BTRFS_SETGET_STACK_FUNCS(name, type, member, bits) \ #define BTRFS_SETGET_STACK_FUNCS(name, type, member, bits) \
static inline u##bits btrfs_##name(type *s) \ static inline u##bits btrfs_##name(const type *s) \
{ \ { \
return le##bits##_to_cpu(s->member); \ return le##bits##_to_cpu(s->member); \
} \ } \
...@@ -2678,7 +2681,7 @@ static inline unsigned long btrfs_node_key_ptr_offset(int nr) ...@@ -2678,7 +2681,7 @@ static inline unsigned long btrfs_node_key_ptr_offset(int nr)
sizeof(struct btrfs_key_ptr) * nr; sizeof(struct btrfs_key_ptr) * nr;
} }
void btrfs_node_key(struct extent_buffer *eb, void btrfs_node_key(const struct extent_buffer *eb,
struct btrfs_disk_key *disk_key, int nr); struct btrfs_disk_key *disk_key, int nr);
static inline void btrfs_set_node_key(struct extent_buffer *eb, static inline void btrfs_set_node_key(struct extent_buffer *eb,
...@@ -2707,28 +2710,28 @@ static inline struct btrfs_item *btrfs_item_nr(int nr) ...@@ -2707,28 +2710,28 @@ static inline struct btrfs_item *btrfs_item_nr(int nr)
return (struct btrfs_item *)btrfs_item_nr_offset(nr); return (struct btrfs_item *)btrfs_item_nr_offset(nr);
} }
static inline u32 btrfs_item_end(struct extent_buffer *eb, static inline u32 btrfs_item_end(const struct extent_buffer *eb,
struct btrfs_item *item) struct btrfs_item *item)
{ {
return btrfs_item_offset(eb, item) + btrfs_item_size(eb, item); return btrfs_item_offset(eb, item) + btrfs_item_size(eb, item);
} }
static inline u32 btrfs_item_end_nr(struct extent_buffer *eb, int nr) static inline u32 btrfs_item_end_nr(const struct extent_buffer *eb, int nr)
{ {
return btrfs_item_end(eb, btrfs_item_nr(nr)); return btrfs_item_end(eb, btrfs_item_nr(nr));
} }
static inline u32 btrfs_item_offset_nr(struct extent_buffer *eb, int nr) static inline u32 btrfs_item_offset_nr(const struct extent_buffer *eb, int nr)
{ {
return btrfs_item_offset(eb, btrfs_item_nr(nr)); return btrfs_item_offset(eb, btrfs_item_nr(nr));
} }
static inline u32 btrfs_item_size_nr(struct extent_buffer *eb, int nr) static inline u32 btrfs_item_size_nr(const struct extent_buffer *eb, int nr)
{ {
return btrfs_item_size(eb, btrfs_item_nr(nr)); return btrfs_item_size(eb, btrfs_item_nr(nr));
} }
static inline void btrfs_item_key(struct extent_buffer *eb, static inline void btrfs_item_key(const struct extent_buffer *eb,
struct btrfs_disk_key *disk_key, int nr) struct btrfs_disk_key *disk_key, int nr)
{ {
struct btrfs_item *item = btrfs_item_nr(nr); struct btrfs_item *item = btrfs_item_nr(nr);
...@@ -2764,8 +2767,8 @@ BTRFS_SETGET_STACK_FUNCS(stack_dir_name_len, struct btrfs_dir_item, ...@@ -2764,8 +2767,8 @@ BTRFS_SETGET_STACK_FUNCS(stack_dir_name_len, struct btrfs_dir_item,
BTRFS_SETGET_STACK_FUNCS(stack_dir_transid, struct btrfs_dir_item, BTRFS_SETGET_STACK_FUNCS(stack_dir_transid, struct btrfs_dir_item,
transid, 64); transid, 64);
static inline void btrfs_dir_item_key(struct extent_buffer *eb, static inline void btrfs_dir_item_key(const struct extent_buffer *eb,
struct btrfs_dir_item *item, const struct btrfs_dir_item *item,
struct btrfs_disk_key *key) struct btrfs_disk_key *key)
{ {
read_eb_member(eb, item, struct btrfs_dir_item, location, key); read_eb_member(eb, item, struct btrfs_dir_item, location, key);
...@@ -2773,7 +2776,7 @@ static inline void btrfs_dir_item_key(struct extent_buffer *eb, ...@@ -2773,7 +2776,7 @@ static inline void btrfs_dir_item_key(struct extent_buffer *eb,
static inline void btrfs_set_dir_item_key(struct extent_buffer *eb, static inline void btrfs_set_dir_item_key(struct extent_buffer *eb,
struct btrfs_dir_item *item, struct btrfs_dir_item *item,
struct btrfs_disk_key *key) const struct btrfs_disk_key *key)
{ {
write_eb_member(eb, item, struct btrfs_dir_item, location, key); write_eb_member(eb, item, struct btrfs_dir_item, location, key);
} }
...@@ -2785,8 +2788,8 @@ BTRFS_SETGET_FUNCS(free_space_bitmaps, struct btrfs_free_space_header, ...@@ -2785,8 +2788,8 @@ BTRFS_SETGET_FUNCS(free_space_bitmaps, struct btrfs_free_space_header,
BTRFS_SETGET_FUNCS(free_space_generation, struct btrfs_free_space_header, BTRFS_SETGET_FUNCS(free_space_generation, struct btrfs_free_space_header,
generation, 64); generation, 64);
static inline void btrfs_free_space_key(struct extent_buffer *eb, static inline void btrfs_free_space_key(const struct extent_buffer *eb,
struct btrfs_free_space_header *h, const struct btrfs_free_space_header *h,
struct btrfs_disk_key *key) struct btrfs_disk_key *key)
{ {
read_eb_member(eb, h, struct btrfs_free_space_header, location, key); read_eb_member(eb, h, struct btrfs_free_space_header, location, key);
...@@ -2794,7 +2797,7 @@ static inline void btrfs_free_space_key(struct extent_buffer *eb, ...@@ -2794,7 +2797,7 @@ static inline void btrfs_free_space_key(struct extent_buffer *eb,
static inline void btrfs_set_free_space_key(struct extent_buffer *eb, static inline void btrfs_set_free_space_key(struct extent_buffer *eb,
struct btrfs_free_space_header *h, struct btrfs_free_space_header *h,
struct btrfs_disk_key *key) const struct btrfs_disk_key *key)
{ {
write_eb_member(eb, h, struct btrfs_free_space_header, location, key); write_eb_member(eb, h, struct btrfs_free_space_header, location, key);
} }
...@@ -2821,7 +2824,7 @@ static inline void btrfs_cpu_key_to_disk(struct btrfs_disk_key *disk, ...@@ -2821,7 +2824,7 @@ static inline void btrfs_cpu_key_to_disk(struct btrfs_disk_key *disk,
disk->objectid = cpu_to_le64(cpu->objectid); disk->objectid = cpu_to_le64(cpu->objectid);
} }
static inline void btrfs_node_key_to_cpu(struct extent_buffer *eb, static inline void btrfs_node_key_to_cpu(const struct extent_buffer *eb,
struct btrfs_key *key, int nr) struct btrfs_key *key, int nr)
{ {
struct btrfs_disk_key disk_key; struct btrfs_disk_key disk_key;
...@@ -2829,7 +2832,7 @@ static inline void btrfs_node_key_to_cpu(struct extent_buffer *eb, ...@@ -2829,7 +2832,7 @@ static inline void btrfs_node_key_to_cpu(struct extent_buffer *eb,
btrfs_disk_key_to_cpu(key, &disk_key); btrfs_disk_key_to_cpu(key, &disk_key);
} }
static inline void btrfs_item_key_to_cpu(struct extent_buffer *eb, static inline void btrfs_item_key_to_cpu(const struct extent_buffer *eb,
struct btrfs_key *key, int nr) struct btrfs_key *key, int nr)
{ {
struct btrfs_disk_key disk_key; struct btrfs_disk_key disk_key;
...@@ -2837,8 +2840,8 @@ static inline void btrfs_item_key_to_cpu(struct extent_buffer *eb, ...@@ -2837,8 +2840,8 @@ static inline void btrfs_item_key_to_cpu(struct extent_buffer *eb,
btrfs_disk_key_to_cpu(key, &disk_key); btrfs_disk_key_to_cpu(key, &disk_key);
} }
static inline void btrfs_dir_item_key_to_cpu(struct extent_buffer *eb, static inline void btrfs_dir_item_key_to_cpu(const struct extent_buffer *eb,
struct btrfs_dir_item *item, const struct btrfs_dir_item *item,
struct btrfs_key *key) struct btrfs_key *key)
{ {
struct btrfs_disk_key disk_key; struct btrfs_disk_key disk_key;
...@@ -2872,7 +2875,7 @@ BTRFS_SETGET_STACK_FUNCS(stack_header_nritems, struct btrfs_header, ...@@ -2872,7 +2875,7 @@ BTRFS_SETGET_STACK_FUNCS(stack_header_nritems, struct btrfs_header,
nritems, 32); nritems, 32);
BTRFS_SETGET_STACK_FUNCS(stack_header_bytenr, struct btrfs_header, bytenr, 64); BTRFS_SETGET_STACK_FUNCS(stack_header_bytenr, struct btrfs_header, bytenr, 64);
static inline int btrfs_header_flag(struct extent_buffer *eb, u64 flag) static inline int btrfs_header_flag(const struct extent_buffer *eb, u64 flag)
{ {
return (btrfs_header_flags(eb) & flag) == flag; return (btrfs_header_flags(eb) & flag) == flag;
} }
...@@ -2891,7 +2894,7 @@ static inline int btrfs_clear_header_flag(struct extent_buffer *eb, u64 flag) ...@@ -2891,7 +2894,7 @@ static inline int btrfs_clear_header_flag(struct extent_buffer *eb, u64 flag)
return (flags & flag) == flag; return (flags & flag) == flag;
} }
static inline int btrfs_header_backref_rev(struct extent_buffer *eb) static inline int btrfs_header_backref_rev(const struct extent_buffer *eb)
{ {
u64 flags = btrfs_header_flags(eb); u64 flags = btrfs_header_flags(eb);
return flags >> BTRFS_BACKREF_REV_SHIFT; return flags >> BTRFS_BACKREF_REV_SHIFT;
...@@ -2911,12 +2914,12 @@ static inline unsigned long btrfs_header_fsid(void) ...@@ -2911,12 +2914,12 @@ static inline unsigned long btrfs_header_fsid(void)
return offsetof(struct btrfs_header, fsid); return offsetof(struct btrfs_header, fsid);
} }
static inline unsigned long btrfs_header_chunk_tree_uuid(struct extent_buffer *eb) static inline unsigned long btrfs_header_chunk_tree_uuid(const struct extent_buffer *eb)
{ {
return offsetof(struct btrfs_header, chunk_tree_uuid); return offsetof(struct btrfs_header, chunk_tree_uuid);
} }
static inline int btrfs_is_leaf(struct extent_buffer *eb) static inline int btrfs_is_leaf(const struct extent_buffer *eb)
{ {
return btrfs_header_level(eb) == 0; return btrfs_header_level(eb) == 0;
} }
...@@ -2950,12 +2953,12 @@ BTRFS_SETGET_STACK_FUNCS(root_stransid, struct btrfs_root_item, ...@@ -2950,12 +2953,12 @@ BTRFS_SETGET_STACK_FUNCS(root_stransid, struct btrfs_root_item,
BTRFS_SETGET_STACK_FUNCS(root_rtransid, struct btrfs_root_item, BTRFS_SETGET_STACK_FUNCS(root_rtransid, struct btrfs_root_item,
rtransid, 64); rtransid, 64);
static inline bool btrfs_root_readonly(struct btrfs_root *root) static inline bool btrfs_root_readonly(const struct btrfs_root *root)
{ {
return (root->root_item.flags & cpu_to_le64(BTRFS_ROOT_SUBVOL_RDONLY)) != 0; return (root->root_item.flags & cpu_to_le64(BTRFS_ROOT_SUBVOL_RDONLY)) != 0;
} }
static inline bool btrfs_root_dead(struct btrfs_root *root) static inline bool btrfs_root_dead(const struct btrfs_root *root)
{ {
return (root->root_item.flags & cpu_to_le64(BTRFS_ROOT_SUBVOL_DEAD)) != 0; return (root->root_item.flags & cpu_to_le64(BTRFS_ROOT_SUBVOL_DEAD)) != 0;
} }
...@@ -3012,8 +3015,8 @@ BTRFS_SETGET_STACK_FUNCS(backup_num_devices, struct btrfs_root_backup, ...@@ -3012,8 +3015,8 @@ BTRFS_SETGET_STACK_FUNCS(backup_num_devices, struct btrfs_root_backup,
/* struct btrfs_balance_item */ /* struct btrfs_balance_item */
BTRFS_SETGET_FUNCS(balance_flags, struct btrfs_balance_item, flags, 64); BTRFS_SETGET_FUNCS(balance_flags, struct btrfs_balance_item, flags, 64);
static inline void btrfs_balance_data(struct extent_buffer *eb, static inline void btrfs_balance_data(const struct extent_buffer *eb,
struct btrfs_balance_item *bi, const struct btrfs_balance_item *bi,
struct btrfs_disk_balance_args *ba) struct btrfs_disk_balance_args *ba)
{ {
read_eb_member(eb, bi, struct btrfs_balance_item, data, ba); read_eb_member(eb, bi, struct btrfs_balance_item, data, ba);
...@@ -3021,13 +3024,13 @@ static inline void btrfs_balance_data(struct extent_buffer *eb, ...@@ -3021,13 +3024,13 @@ static inline void btrfs_balance_data(struct extent_buffer *eb,
static inline void btrfs_set_balance_data(struct extent_buffer *eb, static inline void btrfs_set_balance_data(struct extent_buffer *eb,
struct btrfs_balance_item *bi, struct btrfs_balance_item *bi,
struct btrfs_disk_balance_args *ba) const struct btrfs_disk_balance_args *ba)
{ {
write_eb_member(eb, bi, struct btrfs_balance_item, data, ba); write_eb_member(eb, bi, struct btrfs_balance_item, data, ba);
} }
static inline void btrfs_balance_meta(struct extent_buffer *eb, static inline void btrfs_balance_meta(const struct extent_buffer *eb,
struct btrfs_balance_item *bi, const struct btrfs_balance_item *bi,
struct btrfs_disk_balance_args *ba) struct btrfs_disk_balance_args *ba)
{ {
read_eb_member(eb, bi, struct btrfs_balance_item, meta, ba); read_eb_member(eb, bi, struct btrfs_balance_item, meta, ba);
...@@ -3035,13 +3038,13 @@ static inline void btrfs_balance_meta(struct extent_buffer *eb, ...@@ -3035,13 +3038,13 @@ static inline void btrfs_balance_meta(struct extent_buffer *eb,
static inline void btrfs_set_balance_meta(struct extent_buffer *eb, static inline void btrfs_set_balance_meta(struct extent_buffer *eb,
struct btrfs_balance_item *bi, struct btrfs_balance_item *bi,
struct btrfs_disk_balance_args *ba) const struct btrfs_disk_balance_args *ba)
{ {
write_eb_member(eb, bi, struct btrfs_balance_item, meta, ba); write_eb_member(eb, bi, struct btrfs_balance_item, meta, ba);
} }
static inline void btrfs_balance_sys(struct extent_buffer *eb, static inline void btrfs_balance_sys(const struct extent_buffer *eb,
struct btrfs_balance_item *bi, const struct btrfs_balance_item *bi,
struct btrfs_disk_balance_args *ba) struct btrfs_disk_balance_args *ba)
{ {
read_eb_member(eb, bi, struct btrfs_balance_item, sys, ba); read_eb_member(eb, bi, struct btrfs_balance_item, sys, ba);
...@@ -3049,14 +3052,14 @@ static inline void btrfs_balance_sys(struct extent_buffer *eb, ...@@ -3049,14 +3052,14 @@ static inline void btrfs_balance_sys(struct extent_buffer *eb,
static inline void btrfs_set_balance_sys(struct extent_buffer *eb, static inline void btrfs_set_balance_sys(struct extent_buffer *eb,
struct btrfs_balance_item *bi, struct btrfs_balance_item *bi,
struct btrfs_disk_balance_args *ba) const struct btrfs_disk_balance_args *ba)
{ {
write_eb_member(eb, bi, struct btrfs_balance_item, sys, ba); write_eb_member(eb, bi, struct btrfs_balance_item, sys, ba);
} }
static inline void static inline void
btrfs_disk_balance_args_to_cpu(struct btrfs_balance_args *cpu, btrfs_disk_balance_args_to_cpu(struct btrfs_balance_args *cpu,
struct btrfs_disk_balance_args *disk) const struct btrfs_disk_balance_args *disk)
{ {
memset(cpu, 0, sizeof(*cpu)); memset(cpu, 0, sizeof(*cpu));
...@@ -3076,7 +3079,7 @@ btrfs_disk_balance_args_to_cpu(struct btrfs_balance_args *cpu, ...@@ -3076,7 +3079,7 @@ btrfs_disk_balance_args_to_cpu(struct btrfs_balance_args *cpu,
static inline void static inline void
btrfs_cpu_balance_args_to_disk(struct btrfs_disk_balance_args *disk, btrfs_cpu_balance_args_to_disk(struct btrfs_disk_balance_args *disk,
struct btrfs_balance_args *cpu) const struct btrfs_balance_args *cpu)
{ {
memset(disk, 0, sizeof(*disk)); memset(disk, 0, sizeof(*disk));
...@@ -3144,7 +3147,7 @@ BTRFS_SETGET_STACK_FUNCS(super_magic, struct btrfs_super_block, magic, 64); ...@@ -3144,7 +3147,7 @@ BTRFS_SETGET_STACK_FUNCS(super_magic, struct btrfs_super_block, magic, 64);
BTRFS_SETGET_STACK_FUNCS(super_uuid_tree_generation, struct btrfs_super_block, BTRFS_SETGET_STACK_FUNCS(super_uuid_tree_generation, struct btrfs_super_block,
uuid_tree_generation, 64); uuid_tree_generation, 64);
static inline int btrfs_super_csum_size(struct btrfs_super_block *s) static inline int btrfs_super_csum_size(const struct btrfs_super_block *s)
{ {
u16 t = btrfs_super_csum_type(s); u16 t = btrfs_super_csum_type(s);
/* /*
...@@ -3163,8 +3166,8 @@ static inline unsigned long btrfs_leaf_data(struct extent_buffer *l) ...@@ -3163,8 +3166,8 @@ static inline unsigned long btrfs_leaf_data(struct extent_buffer *l)
* this returns the address of the start of the last item, * this returns the address of the start of the last item,
* which is the stop of the leaf data stack * which is the stop of the leaf data stack
*/ */
static inline unsigned int leaf_data_end(struct btrfs_root *root, static inline unsigned int leaf_data_end(const struct btrfs_root *root,
struct extent_buffer *leaf) const struct extent_buffer *leaf)
{ {
u32 nr = btrfs_header_nritems(leaf); u32 nr = btrfs_header_nritems(leaf);
...@@ -3189,7 +3192,7 @@ BTRFS_SETGET_STACK_FUNCS(stack_file_extent_compression, ...@@ -3189,7 +3192,7 @@ BTRFS_SETGET_STACK_FUNCS(stack_file_extent_compression,
struct btrfs_file_extent_item, compression, 8); struct btrfs_file_extent_item, compression, 8);
static inline unsigned long static inline unsigned long
btrfs_file_extent_inline_start(struct btrfs_file_extent_item *e) btrfs_file_extent_inline_start(const struct btrfs_file_extent_item *e)
{ {
return (unsigned long)e + BTRFS_FILE_EXTENT_INLINE_DATA_START; return (unsigned long)e + BTRFS_FILE_EXTENT_INLINE_DATA_START;
} }
...@@ -3223,7 +3226,8 @@ BTRFS_SETGET_FUNCS(file_extent_other_encoding, struct btrfs_file_extent_item, ...@@ -3223,7 +3226,8 @@ BTRFS_SETGET_FUNCS(file_extent_other_encoding, struct btrfs_file_extent_item,
* size of any extent headers. If a file is compressed on disk, this is * size of any extent headers. If a file is compressed on disk, this is
* the compressed size * the compressed size
*/ */
static inline u32 btrfs_file_extent_inline_item_len(struct extent_buffer *eb, static inline u32 btrfs_file_extent_inline_item_len(
const struct extent_buffer *eb,
struct btrfs_item *e) struct btrfs_item *e)
{ {
return btrfs_item_size(eb, e) - BTRFS_FILE_EXTENT_INLINE_DATA_START; return btrfs_item_size(eb, e) - BTRFS_FILE_EXTENT_INLINE_DATA_START;
...@@ -3232,9 +3236,9 @@ static inline u32 btrfs_file_extent_inline_item_len(struct extent_buffer *eb, ...@@ -3232,9 +3236,9 @@ static inline u32 btrfs_file_extent_inline_item_len(struct extent_buffer *eb,
/* this returns the number of file bytes represented by the inline item. /* this returns the number of file bytes represented by the inline item.
* If an item is compressed, this is the uncompressed size * If an item is compressed, this is the uncompressed size
*/ */
static inline u32 btrfs_file_extent_inline_len(struct extent_buffer *eb, static inline u32 btrfs_file_extent_inline_len(const struct extent_buffer *eb,
int slot, int slot,
struct btrfs_file_extent_item *fi) const struct btrfs_file_extent_item *fi)
{ {
struct btrfs_map_token token; struct btrfs_map_token token;
...@@ -3256,8 +3260,8 @@ static inline u32 btrfs_file_extent_inline_len(struct extent_buffer *eb, ...@@ -3256,8 +3260,8 @@ static inline u32 btrfs_file_extent_inline_len(struct extent_buffer *eb,
/* btrfs_dev_stats_item */ /* btrfs_dev_stats_item */
static inline u64 btrfs_dev_stats_value(struct extent_buffer *eb, static inline u64 btrfs_dev_stats_value(const struct extent_buffer *eb,
struct btrfs_dev_stats_item *ptr, const struct btrfs_dev_stats_item *ptr,
int index) int index)
{ {
u64 val; u64 val;
......
...@@ -5381,9 +5381,8 @@ int read_extent_buffer_pages(struct extent_io_tree *tree, ...@@ -5381,9 +5381,8 @@ int read_extent_buffer_pages(struct extent_io_tree *tree,
return ret; return ret;
} }
void read_extent_buffer(struct extent_buffer *eb, void *dstv, void read_extent_buffer(const struct extent_buffer *eb, void *dstv,
unsigned long start, unsigned long start, unsigned long len)
unsigned long len)
{ {
size_t cur; size_t cur;
size_t offset; size_t offset;
...@@ -5412,9 +5411,9 @@ void read_extent_buffer(struct extent_buffer *eb, void *dstv, ...@@ -5412,9 +5411,9 @@ void read_extent_buffer(struct extent_buffer *eb, void *dstv,
} }
} }
int read_extent_buffer_to_user(struct extent_buffer *eb, void __user *dstv, int read_extent_buffer_to_user(const struct extent_buffer *eb,
unsigned long start, void __user *dstv,
unsigned long len) unsigned long start, unsigned long len)
{ {
size_t cur; size_t cur;
size_t offset; size_t offset;
...@@ -5449,9 +5448,9 @@ int read_extent_buffer_to_user(struct extent_buffer *eb, void __user *dstv, ...@@ -5449,9 +5448,9 @@ int read_extent_buffer_to_user(struct extent_buffer *eb, void __user *dstv,
return ret; return ret;
} }
int map_private_extent_buffer(struct extent_buffer *eb, unsigned long start, int map_private_extent_buffer(const struct extent_buffer *eb,
unsigned long min_len, char **map, unsigned long start, unsigned long min_len,
unsigned long *map_start, char **map, unsigned long *map_start,
unsigned long *map_len) unsigned long *map_len)
{ {
size_t offset = start & (PAGE_CACHE_SIZE - 1); size_t offset = start & (PAGE_CACHE_SIZE - 1);
...@@ -5487,9 +5486,8 @@ int map_private_extent_buffer(struct extent_buffer *eb, unsigned long start, ...@@ -5487,9 +5486,8 @@ int map_private_extent_buffer(struct extent_buffer *eb, unsigned long start,
return 0; return 0;
} }
int memcmp_extent_buffer(struct extent_buffer *eb, const void *ptrv, int memcmp_extent_buffer(const struct extent_buffer *eb, const void *ptrv,
unsigned long start, unsigned long start, unsigned long len)
unsigned long len)
{ {
size_t cur; size_t cur;
size_t offset; size_t offset;
......
...@@ -308,14 +308,13 @@ static inline void extent_buffer_get(struct extent_buffer *eb) ...@@ -308,14 +308,13 @@ static inline void extent_buffer_get(struct extent_buffer *eb)
atomic_inc(&eb->refs); atomic_inc(&eb->refs);
} }
int memcmp_extent_buffer(struct extent_buffer *eb, const void *ptrv, int memcmp_extent_buffer(const struct extent_buffer *eb, const void *ptrv,
unsigned long start, unsigned long start, unsigned long len);
unsigned long len); void read_extent_buffer(const struct extent_buffer *eb, void *dst,
void read_extent_buffer(struct extent_buffer *eb, void *dst,
unsigned long start, unsigned long start,
unsigned long len); unsigned long len);
int read_extent_buffer_to_user(struct extent_buffer *eb, void __user *dst, int read_extent_buffer_to_user(const struct extent_buffer *eb,
unsigned long start, void __user *dst, unsigned long start,
unsigned long len); unsigned long len);
void write_extent_buffer(struct extent_buffer *eb, const void *src, void write_extent_buffer(struct extent_buffer *eb, const void *src,
unsigned long start, unsigned long len); unsigned long start, unsigned long len);
...@@ -334,9 +333,9 @@ int set_extent_buffer_uptodate(struct extent_buffer *eb); ...@@ -334,9 +333,9 @@ int set_extent_buffer_uptodate(struct extent_buffer *eb);
int clear_extent_buffer_uptodate(struct extent_buffer *eb); int clear_extent_buffer_uptodate(struct extent_buffer *eb);
int extent_buffer_uptodate(struct extent_buffer *eb); int extent_buffer_uptodate(struct extent_buffer *eb);
int extent_buffer_under_io(struct extent_buffer *eb); int extent_buffer_under_io(struct extent_buffer *eb);
int map_private_extent_buffer(struct extent_buffer *eb, unsigned long offset, int map_private_extent_buffer(const struct extent_buffer *eb,
unsigned long min_len, char **map, unsigned long offset, unsigned long min_len,
unsigned long *map_start, char **map, unsigned long *map_start,
unsigned long *map_len); unsigned long *map_len);
int extent_range_clear_dirty_for_io(struct inode *inode, u64 start, u64 end); int extent_range_clear_dirty_for_io(struct inode *inode, u64 start, u64 end);
int extent_range_redirty_for_io(struct inode *inode, u64 start, u64 end); int extent_range_redirty_for_io(struct inode *inode, u64 start, u64 end);
......
...@@ -50,8 +50,8 @@ static inline void put_unaligned_le8(u8 val, void *p) ...@@ -50,8 +50,8 @@ static inline void put_unaligned_le8(u8 val, void *p)
*/ */
#define DEFINE_BTRFS_SETGET_BITS(bits) \ #define DEFINE_BTRFS_SETGET_BITS(bits) \
u##bits btrfs_get_token_##bits(struct extent_buffer *eb, void *ptr, \ u##bits btrfs_get_token_##bits(const struct extent_buffer *eb, \
unsigned long off, \ const void *ptr, unsigned long off, \
struct btrfs_map_token *token) \ struct btrfs_map_token *token) \
{ \ { \
unsigned long part_offset = (unsigned long)ptr; \ unsigned long part_offset = (unsigned long)ptr; \
...@@ -90,7 +90,8 @@ u##bits btrfs_get_token_##bits(struct extent_buffer *eb, void *ptr, \ ...@@ -90,7 +90,8 @@ u##bits btrfs_get_token_##bits(struct extent_buffer *eb, void *ptr, \
return res; \ return res; \
} \ } \
void btrfs_set_token_##bits(struct extent_buffer *eb, \ void btrfs_set_token_##bits(struct extent_buffer *eb, \
void *ptr, unsigned long off, u##bits val, \ const void *ptr, unsigned long off, \
u##bits val, \
struct btrfs_map_token *token) \ struct btrfs_map_token *token) \
{ \ { \
unsigned long part_offset = (unsigned long)ptr; \ unsigned long part_offset = (unsigned long)ptr; \
...@@ -133,7 +134,7 @@ DEFINE_BTRFS_SETGET_BITS(16) ...@@ -133,7 +134,7 @@ DEFINE_BTRFS_SETGET_BITS(16)
DEFINE_BTRFS_SETGET_BITS(32) DEFINE_BTRFS_SETGET_BITS(32)
DEFINE_BTRFS_SETGET_BITS(64) DEFINE_BTRFS_SETGET_BITS(64)
void btrfs_node_key(struct extent_buffer *eb, void btrfs_node_key(const struct extent_buffer *eb,
struct btrfs_disk_key *disk_key, int nr) struct btrfs_disk_key *disk_key, int nr)
{ {
unsigned long ptr = btrfs_node_key_ptr_offset(nr); unsigned long ptr = btrfs_node_key_ptr_offset(nr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment