mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git
synced 2024-11-23 12:14:24 +08:00
btrfs-progs: kernel-shared: update const of parameters accessors.h
Sync up with kernel and fix warnings reported by -Wcast-qual. eg. Most of the change is due to extent_buffer::data, which is a direct struct member, unlike in kernel where it's an array of pages. The const qualifier cannot be used the same way so it's dropped in affected herlpers. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
2b9f491fa3
commit
a5b7e414da
@ -40,6 +40,7 @@ void btrfs_init_map_token(struct btrfs_map_token *token, struct extent_buffer *e
|
||||
/*
|
||||
* MODIFIED:
|
||||
* - We don't have eb->folios, simply wrap the set/get helpers.
|
||||
* - no const for extent buffer in btrfs_set_*
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -96,7 +97,7 @@ void btrfs_set_token_##bits(struct btrfs_map_token *token, \
|
||||
ASSERT(check_setget_bounds(token->eb, ptr, off, size)); \
|
||||
put_unaligned_le##bits(val, token->kaddr + member_offset); \
|
||||
} \
|
||||
void btrfs_set_##bits(const struct extent_buffer *eb, void *ptr, \
|
||||
void btrfs_set_##bits(struct extent_buffer *eb, void *ptr, \
|
||||
unsigned long off, u##bits val) \
|
||||
{ \
|
||||
unsigned long member_offset = (unsigned long)ptr + off; \
|
||||
|
@ -34,7 +34,7 @@ void btrfs_init_map_token(struct btrfs_map_token *token, struct extent_buffer *e
|
||||
|
||||
static inline u8 get_unaligned_le8(const void *p)
|
||||
{
|
||||
return *(u8 *)p;
|
||||
return *(const u8 *)p;
|
||||
}
|
||||
|
||||
static inline void put_unaligned_le8(u8 val, void *p)
|
||||
@ -48,8 +48,8 @@ static inline void put_unaligned_le8(u8 val, void *p)
|
||||
offsetof(type, member), \
|
||||
sizeof(((type *)0)->member)))
|
||||
|
||||
#define write_eb_member(eb, ptr, type, member, result) (\
|
||||
write_extent_buffer(eb, (char *)(result), \
|
||||
#define write_eb_member(eb, ptr, type, member, source) ( \
|
||||
write_extent_buffer(eb, (const char *)(source), \
|
||||
((unsigned long)(ptr)) + \
|
||||
offsetof(type, member), \
|
||||
sizeof(((type *)0)->member)))
|
||||
@ -62,7 +62,7 @@ void btrfs_set_token_##bits(struct btrfs_map_token *token, \
|
||||
u##bits val); \
|
||||
u##bits btrfs_get_##bits(const struct extent_buffer *eb, \
|
||||
const void *ptr, unsigned long off); \
|
||||
void btrfs_set_##bits(const struct extent_buffer *eb, void *ptr, \
|
||||
void btrfs_set_##bits(struct extent_buffer *eb, void *ptr, \
|
||||
unsigned long off, u##bits val);
|
||||
|
||||
DECLARE_BTRFS_SETGET_BITS(8)
|
||||
@ -77,7 +77,7 @@ static inline u##bits btrfs_##name(const struct extent_buffer *eb, \
|
||||
_static_assert(sizeof(u##bits) == sizeof(((type *)0))->member); \
|
||||
return btrfs_get_##bits(eb, s, offsetof(type, member)); \
|
||||
} \
|
||||
static inline void btrfs_set_##name(const struct extent_buffer *eb, type *s, \
|
||||
static inline void btrfs_set_##name(struct extent_buffer *eb, type *s, \
|
||||
u##bits val) \
|
||||
{ \
|
||||
_static_assert(sizeof(u##bits) == sizeof(((type *)0))->member); \
|
||||
@ -99,14 +99,16 @@ static inline void btrfs_set_token_##name(struct btrfs_map_token *token,\
|
||||
/*
|
||||
* MODIFIED:
|
||||
* - We have eb->data, not eb->folios[0]
|
||||
* - no const for extent buffer in btrfs_set_*, buffer is local, in kernel
|
||||
* it's indirection to pages/folios
|
||||
*/
|
||||
#define BTRFS_SETGET_HEADER_FUNCS(name, type, member, bits) \
|
||||
static inline u##bits btrfs_##name(const struct extent_buffer *eb) \
|
||||
{ \
|
||||
const type *p = (type *)eb->data; \
|
||||
const type *p = (const type *)eb->data; \
|
||||
return get_unaligned_le##bits(&p->member); \
|
||||
} \
|
||||
static inline void btrfs_set_##name(const struct extent_buffer *eb, \
|
||||
static inline void btrfs_set_##name(struct extent_buffer *eb, \
|
||||
u##bits val) \
|
||||
{ \
|
||||
type *p = (type *)eb->data; \
|
||||
@ -133,8 +135,9 @@ static inline u64 btrfs_device_total_bytes(const struct extent_buffer *eb,
|
||||
/*
|
||||
* MODIFIED
|
||||
* - Removed WARN_ON(!IS_ALIGNED(val, eb->fs_info->sectorsize));
|
||||
* - no const for extent buffer
|
||||
*/
|
||||
static inline void btrfs_set_device_total_bytes(const struct extent_buffer *eb,
|
||||
static inline void btrfs_set_device_total_bytes(struct extent_buffer *eb,
|
||||
struct btrfs_dev_item *s,
|
||||
u64 val)
|
||||
{
|
||||
@ -379,9 +382,9 @@ static inline void btrfs_tree_block_key(const struct extent_buffer *eb,
|
||||
read_eb_member(eb, item, struct btrfs_tree_block_info, key, key);
|
||||
}
|
||||
|
||||
static inline void btrfs_set_tree_block_key(const struct extent_buffer *eb,
|
||||
static inline void btrfs_set_tree_block_key(struct extent_buffer *eb,
|
||||
struct btrfs_tree_block_info *item,
|
||||
struct btrfs_disk_key *key)
|
||||
const struct btrfs_disk_key *key)
|
||||
{
|
||||
write_eb_member(eb, item, struct btrfs_tree_block_info, key, key);
|
||||
}
|
||||
@ -435,7 +438,7 @@ static inline u64 btrfs_node_blockptr(const struct extent_buffer *eb, int nr)
|
||||
return btrfs_key_blockptr(eb, (struct btrfs_key_ptr *)ptr);
|
||||
}
|
||||
|
||||
static inline void btrfs_set_node_blockptr(const struct extent_buffer *eb,
|
||||
static inline void btrfs_set_node_blockptr(struct extent_buffer *eb,
|
||||
int nr, u64 val)
|
||||
{
|
||||
unsigned long ptr;
|
||||
@ -454,7 +457,7 @@ static inline u64 btrfs_node_ptr_generation(const struct extent_buffer *eb, int
|
||||
return btrfs_key_generation(eb, (struct btrfs_key_ptr *)ptr);
|
||||
}
|
||||
|
||||
static inline void btrfs_set_node_ptr_generation(const struct extent_buffer *eb,
|
||||
static inline void btrfs_set_node_ptr_generation(struct extent_buffer *eb,
|
||||
int nr, u64 val)
|
||||
{
|
||||
unsigned long ptr;
|
||||
@ -473,8 +476,8 @@ static inline unsigned long btrfs_node_key_ptr_offset(const struct extent_buffer
|
||||
void btrfs_node_key(const struct extent_buffer *eb,
|
||||
struct btrfs_disk_key *disk_key, int nr);
|
||||
|
||||
static inline void btrfs_set_node_key(const struct extent_buffer *eb,
|
||||
struct btrfs_disk_key *disk_key, int nr)
|
||||
static inline void btrfs_set_node_key(struct extent_buffer *eb,
|
||||
const struct btrfs_disk_key *disk_key, int nr)
|
||||
{
|
||||
unsigned long ptr;
|
||||
|
||||
@ -505,7 +508,7 @@ static inline u32 btrfs_item_##member(const struct extent_buffer *eb, int slot)
|
||||
{ \
|
||||
return btrfs_raw_item_##member(eb, btrfs_item_nr(eb, slot)); \
|
||||
} \
|
||||
static inline void btrfs_set_item_##member(const struct extent_buffer *eb, \
|
||||
static inline void btrfs_set_item_##member(struct extent_buffer *eb, \
|
||||
int slot, u32 val) \
|
||||
{ \
|
||||
btrfs_set_raw_item_##member(eb, btrfs_item_nr(eb, slot), val); \
|
||||
@ -540,7 +543,7 @@ static inline void btrfs_item_key(const struct extent_buffer *eb,
|
||||
}
|
||||
|
||||
static inline void btrfs_set_item_key(struct extent_buffer *eb,
|
||||
struct btrfs_disk_key *disk_key, int nr)
|
||||
const struct btrfs_disk_key *disk_key, int nr)
|
||||
{
|
||||
struct btrfs_item *item = btrfs_item_nr(eb, nr);
|
||||
|
||||
|
@ -79,7 +79,7 @@ static unsigned int leaf_data_end(const struct extent_buffer *leaf)
|
||||
* have to adjust any offsets to account for the header in the leaf. This
|
||||
* handles that math to simplify the callers.
|
||||
*/
|
||||
static inline void memmove_leaf_data(const struct extent_buffer *leaf,
|
||||
static inline void memmove_leaf_data(struct extent_buffer *leaf,
|
||||
unsigned long dst_offset,
|
||||
unsigned long src_offset,
|
||||
unsigned long len)
|
||||
@ -102,7 +102,7 @@ static inline void memmove_leaf_data(const struct extent_buffer *leaf,
|
||||
* have to adjust any offsets to account for the header in the leaf. This
|
||||
* handles that math to simplify the callers.
|
||||
*/
|
||||
static inline void copy_leaf_data(const struct extent_buffer *dst,
|
||||
static inline void copy_leaf_data(struct extent_buffer *dst,
|
||||
const struct extent_buffer *src,
|
||||
unsigned long dst_offset,
|
||||
unsigned long src_offset, unsigned long len)
|
||||
@ -122,7 +122,7 @@ static inline void copy_leaf_data(const struct extent_buffer *dst,
|
||||
* Wrapper around memmove_extent_buffer() that does the math to get the
|
||||
* appropriate offsets into the leaf from the item numbers.
|
||||
*/
|
||||
static inline void memmove_leaf_items(const struct extent_buffer *leaf,
|
||||
static inline void memmove_leaf_items(struct extent_buffer *leaf,
|
||||
int dst_item, int src_item, int nr_items)
|
||||
{
|
||||
memmove_extent_buffer(leaf, btrfs_item_nr_offset(leaf, dst_item),
|
||||
@ -142,7 +142,7 @@ static inline void memmove_leaf_items(const struct extent_buffer *leaf,
|
||||
* Wrapper around copy_extent_buffer() that does the math to get the
|
||||
* appropriate offsets into the leaf from the item numbers.
|
||||
*/
|
||||
static inline void copy_leaf_items(const struct extent_buffer *dst,
|
||||
static inline void copy_leaf_items(struct extent_buffer *dst,
|
||||
const struct extent_buffer *src,
|
||||
int dst_item, int src_item, int nr_items)
|
||||
{
|
||||
|
@ -612,30 +612,30 @@ void read_extent_buffer(const struct extent_buffer *eb, void *dst,
|
||||
memcpy(dst, eb->data + start, len);
|
||||
}
|
||||
|
||||
void write_extent_buffer_fsid(const struct extent_buffer *eb, const void *src)
|
||||
void write_extent_buffer_fsid(struct extent_buffer *eb, const void *src)
|
||||
{
|
||||
write_extent_buffer(eb, src, btrfs_header_fsid(), BTRFS_FSID_SIZE);
|
||||
}
|
||||
|
||||
void write_extent_buffer_chunk_tree_uuid(const struct extent_buffer *eb,
|
||||
void write_extent_buffer_chunk_tree_uuid(struct extent_buffer *eb,
|
||||
const void *src)
|
||||
{
|
||||
write_extent_buffer(eb, src, btrfs_header_chunk_tree_uuid(eb), BTRFS_FSID_SIZE);
|
||||
}
|
||||
|
||||
void write_extent_buffer(const struct extent_buffer *eb, const void *src,
|
||||
void write_extent_buffer(struct extent_buffer *eb, const void *src,
|
||||
unsigned long start, unsigned long len)
|
||||
{
|
||||
memcpy((void *)eb->data + start, src, len);
|
||||
}
|
||||
|
||||
void copy_extent_buffer_full(const struct extent_buffer *dst,
|
||||
void copy_extent_buffer_full(struct extent_buffer *dst,
|
||||
const struct extent_buffer *src)
|
||||
{
|
||||
copy_extent_buffer(dst, src, 0, 0, src->len);
|
||||
}
|
||||
|
||||
void copy_extent_buffer(const struct extent_buffer *dst,
|
||||
void copy_extent_buffer(struct extent_buffer *dst,
|
||||
const struct extent_buffer *src,
|
||||
unsigned long dst_offset, unsigned long src_offset,
|
||||
unsigned long len)
|
||||
@ -643,19 +643,19 @@ void copy_extent_buffer(const struct extent_buffer *dst,
|
||||
memcpy((void *)dst->data + dst_offset, src->data + src_offset, len);
|
||||
}
|
||||
|
||||
void memcpy_extent_buffer(const struct extent_buffer *dst, unsigned long dst_offset,
|
||||
void memcpy_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
|
||||
unsigned long src_offset, unsigned long len)
|
||||
{
|
||||
memcpy((void *)dst->data + dst_offset, dst->data + src_offset, len);
|
||||
}
|
||||
|
||||
void memmove_extent_buffer(const struct extent_buffer *dst, unsigned long dst_offset,
|
||||
void memmove_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
|
||||
unsigned long src_offset, unsigned long len)
|
||||
{
|
||||
memmove((void *)dst->data + dst_offset, dst->data + src_offset, len);
|
||||
}
|
||||
|
||||
void memset_extent_buffer(const struct extent_buffer *eb, char c,
|
||||
void memset_extent_buffer(struct extent_buffer *eb, char c,
|
||||
unsigned long start, unsigned long len)
|
||||
{
|
||||
memset((void *)eb->data + start, c, len);
|
||||
|
@ -109,24 +109,24 @@ int memcmp_extent_buffer(const struct extent_buffer *eb, const void *ptrv,
|
||||
unsigned long start, unsigned long len);
|
||||
void read_extent_buffer(const struct extent_buffer *eb, void *dst,
|
||||
unsigned long start, unsigned long len);
|
||||
void write_extent_buffer_fsid(const struct extent_buffer *eb, const void *src);
|
||||
void write_extent_buffer_chunk_tree_uuid(const struct extent_buffer *eb,
|
||||
void write_extent_buffer_fsid(struct extent_buffer *eb, const void *src);
|
||||
void write_extent_buffer_chunk_tree_uuid(struct extent_buffer *eb,
|
||||
const void *src);
|
||||
void write_extent_buffer(const struct extent_buffer *eb, const void *src,
|
||||
void write_extent_buffer(struct extent_buffer *eb, const void *src,
|
||||
unsigned long start, unsigned long len);
|
||||
void copy_extent_buffer_full(const struct extent_buffer *dst,
|
||||
void copy_extent_buffer_full(struct extent_buffer *dst,
|
||||
const struct extent_buffer *src);
|
||||
void copy_extent_buffer(const struct extent_buffer *dst,
|
||||
void copy_extent_buffer(struct extent_buffer *dst,
|
||||
const struct extent_buffer *src,
|
||||
unsigned long dst_offset, unsigned long src_offset,
|
||||
unsigned long len);
|
||||
void memcpy_extent_buffer(const struct extent_buffer *dst,
|
||||
void memcpy_extent_buffer(struct extent_buffer *dst,
|
||||
unsigned long dst_offset, unsigned long src_offset,
|
||||
unsigned long len);
|
||||
void memmove_extent_buffer(const struct extent_buffer *dst,
|
||||
void memmove_extent_buffer(struct extent_buffer *dst,
|
||||
const unsigned long dst_offset,
|
||||
unsigned long src_offset, unsigned long len);
|
||||
void memset_extent_buffer(const struct extent_buffer *eb, char c,
|
||||
void memset_extent_buffer(struct extent_buffer *eb, char c,
|
||||
unsigned long start, unsigned long len);
|
||||
int extent_buffer_test_bit(const struct extent_buffer *eb, unsigned long start,
|
||||
unsigned long nr);
|
||||
|
Loading…
Reference in New Issue
Block a user