xref: /openbmc/linux/fs/btrfs/accessors.h (revision 98efb4eb)
1ad1ac501SJosef Bacik /* SPDX-License-Identifier: GPL-2.0 */
2ad1ac501SJosef Bacik 
3ad1ac501SJosef Bacik #ifndef BTRFS_ACCESSORS_H
4ad1ac501SJosef Bacik #define BTRFS_ACCESSORS_H
5ad1ac501SJosef Bacik 
6*98efb4ebSDavid Sterba #include <linux/stddef.h>
7*98efb4ebSDavid Sterba 
8ad1ac501SJosef Bacik struct btrfs_map_token {
9ad1ac501SJosef Bacik 	struct extent_buffer *eb;
10ad1ac501SJosef Bacik 	char *kaddr;
11ad1ac501SJosef Bacik 	unsigned long offset;
12ad1ac501SJosef Bacik };
13ad1ac501SJosef Bacik 
14ad1ac501SJosef Bacik void btrfs_init_map_token(struct btrfs_map_token *token, struct extent_buffer *eb);
15ad1ac501SJosef Bacik 
1607e81dc9SJosef Bacik /*
1707e81dc9SJosef Bacik  * Some macros to generate set/get functions for the struct fields.  This
1807e81dc9SJosef Bacik  * assumes there is a lefoo_to_cpu for every type, so lets make a simple one
1907e81dc9SJosef Bacik  * for u8:
2007e81dc9SJosef Bacik  */
2107e81dc9SJosef Bacik #define le8_to_cpu(v) (v)
2207e81dc9SJosef Bacik #define cpu_to_le8(v) (v)
2307e81dc9SJosef Bacik #define __le8 u8
2407e81dc9SJosef Bacik 
get_unaligned_le8(const void * p)2507e81dc9SJosef Bacik static inline u8 get_unaligned_le8(const void *p)
2607e81dc9SJosef Bacik {
2707e81dc9SJosef Bacik        return *(u8 *)p;
2807e81dc9SJosef Bacik }
2907e81dc9SJosef Bacik 
put_unaligned_le8(u8 val,void * p)3007e81dc9SJosef Bacik static inline void put_unaligned_le8(u8 val, void *p)
3107e81dc9SJosef Bacik {
3207e81dc9SJosef Bacik        *(u8 *)p = val;
3307e81dc9SJosef Bacik }
3407e81dc9SJosef Bacik 
3507e81dc9SJosef Bacik #define read_eb_member(eb, ptr, type, member, result) (\
3607e81dc9SJosef Bacik 	read_extent_buffer(eb, (char *)(result),			\
3707e81dc9SJosef Bacik 			   ((unsigned long)(ptr)) +			\
3807e81dc9SJosef Bacik 			    offsetof(type, member),			\
39*98efb4ebSDavid Sterba 			    sizeof_field(type, member)))
4007e81dc9SJosef Bacik 
4107e81dc9SJosef Bacik #define write_eb_member(eb, ptr, type, member, result) (\
4207e81dc9SJosef Bacik 	write_extent_buffer(eb, (char *)(result),			\
4307e81dc9SJosef Bacik 			   ((unsigned long)(ptr)) +			\
4407e81dc9SJosef Bacik 			    offsetof(type, member),			\
45*98efb4ebSDavid Sterba 			    sizeof_field(type, member)))
4607e81dc9SJosef Bacik 
4707e81dc9SJosef Bacik #define DECLARE_BTRFS_SETGET_BITS(bits)					\
4807e81dc9SJosef Bacik u##bits btrfs_get_token_##bits(struct btrfs_map_token *token,		\
4907e81dc9SJosef Bacik 			       const void *ptr, unsigned long off);	\
5007e81dc9SJosef Bacik void btrfs_set_token_##bits(struct btrfs_map_token *token,		\
5107e81dc9SJosef Bacik 			    const void *ptr, unsigned long off,		\
5207e81dc9SJosef Bacik 			    u##bits val);				\
5307e81dc9SJosef Bacik u##bits btrfs_get_##bits(const struct extent_buffer *eb,		\
5407e81dc9SJosef Bacik 			 const void *ptr, unsigned long off);		\
5507e81dc9SJosef Bacik void btrfs_set_##bits(const struct extent_buffer *eb, void *ptr,	\
5607e81dc9SJosef Bacik 		      unsigned long off, u##bits val);
5707e81dc9SJosef Bacik 
5807e81dc9SJosef Bacik DECLARE_BTRFS_SETGET_BITS(8)
5907e81dc9SJosef Bacik DECLARE_BTRFS_SETGET_BITS(16)
6007e81dc9SJosef Bacik DECLARE_BTRFS_SETGET_BITS(32)
6107e81dc9SJosef Bacik DECLARE_BTRFS_SETGET_BITS(64)
6207e81dc9SJosef Bacik 
6307e81dc9SJosef Bacik #define BTRFS_SETGET_FUNCS(name, type, member, bits)			\
6407e81dc9SJosef Bacik static inline u##bits btrfs_##name(const struct extent_buffer *eb,	\
6507e81dc9SJosef Bacik 				   const type *s)			\
6607e81dc9SJosef Bacik {									\
67*98efb4ebSDavid Sterba 	static_assert(sizeof(u##bits) == sizeof_field(type, member));	\
6807e81dc9SJosef Bacik 	return btrfs_get_##bits(eb, s, offsetof(type, member));		\
6907e81dc9SJosef Bacik }									\
7007e81dc9SJosef Bacik static inline void btrfs_set_##name(const struct extent_buffer *eb, type *s, \
7107e81dc9SJosef Bacik 				    u##bits val)			\
7207e81dc9SJosef Bacik {									\
73*98efb4ebSDavid Sterba 	static_assert(sizeof(u##bits) == sizeof_field(type, member));	\
7407e81dc9SJosef Bacik 	btrfs_set_##bits(eb, s, offsetof(type, member), val);		\
7507e81dc9SJosef Bacik }									\
7607e81dc9SJosef Bacik static inline u##bits btrfs_token_##name(struct btrfs_map_token *token,	\
7707e81dc9SJosef Bacik 					 const type *s)			\
7807e81dc9SJosef Bacik {									\
79*98efb4ebSDavid Sterba 	static_assert(sizeof(u##bits) == sizeof_field(type, member));	\
8007e81dc9SJosef Bacik 	return btrfs_get_token_##bits(token, s, offsetof(type, member));\
8107e81dc9SJosef Bacik }									\
8207e81dc9SJosef Bacik static inline void btrfs_set_token_##name(struct btrfs_map_token *token,\
8307e81dc9SJosef Bacik 					  type *s, u##bits val)		\
8407e81dc9SJosef Bacik {									\
85*98efb4ebSDavid Sterba 	static_assert(sizeof(u##bits) == sizeof_field(type, member));	\
8607e81dc9SJosef Bacik 	btrfs_set_token_##bits(token, s, offsetof(type, member), val);	\
8707e81dc9SJosef Bacik }
8807e81dc9SJosef Bacik 
8907e81dc9SJosef Bacik #define BTRFS_SETGET_HEADER_FUNCS(name, type, member, bits)		\
9007e81dc9SJosef Bacik static inline u##bits btrfs_##name(const struct extent_buffer *eb)	\
9107e81dc9SJosef Bacik {									\
9207e81dc9SJosef Bacik 	const type *p = page_address(eb->pages[0]) +			\
9307e81dc9SJosef Bacik 			offset_in_page(eb->start);			\
9407e81dc9SJosef Bacik 	return get_unaligned_le##bits(&p->member);			\
9507e81dc9SJosef Bacik }									\
9607e81dc9SJosef Bacik static inline void btrfs_set_##name(const struct extent_buffer *eb,	\
9707e81dc9SJosef Bacik 				    u##bits val)			\
9807e81dc9SJosef Bacik {									\
9907e81dc9SJosef Bacik 	type *p = page_address(eb->pages[0]) + offset_in_page(eb->start); \
10007e81dc9SJosef Bacik 	put_unaligned_le##bits(val, &p->member);			\
10107e81dc9SJosef Bacik }
10207e81dc9SJosef Bacik 
10307e81dc9SJosef Bacik #define BTRFS_SETGET_STACK_FUNCS(name, type, member, bits)		\
10407e81dc9SJosef Bacik static inline u##bits btrfs_##name(const type *s)			\
10507e81dc9SJosef Bacik {									\
10607e81dc9SJosef Bacik 	return get_unaligned_le##bits(&s->member);			\
10707e81dc9SJosef Bacik }									\
10807e81dc9SJosef Bacik static inline void btrfs_set_##name(type *s, u##bits val)		\
10907e81dc9SJosef Bacik {									\
11007e81dc9SJosef Bacik 	put_unaligned_le##bits(val, &s->member);			\
11107e81dc9SJosef Bacik }
11207e81dc9SJosef Bacik 
btrfs_device_total_bytes(const struct extent_buffer * eb,struct btrfs_dev_item * s)11307e81dc9SJosef Bacik static inline u64 btrfs_device_total_bytes(const struct extent_buffer *eb,
11407e81dc9SJosef Bacik 					   struct btrfs_dev_item *s)
11507e81dc9SJosef Bacik {
116*98efb4ebSDavid Sterba 	static_assert(sizeof(u64) == sizeof_field(struct btrfs_dev_item, total_bytes));
117*98efb4ebSDavid Sterba 	return btrfs_get_64(eb, s, offsetof(struct btrfs_dev_item, total_bytes));
11807e81dc9SJosef Bacik }
btrfs_set_device_total_bytes(const struct extent_buffer * eb,struct btrfs_dev_item * s,u64 val)11907e81dc9SJosef Bacik static inline void btrfs_set_device_total_bytes(const struct extent_buffer *eb,
12007e81dc9SJosef Bacik 						struct btrfs_dev_item *s,
12107e81dc9SJosef Bacik 						u64 val)
12207e81dc9SJosef Bacik {
123*98efb4ebSDavid Sterba 	static_assert(sizeof(u64) == sizeof_field(struct btrfs_dev_item, total_bytes));
12407e81dc9SJosef Bacik 	WARN_ON(!IS_ALIGNED(val, eb->fs_info->sectorsize));
12507e81dc9SJosef Bacik 	btrfs_set_64(eb, s, offsetof(struct btrfs_dev_item, total_bytes), val);
12607e81dc9SJosef Bacik }
12707e81dc9SJosef Bacik 
12807e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(device_type, struct btrfs_dev_item, type, 64);
12907e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(device_bytes_used, struct btrfs_dev_item, bytes_used, 64);
13007e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(device_io_align, struct btrfs_dev_item, io_align, 32);
13107e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(device_io_width, struct btrfs_dev_item, io_width, 32);
13207e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(device_start_offset, struct btrfs_dev_item, start_offset, 64);
13307e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(device_sector_size, struct btrfs_dev_item, sector_size, 32);
13407e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(device_id, struct btrfs_dev_item, devid, 64);
13507e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(device_group, struct btrfs_dev_item, dev_group, 32);
13607e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(device_seek_speed, struct btrfs_dev_item, seek_speed, 8);
13707e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(device_bandwidth, struct btrfs_dev_item, bandwidth, 8);
13807e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(device_generation, struct btrfs_dev_item, generation, 64);
13907e81dc9SJosef Bacik 
14007e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_device_type, struct btrfs_dev_item, type, 64);
14107e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_device_total_bytes, struct btrfs_dev_item,
14207e81dc9SJosef Bacik 			 total_bytes, 64);
14307e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_device_bytes_used, struct btrfs_dev_item,
14407e81dc9SJosef Bacik 			 bytes_used, 64);
14507e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_device_io_align, struct btrfs_dev_item,
14607e81dc9SJosef Bacik 			 io_align, 32);
14707e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_device_io_width, struct btrfs_dev_item,
14807e81dc9SJosef Bacik 			 io_width, 32);
14907e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_device_sector_size, struct btrfs_dev_item,
15007e81dc9SJosef Bacik 			 sector_size, 32);
15107e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_device_id, struct btrfs_dev_item, devid, 64);
15207e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_device_group, struct btrfs_dev_item, dev_group, 32);
15307e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_device_seek_speed, struct btrfs_dev_item,
15407e81dc9SJosef Bacik 			 seek_speed, 8);
15507e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_device_bandwidth, struct btrfs_dev_item,
15607e81dc9SJosef Bacik 			 bandwidth, 8);
15707e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_device_generation, struct btrfs_dev_item,
15807e81dc9SJosef Bacik 			 generation, 64);
15907e81dc9SJosef Bacik 
btrfs_device_uuid(struct btrfs_dev_item * d)16007e81dc9SJosef Bacik static inline unsigned long btrfs_device_uuid(struct btrfs_dev_item *d)
16107e81dc9SJosef Bacik {
16207e81dc9SJosef Bacik 	return (unsigned long)d + offsetof(struct btrfs_dev_item, uuid);
16307e81dc9SJosef Bacik }
16407e81dc9SJosef Bacik 
btrfs_device_fsid(struct btrfs_dev_item * d)16507e81dc9SJosef Bacik static inline unsigned long btrfs_device_fsid(struct btrfs_dev_item *d)
16607e81dc9SJosef Bacik {
16707e81dc9SJosef Bacik 	return (unsigned long)d + offsetof(struct btrfs_dev_item, fsid);
16807e81dc9SJosef Bacik }
16907e81dc9SJosef Bacik 
17007e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(chunk_length, struct btrfs_chunk, length, 64);
17107e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(chunk_owner, struct btrfs_chunk, owner, 64);
17207e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(chunk_stripe_len, struct btrfs_chunk, stripe_len, 64);
17307e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(chunk_io_align, struct btrfs_chunk, io_align, 32);
17407e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(chunk_io_width, struct btrfs_chunk, io_width, 32);
17507e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(chunk_sector_size, struct btrfs_chunk, sector_size, 32);
17607e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(chunk_type, struct btrfs_chunk, type, 64);
17707e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(chunk_num_stripes, struct btrfs_chunk, num_stripes, 16);
17807e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(chunk_sub_stripes, struct btrfs_chunk, sub_stripes, 16);
17907e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(stripe_devid, struct btrfs_stripe, devid, 64);
18007e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(stripe_offset, struct btrfs_stripe, offset, 64);
18107e81dc9SJosef Bacik 
btrfs_stripe_dev_uuid(struct btrfs_stripe * s)18207e81dc9SJosef Bacik static inline char *btrfs_stripe_dev_uuid(struct btrfs_stripe *s)
18307e81dc9SJosef Bacik {
18407e81dc9SJosef Bacik 	return (char *)s + offsetof(struct btrfs_stripe, dev_uuid);
18507e81dc9SJosef Bacik }
18607e81dc9SJosef Bacik 
18707e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_chunk_length, struct btrfs_chunk, length, 64);
18807e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_chunk_owner, struct btrfs_chunk, owner, 64);
18907e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_chunk_stripe_len, struct btrfs_chunk,
19007e81dc9SJosef Bacik 			 stripe_len, 64);
19107e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_chunk_io_align, struct btrfs_chunk, io_align, 32);
19207e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_chunk_io_width, struct btrfs_chunk, io_width, 32);
19307e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_chunk_sector_size, struct btrfs_chunk,
19407e81dc9SJosef Bacik 			 sector_size, 32);
19507e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_chunk_type, struct btrfs_chunk, type, 64);
19607e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_chunk_num_stripes, struct btrfs_chunk,
19707e81dc9SJosef Bacik 			 num_stripes, 16);
19807e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_chunk_sub_stripes, struct btrfs_chunk,
19907e81dc9SJosef Bacik 			 sub_stripes, 16);
20007e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_stripe_devid, struct btrfs_stripe, devid, 64);
20107e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_stripe_offset, struct btrfs_stripe, offset, 64);
20207e81dc9SJosef Bacik 
btrfs_stripe_nr(struct btrfs_chunk * c,int nr)20307e81dc9SJosef Bacik static inline struct btrfs_stripe *btrfs_stripe_nr(struct btrfs_chunk *c, int nr)
20407e81dc9SJosef Bacik {
20507e81dc9SJosef Bacik 	unsigned long offset = (unsigned long)c;
20607e81dc9SJosef Bacik 
20707e81dc9SJosef Bacik 	offset += offsetof(struct btrfs_chunk, stripe);
20807e81dc9SJosef Bacik 	offset += nr * sizeof(struct btrfs_stripe);
20907e81dc9SJosef Bacik 	return (struct btrfs_stripe *)offset;
21007e81dc9SJosef Bacik }
21107e81dc9SJosef Bacik 
btrfs_stripe_dev_uuid_nr(struct btrfs_chunk * c,int nr)21207e81dc9SJosef Bacik static inline char *btrfs_stripe_dev_uuid_nr(struct btrfs_chunk *c, int nr)
21307e81dc9SJosef Bacik {
21407e81dc9SJosef Bacik 	return btrfs_stripe_dev_uuid(btrfs_stripe_nr(c, nr));
21507e81dc9SJosef Bacik }
21607e81dc9SJosef Bacik 
btrfs_stripe_offset_nr(const struct extent_buffer * eb,struct btrfs_chunk * c,int nr)21707e81dc9SJosef Bacik static inline u64 btrfs_stripe_offset_nr(const struct extent_buffer *eb,
21807e81dc9SJosef Bacik 					 struct btrfs_chunk *c, int nr)
21907e81dc9SJosef Bacik {
22007e81dc9SJosef Bacik 	return btrfs_stripe_offset(eb, btrfs_stripe_nr(c, nr));
22107e81dc9SJosef Bacik }
22207e81dc9SJosef Bacik 
btrfs_set_stripe_offset_nr(struct extent_buffer * eb,struct btrfs_chunk * c,int nr,u64 val)223054056bdSJosef Bacik static inline void btrfs_set_stripe_offset_nr(struct extent_buffer *eb,
224054056bdSJosef Bacik 					      struct btrfs_chunk *c, int nr,
225054056bdSJosef Bacik 					      u64 val)
226054056bdSJosef Bacik {
227054056bdSJosef Bacik 	btrfs_set_stripe_offset(eb, btrfs_stripe_nr(c, nr), val);
228054056bdSJosef Bacik }
229054056bdSJosef Bacik 
btrfs_stripe_devid_nr(const struct extent_buffer * eb,struct btrfs_chunk * c,int nr)23007e81dc9SJosef Bacik static inline u64 btrfs_stripe_devid_nr(const struct extent_buffer *eb,
23107e81dc9SJosef Bacik 					 struct btrfs_chunk *c, int nr)
23207e81dc9SJosef Bacik {
23307e81dc9SJosef Bacik 	return btrfs_stripe_devid(eb, btrfs_stripe_nr(c, nr));
23407e81dc9SJosef Bacik }
23507e81dc9SJosef Bacik 
btrfs_set_stripe_devid_nr(struct extent_buffer * eb,struct btrfs_chunk * c,int nr,u64 val)236054056bdSJosef Bacik static inline void btrfs_set_stripe_devid_nr(struct extent_buffer *eb,
237054056bdSJosef Bacik 					     struct btrfs_chunk *c, int nr,
238054056bdSJosef Bacik 					     u64 val)
239054056bdSJosef Bacik {
240054056bdSJosef Bacik 	btrfs_set_stripe_devid(eb, btrfs_stripe_nr(c, nr), val);
241054056bdSJosef Bacik }
242054056bdSJosef Bacik 
24307e81dc9SJosef Bacik /* struct btrfs_block_group_item */
24407e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_block_group_used, struct btrfs_block_group_item,
24507e81dc9SJosef Bacik 			 used, 64);
24607e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(block_group_used, struct btrfs_block_group_item, used, 64);
24707e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_block_group_chunk_objectid,
24807e81dc9SJosef Bacik 			struct btrfs_block_group_item, chunk_objectid, 64);
24907e81dc9SJosef Bacik 
25007e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(block_group_chunk_objectid,
25107e81dc9SJosef Bacik 		   struct btrfs_block_group_item, chunk_objectid, 64);
25207e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(block_group_flags, struct btrfs_block_group_item, flags, 64);
25307e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_block_group_flags,
25407e81dc9SJosef Bacik 			struct btrfs_block_group_item, flags, 64);
25507e81dc9SJosef Bacik 
25607e81dc9SJosef Bacik /* struct btrfs_free_space_info */
25707e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(free_space_extent_count, struct btrfs_free_space_info,
25807e81dc9SJosef Bacik 		   extent_count, 32);
25907e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(free_space_flags, struct btrfs_free_space_info, flags, 32);
26007e81dc9SJosef Bacik 
26107e81dc9SJosef Bacik /* struct btrfs_inode_ref */
26207e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(inode_ref_name_len, struct btrfs_inode_ref, name_len, 16);
26307e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(inode_ref_index, struct btrfs_inode_ref, index, 64);
264054056bdSJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_inode_ref_name_len, struct btrfs_inode_ref, name_len, 16);
265054056bdSJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_inode_ref_index, struct btrfs_inode_ref, index, 64);
26607e81dc9SJosef Bacik 
26707e81dc9SJosef Bacik /* struct btrfs_inode_extref */
26807e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(inode_extref_parent, struct btrfs_inode_extref,
26907e81dc9SJosef Bacik 		   parent_objectid, 64);
27007e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(inode_extref_name_len, struct btrfs_inode_extref,
27107e81dc9SJosef Bacik 		   name_len, 16);
27207e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(inode_extref_index, struct btrfs_inode_extref, index, 64);
27307e81dc9SJosef Bacik 
27407e81dc9SJosef Bacik /* struct btrfs_inode_item */
27507e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(inode_generation, struct btrfs_inode_item, generation, 64);
27607e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(inode_sequence, struct btrfs_inode_item, sequence, 64);
27707e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(inode_transid, struct btrfs_inode_item, transid, 64);
27807e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(inode_size, struct btrfs_inode_item, size, 64);
27907e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(inode_nbytes, struct btrfs_inode_item, nbytes, 64);
28007e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(inode_block_group, struct btrfs_inode_item, block_group, 64);
28107e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
28207e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
28307e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
28407e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
28507e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
28607e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
28707e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_inode_generation, struct btrfs_inode_item,
28807e81dc9SJosef Bacik 			 generation, 64);
28907e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_inode_sequence, struct btrfs_inode_item,
29007e81dc9SJosef Bacik 			 sequence, 64);
29107e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_inode_transid, struct btrfs_inode_item,
29207e81dc9SJosef Bacik 			 transid, 64);
29307e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_inode_size, struct btrfs_inode_item, size, 64);
29407e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_inode_nbytes, struct btrfs_inode_item, nbytes, 64);
29507e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_inode_block_group, struct btrfs_inode_item,
29607e81dc9SJosef Bacik 			 block_group, 64);
29707e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_inode_nlink, struct btrfs_inode_item, nlink, 32);
29807e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_inode_uid, struct btrfs_inode_item, uid, 32);
29907e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_inode_gid, struct btrfs_inode_item, gid, 32);
30007e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_inode_mode, struct btrfs_inode_item, mode, 32);
30107e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_inode_rdev, struct btrfs_inode_item, rdev, 64);
30207e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_inode_flags, struct btrfs_inode_item, flags, 64);
30307e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(timespec_sec, struct btrfs_timespec, sec, 64);
30407e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(timespec_nsec, struct btrfs_timespec, nsec, 32);
30507e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_timespec_sec, struct btrfs_timespec, sec, 64);
30607e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_timespec_nsec, struct btrfs_timespec, nsec, 32);
30707e81dc9SJosef Bacik 
30807e81dc9SJosef Bacik /* struct btrfs_dev_extent */
30907e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(dev_extent_chunk_tree, struct btrfs_dev_extent, chunk_tree, 64);
31007e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(dev_extent_chunk_objectid, struct btrfs_dev_extent,
31107e81dc9SJosef Bacik 		   chunk_objectid, 64);
31207e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(dev_extent_chunk_offset, struct btrfs_dev_extent,
31307e81dc9SJosef Bacik 		   chunk_offset, 64);
31407e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(dev_extent_length, struct btrfs_dev_extent, length, 64);
315054056bdSJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_dev_extent_chunk_tree, struct btrfs_dev_extent,
316054056bdSJosef Bacik 			 chunk_tree, 64);
317054056bdSJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_dev_extent_chunk_objectid, struct btrfs_dev_extent,
318054056bdSJosef Bacik 			 chunk_objectid, 64);
319054056bdSJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_dev_extent_chunk_offset, struct btrfs_dev_extent,
320054056bdSJosef Bacik 			 chunk_offset, 64);
321054056bdSJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_dev_extent_length, struct btrfs_dev_extent, length, 64);
322054056bdSJosef Bacik 
32307e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(extent_refs, struct btrfs_extent_item, refs, 64);
32407e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(extent_generation, struct btrfs_extent_item, generation, 64);
32507e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(extent_flags, struct btrfs_extent_item, flags, 64);
32607e81dc9SJosef Bacik 
32707e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(tree_block_level, struct btrfs_tree_block_info, level, 8);
32807e81dc9SJosef Bacik 
btrfs_tree_block_key(const struct extent_buffer * eb,struct btrfs_tree_block_info * item,struct btrfs_disk_key * key)32907e81dc9SJosef Bacik static inline void btrfs_tree_block_key(const struct extent_buffer *eb,
33007e81dc9SJosef Bacik 					struct btrfs_tree_block_info *item,
33107e81dc9SJosef Bacik 					struct btrfs_disk_key *key)
33207e81dc9SJosef Bacik {
33307e81dc9SJosef Bacik 	read_eb_member(eb, item, struct btrfs_tree_block_info, key, key);
33407e81dc9SJosef Bacik }
33507e81dc9SJosef Bacik 
btrfs_set_tree_block_key(const struct extent_buffer * eb,struct btrfs_tree_block_info * item,struct btrfs_disk_key * key)33607e81dc9SJosef Bacik static inline void btrfs_set_tree_block_key(const struct extent_buffer *eb,
33707e81dc9SJosef Bacik 					    struct btrfs_tree_block_info *item,
33807e81dc9SJosef Bacik 					    struct btrfs_disk_key *key)
33907e81dc9SJosef Bacik {
34007e81dc9SJosef Bacik 	write_eb_member(eb, item, struct btrfs_tree_block_info, key, key);
34107e81dc9SJosef Bacik }
34207e81dc9SJosef Bacik 
34307e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(extent_data_ref_root, struct btrfs_extent_data_ref, root, 64);
34407e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(extent_data_ref_objectid, struct btrfs_extent_data_ref,
34507e81dc9SJosef Bacik 		   objectid, 64);
34607e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(extent_data_ref_offset, struct btrfs_extent_data_ref,
34707e81dc9SJosef Bacik 		   offset, 64);
34807e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(extent_data_ref_count, struct btrfs_extent_data_ref, count, 32);
34907e81dc9SJosef Bacik 
35007e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(shared_data_ref_count, struct btrfs_shared_data_ref, count, 32);
35107e81dc9SJosef Bacik 
35207e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(extent_inline_ref_type, struct btrfs_extent_inline_ref,
35307e81dc9SJosef Bacik 		   type, 8);
35407e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(extent_inline_ref_offset, struct btrfs_extent_inline_ref,
35507e81dc9SJosef Bacik 		   offset, 64);
35607e81dc9SJosef Bacik 
btrfs_extent_inline_ref_size(int type)35707e81dc9SJosef Bacik static inline u32 btrfs_extent_inline_ref_size(int type)
35807e81dc9SJosef Bacik {
35907e81dc9SJosef Bacik 	if (type == BTRFS_TREE_BLOCK_REF_KEY ||
36007e81dc9SJosef Bacik 	    type == BTRFS_SHARED_BLOCK_REF_KEY)
36107e81dc9SJosef Bacik 		return sizeof(struct btrfs_extent_inline_ref);
36207e81dc9SJosef Bacik 	if (type == BTRFS_SHARED_DATA_REF_KEY)
36307e81dc9SJosef Bacik 		return sizeof(struct btrfs_shared_data_ref) +
36407e81dc9SJosef Bacik 		       sizeof(struct btrfs_extent_inline_ref);
36507e81dc9SJosef Bacik 	if (type == BTRFS_EXTENT_DATA_REF_KEY)
36607e81dc9SJosef Bacik 		return sizeof(struct btrfs_extent_data_ref) +
36707e81dc9SJosef Bacik 		       offsetof(struct btrfs_extent_inline_ref, offset);
36807e81dc9SJosef Bacik 	return 0;
36907e81dc9SJosef Bacik }
37007e81dc9SJosef Bacik 
37107e81dc9SJosef Bacik /* struct btrfs_node */
37207e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(key_blockptr, struct btrfs_key_ptr, blockptr, 64);
37307e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(key_generation, struct btrfs_key_ptr, generation, 64);
37407e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_key_blockptr, struct btrfs_key_ptr, blockptr, 64);
37507e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_key_generation, struct btrfs_key_ptr,
37607e81dc9SJosef Bacik 			 generation, 64);
37707e81dc9SJosef Bacik 
btrfs_node_blockptr(const struct extent_buffer * eb,int nr)37807e81dc9SJosef Bacik static inline u64 btrfs_node_blockptr(const struct extent_buffer *eb, int nr)
37907e81dc9SJosef Bacik {
38007e81dc9SJosef Bacik 	unsigned long ptr;
38107e81dc9SJosef Bacik 
38207e81dc9SJosef Bacik 	ptr = offsetof(struct btrfs_node, ptrs) +
38307e81dc9SJosef Bacik 		sizeof(struct btrfs_key_ptr) * nr;
38407e81dc9SJosef Bacik 	return btrfs_key_blockptr(eb, (struct btrfs_key_ptr *)ptr);
38507e81dc9SJosef Bacik }
38607e81dc9SJosef Bacik 
btrfs_set_node_blockptr(const struct extent_buffer * eb,int nr,u64 val)38707e81dc9SJosef Bacik static inline void btrfs_set_node_blockptr(const struct extent_buffer *eb,
38807e81dc9SJosef Bacik 					   int nr, u64 val)
38907e81dc9SJosef Bacik {
39007e81dc9SJosef Bacik 	unsigned long ptr;
39107e81dc9SJosef Bacik 
39207e81dc9SJosef Bacik 	ptr = offsetof(struct btrfs_node, ptrs) +
39307e81dc9SJosef Bacik 		sizeof(struct btrfs_key_ptr) * nr;
39407e81dc9SJosef Bacik 	btrfs_set_key_blockptr(eb, (struct btrfs_key_ptr *)ptr, val);
39507e81dc9SJosef Bacik }
39607e81dc9SJosef Bacik 
btrfs_node_ptr_generation(const struct extent_buffer * eb,int nr)39707e81dc9SJosef Bacik static inline u64 btrfs_node_ptr_generation(const struct extent_buffer *eb, int nr)
39807e81dc9SJosef Bacik {
39907e81dc9SJosef Bacik 	unsigned long ptr;
40007e81dc9SJosef Bacik 
40107e81dc9SJosef Bacik 	ptr = offsetof(struct btrfs_node, ptrs) +
40207e81dc9SJosef Bacik 		sizeof(struct btrfs_key_ptr) * nr;
40307e81dc9SJosef Bacik 	return btrfs_key_generation(eb, (struct btrfs_key_ptr *)ptr);
40407e81dc9SJosef Bacik }
40507e81dc9SJosef Bacik 
btrfs_set_node_ptr_generation(const struct extent_buffer * eb,int nr,u64 val)40607e81dc9SJosef Bacik static inline void btrfs_set_node_ptr_generation(const struct extent_buffer *eb,
40707e81dc9SJosef Bacik 						 int nr, u64 val)
40807e81dc9SJosef Bacik {
40907e81dc9SJosef Bacik 	unsigned long ptr;
41007e81dc9SJosef Bacik 
41107e81dc9SJosef Bacik 	ptr = offsetof(struct btrfs_node, ptrs) +
41207e81dc9SJosef Bacik 		sizeof(struct btrfs_key_ptr) * nr;
41307e81dc9SJosef Bacik 	btrfs_set_key_generation(eb, (struct btrfs_key_ptr *)ptr, val);
41407e81dc9SJosef Bacik }
41507e81dc9SJosef Bacik 
btrfs_node_key_ptr_offset(const struct extent_buffer * eb,int nr)416e23efd8eSJosef Bacik static inline unsigned long btrfs_node_key_ptr_offset(const struct extent_buffer *eb, int nr)
41707e81dc9SJosef Bacik {
41807e81dc9SJosef Bacik 	return offsetof(struct btrfs_node, ptrs) +
41907e81dc9SJosef Bacik 		sizeof(struct btrfs_key_ptr) * nr;
42007e81dc9SJosef Bacik }
42107e81dc9SJosef Bacik 
42207e81dc9SJosef Bacik void btrfs_node_key(const struct extent_buffer *eb,
42307e81dc9SJosef Bacik 		    struct btrfs_disk_key *disk_key, int nr);
42407e81dc9SJosef Bacik 
btrfs_set_node_key(const struct extent_buffer * eb,struct btrfs_disk_key * disk_key,int nr)42507e81dc9SJosef Bacik static inline void btrfs_set_node_key(const struct extent_buffer *eb,
42607e81dc9SJosef Bacik 				      struct btrfs_disk_key *disk_key, int nr)
42707e81dc9SJosef Bacik {
42807e81dc9SJosef Bacik 	unsigned long ptr;
42907e81dc9SJosef Bacik 
430e23efd8eSJosef Bacik 	ptr = btrfs_node_key_ptr_offset(eb, nr);
43107e81dc9SJosef Bacik 	write_eb_member(eb, (struct btrfs_key_ptr *)ptr,
43207e81dc9SJosef Bacik 		        struct btrfs_key_ptr, key, disk_key);
43307e81dc9SJosef Bacik }
43407e81dc9SJosef Bacik 
43507e81dc9SJosef Bacik /* struct btrfs_item */
43607e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(raw_item_offset, struct btrfs_item, offset, 32);
43707e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(raw_item_size, struct btrfs_item, size, 32);
43807e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_item_offset, struct btrfs_item, offset, 32);
43907e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_item_size, struct btrfs_item, size, 32);
44007e81dc9SJosef Bacik 
btrfs_item_nr_offset(const struct extent_buffer * eb,int nr)44142c9419aSJosef Bacik static inline unsigned long btrfs_item_nr_offset(const struct extent_buffer *eb, int nr)
44207e81dc9SJosef Bacik {
44307e81dc9SJosef Bacik 	return offsetof(struct btrfs_leaf, items) +
44407e81dc9SJosef Bacik 		sizeof(struct btrfs_item) * nr;
44507e81dc9SJosef Bacik }
44607e81dc9SJosef Bacik 
btrfs_item_nr(const struct extent_buffer * eb,int nr)44742c9419aSJosef Bacik static inline struct btrfs_item *btrfs_item_nr(const struct extent_buffer *eb, int nr)
44807e81dc9SJosef Bacik {
44942c9419aSJosef Bacik 	return (struct btrfs_item *)btrfs_item_nr_offset(eb, nr);
45007e81dc9SJosef Bacik }
45107e81dc9SJosef Bacik 
45207e81dc9SJosef Bacik #define BTRFS_ITEM_SETGET_FUNCS(member)						\
45307e81dc9SJosef Bacik static inline u32 btrfs_item_##member(const struct extent_buffer *eb, int slot)	\
45407e81dc9SJosef Bacik {										\
45542c9419aSJosef Bacik 	return btrfs_raw_item_##member(eb, btrfs_item_nr(eb, slot));		\
45607e81dc9SJosef Bacik }										\
45707e81dc9SJosef Bacik static inline void btrfs_set_item_##member(const struct extent_buffer *eb,	\
45807e81dc9SJosef Bacik 					   int slot, u32 val)			\
45907e81dc9SJosef Bacik {										\
46042c9419aSJosef Bacik 	btrfs_set_raw_item_##member(eb, btrfs_item_nr(eb, slot), val);		\
46107e81dc9SJosef Bacik }										\
46207e81dc9SJosef Bacik static inline u32 btrfs_token_item_##member(struct btrfs_map_token *token,	\
46307e81dc9SJosef Bacik 					    int slot)				\
46407e81dc9SJosef Bacik {										\
46542c9419aSJosef Bacik 	struct btrfs_item *item = btrfs_item_nr(token->eb, slot);		\
46607e81dc9SJosef Bacik 	return btrfs_token_raw_item_##member(token, item);			\
46707e81dc9SJosef Bacik }										\
46807e81dc9SJosef Bacik static inline void btrfs_set_token_item_##member(struct btrfs_map_token *token,	\
46907e81dc9SJosef Bacik 						 int slot, u32 val)		\
47007e81dc9SJosef Bacik {										\
47142c9419aSJosef Bacik 	struct btrfs_item *item = btrfs_item_nr(token->eb, slot);		\
47207e81dc9SJosef Bacik 	btrfs_set_token_raw_item_##member(token, item, val);			\
47307e81dc9SJosef Bacik }
47407e81dc9SJosef Bacik 
47507e81dc9SJosef Bacik BTRFS_ITEM_SETGET_FUNCS(offset)
47607e81dc9SJosef Bacik BTRFS_ITEM_SETGET_FUNCS(size);
47707e81dc9SJosef Bacik 
btrfs_item_data_end(const struct extent_buffer * eb,int nr)47807e81dc9SJosef Bacik static inline u32 btrfs_item_data_end(const struct extent_buffer *eb, int nr)
47907e81dc9SJosef Bacik {
48007e81dc9SJosef Bacik 	return btrfs_item_offset(eb, nr) + btrfs_item_size(eb, nr);
48107e81dc9SJosef Bacik }
48207e81dc9SJosef Bacik 
btrfs_item_key(const struct extent_buffer * eb,struct btrfs_disk_key * disk_key,int nr)48307e81dc9SJosef Bacik static inline void btrfs_item_key(const struct extent_buffer *eb,
48407e81dc9SJosef Bacik 			   struct btrfs_disk_key *disk_key, int nr)
48507e81dc9SJosef Bacik {
48642c9419aSJosef Bacik 	struct btrfs_item *item = btrfs_item_nr(eb, nr);
48707e81dc9SJosef Bacik 
48807e81dc9SJosef Bacik 	read_eb_member(eb, item, struct btrfs_item, key, disk_key);
48907e81dc9SJosef Bacik }
49007e81dc9SJosef Bacik 
btrfs_set_item_key(struct extent_buffer * eb,struct btrfs_disk_key * disk_key,int nr)49107e81dc9SJosef Bacik static inline void btrfs_set_item_key(struct extent_buffer *eb,
49207e81dc9SJosef Bacik 				      struct btrfs_disk_key *disk_key, int nr)
49307e81dc9SJosef Bacik {
49442c9419aSJosef Bacik 	struct btrfs_item *item = btrfs_item_nr(eb, nr);
49507e81dc9SJosef Bacik 
49607e81dc9SJosef Bacik 	write_eb_member(eb, item, struct btrfs_item, key, disk_key);
49707e81dc9SJosef Bacik }
49807e81dc9SJosef Bacik 
49907e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(dir_log_end, struct btrfs_dir_log_item, end, 64);
50007e81dc9SJosef Bacik 
50107e81dc9SJosef Bacik /* struct btrfs_root_ref */
50207e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(root_ref_dirid, struct btrfs_root_ref, dirid, 64);
50307e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(root_ref_sequence, struct btrfs_root_ref, sequence, 64);
50407e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(root_ref_name_len, struct btrfs_root_ref, name_len, 16);
505054056bdSJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_root_ref_dirid, struct btrfs_root_ref, dirid, 64);
506054056bdSJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_root_ref_sequence, struct btrfs_root_ref, sequence, 64);
507054056bdSJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_root_ref_name_len, struct btrfs_root_ref, name_len, 16);
50807e81dc9SJosef Bacik 
50907e81dc9SJosef Bacik /* struct btrfs_dir_item */
51007e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(dir_data_len, struct btrfs_dir_item, data_len, 16);
51194a48aefSOmar Sandoval BTRFS_SETGET_FUNCS(dir_flags, struct btrfs_dir_item, type, 8);
51207e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(dir_name_len, struct btrfs_dir_item, name_len, 16);
51307e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(dir_transid, struct btrfs_dir_item, transid, 64);
51494a48aefSOmar Sandoval BTRFS_SETGET_STACK_FUNCS(stack_dir_flags, struct btrfs_dir_item, type, 8);
51507e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_dir_data_len, struct btrfs_dir_item, data_len, 16);
51607e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_dir_name_len, struct btrfs_dir_item, name_len, 16);
51707e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_dir_transid, struct btrfs_dir_item, transid, 64);
51807e81dc9SJosef Bacik 
btrfs_dir_ftype(const struct extent_buffer * eb,const struct btrfs_dir_item * item)51994a48aefSOmar Sandoval static inline u8 btrfs_dir_ftype(const struct extent_buffer *eb,
52094a48aefSOmar Sandoval 				 const struct btrfs_dir_item *item)
52194a48aefSOmar Sandoval {
52294a48aefSOmar Sandoval 	return btrfs_dir_flags_to_ftype(btrfs_dir_flags(eb, item));
52394a48aefSOmar Sandoval }
52494a48aefSOmar Sandoval 
btrfs_stack_dir_ftype(const struct btrfs_dir_item * item)52594a48aefSOmar Sandoval static inline u8 btrfs_stack_dir_ftype(const struct btrfs_dir_item *item)
52694a48aefSOmar Sandoval {
52794a48aefSOmar Sandoval 	return btrfs_dir_flags_to_ftype(btrfs_stack_dir_flags(item));
52894a48aefSOmar Sandoval }
52994a48aefSOmar Sandoval 
btrfs_dir_item_key(const struct extent_buffer * eb,const struct btrfs_dir_item * item,struct btrfs_disk_key * key)53007e81dc9SJosef Bacik static inline void btrfs_dir_item_key(const struct extent_buffer *eb,
53107e81dc9SJosef Bacik 				      const struct btrfs_dir_item *item,
53207e81dc9SJosef Bacik 				      struct btrfs_disk_key *key)
53307e81dc9SJosef Bacik {
53407e81dc9SJosef Bacik 	read_eb_member(eb, item, struct btrfs_dir_item, location, key);
53507e81dc9SJosef Bacik }
53607e81dc9SJosef Bacik 
btrfs_set_dir_item_key(struct extent_buffer * eb,struct btrfs_dir_item * item,const struct btrfs_disk_key * key)53707e81dc9SJosef Bacik static inline void btrfs_set_dir_item_key(struct extent_buffer *eb,
53807e81dc9SJosef Bacik 					  struct btrfs_dir_item *item,
53907e81dc9SJosef Bacik 					  const struct btrfs_disk_key *key)
54007e81dc9SJosef Bacik {
54107e81dc9SJosef Bacik 	write_eb_member(eb, item, struct btrfs_dir_item, location, key);
54207e81dc9SJosef Bacik }
54307e81dc9SJosef Bacik 
54407e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(free_space_entries, struct btrfs_free_space_header,
54507e81dc9SJosef Bacik 		   num_entries, 64);
54607e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(free_space_bitmaps, struct btrfs_free_space_header,
54707e81dc9SJosef Bacik 		   num_bitmaps, 64);
54807e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(free_space_generation, struct btrfs_free_space_header,
54907e81dc9SJosef Bacik 		   generation, 64);
55007e81dc9SJosef Bacik 
btrfs_free_space_key(const struct extent_buffer * eb,const struct btrfs_free_space_header * h,struct btrfs_disk_key * key)55107e81dc9SJosef Bacik static inline void btrfs_free_space_key(const struct extent_buffer *eb,
55207e81dc9SJosef Bacik 					const struct btrfs_free_space_header *h,
55307e81dc9SJosef Bacik 					struct btrfs_disk_key *key)
55407e81dc9SJosef Bacik {
55507e81dc9SJosef Bacik 	read_eb_member(eb, h, struct btrfs_free_space_header, location, key);
55607e81dc9SJosef Bacik }
55707e81dc9SJosef Bacik 
btrfs_set_free_space_key(struct extent_buffer * eb,struct btrfs_free_space_header * h,const struct btrfs_disk_key * key)55807e81dc9SJosef Bacik static inline void btrfs_set_free_space_key(struct extent_buffer *eb,
55907e81dc9SJosef Bacik 					    struct btrfs_free_space_header *h,
56007e81dc9SJosef Bacik 					    const struct btrfs_disk_key *key)
56107e81dc9SJosef Bacik {
56207e81dc9SJosef Bacik 	write_eb_member(eb, h, struct btrfs_free_space_header, location, key);
56307e81dc9SJosef Bacik }
56407e81dc9SJosef Bacik 
56507e81dc9SJosef Bacik /* struct btrfs_disk_key */
56607e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(disk_key_objectid, struct btrfs_disk_key, objectid, 64);
56707e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(disk_key_offset, struct btrfs_disk_key, offset, 64);
56807e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(disk_key_type, struct btrfs_disk_key, type, 8);
56907e81dc9SJosef Bacik 
57007e81dc9SJosef Bacik #ifdef __LITTLE_ENDIAN
57107e81dc9SJosef Bacik 
57207e81dc9SJosef Bacik /*
57307e81dc9SJosef Bacik  * Optimized helpers for little-endian architectures where CPU and on-disk
57407e81dc9SJosef Bacik  * structures have the same endianness and we can skip conversions.
57507e81dc9SJosef Bacik  */
57607e81dc9SJosef Bacik 
btrfs_disk_key_to_cpu(struct btrfs_key * cpu_key,const struct btrfs_disk_key * disk_key)57707e81dc9SJosef Bacik static inline void btrfs_disk_key_to_cpu(struct btrfs_key *cpu_key,
57807e81dc9SJosef Bacik 					 const struct btrfs_disk_key *disk_key)
57907e81dc9SJosef Bacik {
58007e81dc9SJosef Bacik 	memcpy(cpu_key, disk_key, sizeof(struct btrfs_key));
58107e81dc9SJosef Bacik }
58207e81dc9SJosef Bacik 
btrfs_cpu_key_to_disk(struct btrfs_disk_key * disk_key,const struct btrfs_key * cpu_key)58307e81dc9SJosef Bacik static inline void btrfs_cpu_key_to_disk(struct btrfs_disk_key *disk_key,
58407e81dc9SJosef Bacik 					 const struct btrfs_key *cpu_key)
58507e81dc9SJosef Bacik {
58607e81dc9SJosef Bacik 	memcpy(disk_key, cpu_key, sizeof(struct btrfs_key));
58707e81dc9SJosef Bacik }
58807e81dc9SJosef Bacik 
btrfs_node_key_to_cpu(const struct extent_buffer * eb,struct btrfs_key * cpu_key,int nr)58907e81dc9SJosef Bacik static inline void btrfs_node_key_to_cpu(const struct extent_buffer *eb,
59007e81dc9SJosef Bacik 					 struct btrfs_key *cpu_key, int nr)
59107e81dc9SJosef Bacik {
59207e81dc9SJosef Bacik 	struct btrfs_disk_key *disk_key = (struct btrfs_disk_key *)cpu_key;
59307e81dc9SJosef Bacik 
59407e81dc9SJosef Bacik 	btrfs_node_key(eb, disk_key, nr);
59507e81dc9SJosef Bacik }
59607e81dc9SJosef Bacik 
btrfs_item_key_to_cpu(const struct extent_buffer * eb,struct btrfs_key * cpu_key,int nr)59707e81dc9SJosef Bacik static inline void btrfs_item_key_to_cpu(const struct extent_buffer *eb,
59807e81dc9SJosef Bacik 					 struct btrfs_key *cpu_key, int nr)
59907e81dc9SJosef Bacik {
60007e81dc9SJosef Bacik 	struct btrfs_disk_key *disk_key = (struct btrfs_disk_key *)cpu_key;
60107e81dc9SJosef Bacik 
60207e81dc9SJosef Bacik 	btrfs_item_key(eb, disk_key, nr);
60307e81dc9SJosef Bacik }
60407e81dc9SJosef Bacik 
btrfs_dir_item_key_to_cpu(const struct extent_buffer * eb,const struct btrfs_dir_item * item,struct btrfs_key * cpu_key)60507e81dc9SJosef Bacik static inline void btrfs_dir_item_key_to_cpu(const struct extent_buffer *eb,
60607e81dc9SJosef Bacik 					     const struct btrfs_dir_item *item,
60707e81dc9SJosef Bacik 					     struct btrfs_key *cpu_key)
60807e81dc9SJosef Bacik {
60907e81dc9SJosef Bacik 	struct btrfs_disk_key *disk_key = (struct btrfs_disk_key *)cpu_key;
61007e81dc9SJosef Bacik 
61107e81dc9SJosef Bacik 	btrfs_dir_item_key(eb, item, disk_key);
61207e81dc9SJosef Bacik }
61307e81dc9SJosef Bacik 
61407e81dc9SJosef Bacik #else
61507e81dc9SJosef Bacik 
btrfs_disk_key_to_cpu(struct btrfs_key * cpu,const struct btrfs_disk_key * disk)61607e81dc9SJosef Bacik static inline void btrfs_disk_key_to_cpu(struct btrfs_key *cpu,
61707e81dc9SJosef Bacik 					 const struct btrfs_disk_key *disk)
61807e81dc9SJosef Bacik {
61907e81dc9SJosef Bacik 	cpu->offset = le64_to_cpu(disk->offset);
62007e81dc9SJosef Bacik 	cpu->type = disk->type;
62107e81dc9SJosef Bacik 	cpu->objectid = le64_to_cpu(disk->objectid);
62207e81dc9SJosef Bacik }
62307e81dc9SJosef Bacik 
btrfs_cpu_key_to_disk(struct btrfs_disk_key * disk,const struct btrfs_key * cpu)62407e81dc9SJosef Bacik static inline void btrfs_cpu_key_to_disk(struct btrfs_disk_key *disk,
62507e81dc9SJosef Bacik 					 const struct btrfs_key *cpu)
62607e81dc9SJosef Bacik {
62707e81dc9SJosef Bacik 	disk->offset = cpu_to_le64(cpu->offset);
62807e81dc9SJosef Bacik 	disk->type = cpu->type;
62907e81dc9SJosef Bacik 	disk->objectid = cpu_to_le64(cpu->objectid);
63007e81dc9SJosef Bacik }
63107e81dc9SJosef Bacik 
btrfs_node_key_to_cpu(const struct extent_buffer * eb,struct btrfs_key * key,int nr)63207e81dc9SJosef Bacik static inline void btrfs_node_key_to_cpu(const struct extent_buffer *eb,
63307e81dc9SJosef Bacik 					 struct btrfs_key *key, int nr)
63407e81dc9SJosef Bacik {
63507e81dc9SJosef Bacik 	struct btrfs_disk_key disk_key;
63607e81dc9SJosef Bacik 
63707e81dc9SJosef Bacik 	btrfs_node_key(eb, &disk_key, nr);
63807e81dc9SJosef Bacik 	btrfs_disk_key_to_cpu(key, &disk_key);
63907e81dc9SJosef Bacik }
64007e81dc9SJosef Bacik 
btrfs_item_key_to_cpu(const struct extent_buffer * eb,struct btrfs_key * key,int nr)64107e81dc9SJosef Bacik static inline void btrfs_item_key_to_cpu(const struct extent_buffer *eb,
64207e81dc9SJosef Bacik 					 struct btrfs_key *key, int nr)
64307e81dc9SJosef Bacik {
64407e81dc9SJosef Bacik 	struct btrfs_disk_key disk_key;
64507e81dc9SJosef Bacik 
64607e81dc9SJosef Bacik 	btrfs_item_key(eb, &disk_key, nr);
64707e81dc9SJosef Bacik 	btrfs_disk_key_to_cpu(key, &disk_key);
64807e81dc9SJosef Bacik }
64907e81dc9SJosef Bacik 
btrfs_dir_item_key_to_cpu(const struct extent_buffer * eb,const struct btrfs_dir_item * item,struct btrfs_key * key)65007e81dc9SJosef Bacik static inline void btrfs_dir_item_key_to_cpu(const struct extent_buffer *eb,
65107e81dc9SJosef Bacik 					     const struct btrfs_dir_item *item,
65207e81dc9SJosef Bacik 					     struct btrfs_key *key)
65307e81dc9SJosef Bacik {
65407e81dc9SJosef Bacik 	struct btrfs_disk_key disk_key;
65507e81dc9SJosef Bacik 
65607e81dc9SJosef Bacik 	btrfs_dir_item_key(eb, item, &disk_key);
65707e81dc9SJosef Bacik 	btrfs_disk_key_to_cpu(key, &disk_key);
65807e81dc9SJosef Bacik }
65907e81dc9SJosef Bacik 
66007e81dc9SJosef Bacik #endif
66107e81dc9SJosef Bacik 
66207e81dc9SJosef Bacik /* struct btrfs_header */
66307e81dc9SJosef Bacik BTRFS_SETGET_HEADER_FUNCS(header_bytenr, struct btrfs_header, bytenr, 64);
66407e81dc9SJosef Bacik BTRFS_SETGET_HEADER_FUNCS(header_generation, struct btrfs_header, generation, 64);
66507e81dc9SJosef Bacik BTRFS_SETGET_HEADER_FUNCS(header_owner, struct btrfs_header, owner, 64);
66607e81dc9SJosef Bacik BTRFS_SETGET_HEADER_FUNCS(header_nritems, struct btrfs_header, nritems, 32);
66707e81dc9SJosef Bacik BTRFS_SETGET_HEADER_FUNCS(header_flags, struct btrfs_header, flags, 64);
66807e81dc9SJosef Bacik BTRFS_SETGET_HEADER_FUNCS(header_level, struct btrfs_header, level, 8);
66907e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_header_generation, struct btrfs_header,
67007e81dc9SJosef Bacik 			 generation, 64);
67107e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_header_owner, struct btrfs_header, owner, 64);
67207e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_header_nritems, struct btrfs_header, nritems, 32);
67307e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_header_bytenr, struct btrfs_header, bytenr, 64);
67407e81dc9SJosef Bacik 
btrfs_header_flag(const struct extent_buffer * eb,u64 flag)67507e81dc9SJosef Bacik static inline int btrfs_header_flag(const struct extent_buffer *eb, u64 flag)
67607e81dc9SJosef Bacik {
67707e81dc9SJosef Bacik 	return (btrfs_header_flags(eb) & flag) == flag;
67807e81dc9SJosef Bacik }
67907e81dc9SJosef Bacik 
btrfs_set_header_flag(struct extent_buffer * eb,u64 flag)68007e81dc9SJosef Bacik static inline void btrfs_set_header_flag(struct extent_buffer *eb, u64 flag)
68107e81dc9SJosef Bacik {
68207e81dc9SJosef Bacik 	u64 flags = btrfs_header_flags(eb);
68307e81dc9SJosef Bacik 
68407e81dc9SJosef Bacik 	btrfs_set_header_flags(eb, flags | flag);
68507e81dc9SJosef Bacik }
68607e81dc9SJosef Bacik 
btrfs_clear_header_flag(struct extent_buffer * eb,u64 flag)68707e81dc9SJosef Bacik static inline void btrfs_clear_header_flag(struct extent_buffer *eb, u64 flag)
68807e81dc9SJosef Bacik {
68907e81dc9SJosef Bacik 	u64 flags = btrfs_header_flags(eb);
69007e81dc9SJosef Bacik 
69107e81dc9SJosef Bacik 	btrfs_set_header_flags(eb, flags & ~flag);
69207e81dc9SJosef Bacik }
69307e81dc9SJosef Bacik 
btrfs_header_backref_rev(const struct extent_buffer * eb)69407e81dc9SJosef Bacik static inline int btrfs_header_backref_rev(const struct extent_buffer *eb)
69507e81dc9SJosef Bacik {
69607e81dc9SJosef Bacik 	u64 flags = btrfs_header_flags(eb);
69707e81dc9SJosef Bacik 
69807e81dc9SJosef Bacik 	return flags >> BTRFS_BACKREF_REV_SHIFT;
69907e81dc9SJosef Bacik }
70007e81dc9SJosef Bacik 
btrfs_set_header_backref_rev(struct extent_buffer * eb,int rev)70107e81dc9SJosef Bacik static inline void btrfs_set_header_backref_rev(struct extent_buffer *eb, int rev)
70207e81dc9SJosef Bacik {
70307e81dc9SJosef Bacik 	u64 flags = btrfs_header_flags(eb);
70407e81dc9SJosef Bacik 
70507e81dc9SJosef Bacik 	flags &= ~BTRFS_BACKREF_REV_MASK;
70607e81dc9SJosef Bacik 	flags |= (u64)rev << BTRFS_BACKREF_REV_SHIFT;
70707e81dc9SJosef Bacik 	btrfs_set_header_flags(eb, flags);
70807e81dc9SJosef Bacik }
70907e81dc9SJosef Bacik 
btrfs_is_leaf(const struct extent_buffer * eb)71007e81dc9SJosef Bacik static inline int btrfs_is_leaf(const struct extent_buffer *eb)
71107e81dc9SJosef Bacik {
71207e81dc9SJosef Bacik 	return btrfs_header_level(eb) == 0;
71307e81dc9SJosef Bacik }
71407e81dc9SJosef Bacik 
71507e81dc9SJosef Bacik /* struct btrfs_root_item */
71607e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(disk_root_generation, struct btrfs_root_item, generation, 64);
71707e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(disk_root_refs, struct btrfs_root_item, refs, 32);
71807e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(disk_root_bytenr, struct btrfs_root_item, bytenr, 64);
71907e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(disk_root_level, struct btrfs_root_item, level, 8);
72007e81dc9SJosef Bacik 
72107e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(root_generation, struct btrfs_root_item, generation, 64);
72207e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(root_bytenr, struct btrfs_root_item, bytenr, 64);
72307e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(root_drop_level, struct btrfs_root_item, drop_level, 8);
72407e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(root_level, struct btrfs_root_item, level, 8);
72507e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(root_dirid, struct btrfs_root_item, root_dirid, 64);
72607e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(root_refs, struct btrfs_root_item, refs, 32);
72707e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(root_flags, struct btrfs_root_item, flags, 64);
72807e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(root_used, struct btrfs_root_item, bytes_used, 64);
72907e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(root_limit, struct btrfs_root_item, byte_limit, 64);
73007e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(root_last_snapshot, struct btrfs_root_item,
73107e81dc9SJosef Bacik 			 last_snapshot, 64);
73207e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(root_generation_v2, struct btrfs_root_item,
73307e81dc9SJosef Bacik 			 generation_v2, 64);
73407e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(root_ctransid, struct btrfs_root_item, ctransid, 64);
73507e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(root_otransid, struct btrfs_root_item, otransid, 64);
73607e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(root_stransid, struct btrfs_root_item, stransid, 64);
73707e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(root_rtransid, struct btrfs_root_item, rtransid, 64);
73807e81dc9SJosef Bacik 
73907e81dc9SJosef Bacik /* struct btrfs_root_backup */
74007e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(backup_tree_root, struct btrfs_root_backup,
74107e81dc9SJosef Bacik 		   tree_root, 64);
74207e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(backup_tree_root_gen, struct btrfs_root_backup,
74307e81dc9SJosef Bacik 		   tree_root_gen, 64);
74407e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(backup_tree_root_level, struct btrfs_root_backup,
74507e81dc9SJosef Bacik 		   tree_root_level, 8);
74607e81dc9SJosef Bacik 
74707e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(backup_chunk_root, struct btrfs_root_backup,
74807e81dc9SJosef Bacik 		   chunk_root, 64);
74907e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(backup_chunk_root_gen, struct btrfs_root_backup,
75007e81dc9SJosef Bacik 		   chunk_root_gen, 64);
75107e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(backup_chunk_root_level, struct btrfs_root_backup,
75207e81dc9SJosef Bacik 		   chunk_root_level, 8);
75307e81dc9SJosef Bacik 
75407e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(backup_extent_root, struct btrfs_root_backup,
75507e81dc9SJosef Bacik 		   extent_root, 64);
75607e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(backup_extent_root_gen, struct btrfs_root_backup,
75707e81dc9SJosef Bacik 		   extent_root_gen, 64);
75807e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(backup_extent_root_level, struct btrfs_root_backup,
75907e81dc9SJosef Bacik 		   extent_root_level, 8);
76007e81dc9SJosef Bacik 
76107e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(backup_fs_root, struct btrfs_root_backup,
76207e81dc9SJosef Bacik 		   fs_root, 64);
76307e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(backup_fs_root_gen, struct btrfs_root_backup,
76407e81dc9SJosef Bacik 		   fs_root_gen, 64);
76507e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(backup_fs_root_level, struct btrfs_root_backup,
76607e81dc9SJosef Bacik 		   fs_root_level, 8);
76707e81dc9SJosef Bacik 
76807e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(backup_dev_root, struct btrfs_root_backup,
76907e81dc9SJosef Bacik 		   dev_root, 64);
77007e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(backup_dev_root_gen, struct btrfs_root_backup,
77107e81dc9SJosef Bacik 		   dev_root_gen, 64);
77207e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(backup_dev_root_level, struct btrfs_root_backup,
77307e81dc9SJosef Bacik 		   dev_root_level, 8);
77407e81dc9SJosef Bacik 
77507e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(backup_csum_root, struct btrfs_root_backup,
77607e81dc9SJosef Bacik 		   csum_root, 64);
77707e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(backup_csum_root_gen, struct btrfs_root_backup,
77807e81dc9SJosef Bacik 		   csum_root_gen, 64);
77907e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(backup_csum_root_level, struct btrfs_root_backup,
78007e81dc9SJosef Bacik 		   csum_root_level, 8);
78107e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(backup_total_bytes, struct btrfs_root_backup,
78207e81dc9SJosef Bacik 		   total_bytes, 64);
78307e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(backup_bytes_used, struct btrfs_root_backup,
78407e81dc9SJosef Bacik 		   bytes_used, 64);
78507e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(backup_num_devices, struct btrfs_root_backup,
78607e81dc9SJosef Bacik 		   num_devices, 64);
78707e81dc9SJosef Bacik 
78807e81dc9SJosef Bacik /* struct btrfs_balance_item */
78907e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(balance_flags, struct btrfs_balance_item, flags, 64);
79007e81dc9SJosef Bacik 
btrfs_balance_data(const struct extent_buffer * eb,const struct btrfs_balance_item * bi,struct btrfs_disk_balance_args * ba)79107e81dc9SJosef Bacik static inline void btrfs_balance_data(const struct extent_buffer *eb,
79207e81dc9SJosef Bacik 				      const struct btrfs_balance_item *bi,
79307e81dc9SJosef Bacik 				      struct btrfs_disk_balance_args *ba)
79407e81dc9SJosef Bacik {
79507e81dc9SJosef Bacik 	read_eb_member(eb, bi, struct btrfs_balance_item, data, ba);
79607e81dc9SJosef Bacik }
79707e81dc9SJosef Bacik 
btrfs_set_balance_data(struct extent_buffer * eb,struct btrfs_balance_item * bi,const struct btrfs_disk_balance_args * ba)79807e81dc9SJosef Bacik static inline void btrfs_set_balance_data(struct extent_buffer *eb,
79907e81dc9SJosef Bacik 					  struct btrfs_balance_item *bi,
80007e81dc9SJosef Bacik 					  const struct btrfs_disk_balance_args *ba)
80107e81dc9SJosef Bacik {
80207e81dc9SJosef Bacik 	write_eb_member(eb, bi, struct btrfs_balance_item, data, ba);
80307e81dc9SJosef Bacik }
80407e81dc9SJosef Bacik 
btrfs_balance_meta(const struct extent_buffer * eb,const struct btrfs_balance_item * bi,struct btrfs_disk_balance_args * ba)80507e81dc9SJosef Bacik static inline void btrfs_balance_meta(const struct extent_buffer *eb,
80607e81dc9SJosef Bacik 				      const struct btrfs_balance_item *bi,
80707e81dc9SJosef Bacik 				      struct btrfs_disk_balance_args *ba)
80807e81dc9SJosef Bacik {
80907e81dc9SJosef Bacik 	read_eb_member(eb, bi, struct btrfs_balance_item, meta, ba);
81007e81dc9SJosef Bacik }
81107e81dc9SJosef Bacik 
btrfs_set_balance_meta(struct extent_buffer * eb,struct btrfs_balance_item * bi,const struct btrfs_disk_balance_args * ba)81207e81dc9SJosef Bacik static inline void btrfs_set_balance_meta(struct extent_buffer *eb,
81307e81dc9SJosef Bacik 					  struct btrfs_balance_item *bi,
81407e81dc9SJosef Bacik 					  const struct btrfs_disk_balance_args *ba)
81507e81dc9SJosef Bacik {
81607e81dc9SJosef Bacik 	write_eb_member(eb, bi, struct btrfs_balance_item, meta, ba);
81707e81dc9SJosef Bacik }
81807e81dc9SJosef Bacik 
btrfs_balance_sys(const struct extent_buffer * eb,const struct btrfs_balance_item * bi,struct btrfs_disk_balance_args * ba)81907e81dc9SJosef Bacik static inline void btrfs_balance_sys(const struct extent_buffer *eb,
82007e81dc9SJosef Bacik 				     const struct btrfs_balance_item *bi,
82107e81dc9SJosef Bacik 				     struct btrfs_disk_balance_args *ba)
82207e81dc9SJosef Bacik {
82307e81dc9SJosef Bacik 	read_eb_member(eb, bi, struct btrfs_balance_item, sys, ba);
82407e81dc9SJosef Bacik }
82507e81dc9SJosef Bacik 
btrfs_set_balance_sys(struct extent_buffer * eb,struct btrfs_balance_item * bi,const struct btrfs_disk_balance_args * ba)82607e81dc9SJosef Bacik static inline void btrfs_set_balance_sys(struct extent_buffer *eb,
82707e81dc9SJosef Bacik 					 struct btrfs_balance_item *bi,
82807e81dc9SJosef Bacik 					 const struct btrfs_disk_balance_args *ba)
82907e81dc9SJosef Bacik {
83007e81dc9SJosef Bacik 	write_eb_member(eb, bi, struct btrfs_balance_item, sys, ba);
83107e81dc9SJosef Bacik }
83207e81dc9SJosef Bacik 
btrfs_disk_balance_args_to_cpu(struct btrfs_balance_args * cpu,const struct btrfs_disk_balance_args * disk)83307e81dc9SJosef Bacik static inline void btrfs_disk_balance_args_to_cpu(struct btrfs_balance_args *cpu,
83407e81dc9SJosef Bacik 			       const struct btrfs_disk_balance_args *disk)
83507e81dc9SJosef Bacik {
83607e81dc9SJosef Bacik 	memset(cpu, 0, sizeof(*cpu));
83707e81dc9SJosef Bacik 
83807e81dc9SJosef Bacik 	cpu->profiles = le64_to_cpu(disk->profiles);
83907e81dc9SJosef Bacik 	cpu->usage = le64_to_cpu(disk->usage);
84007e81dc9SJosef Bacik 	cpu->devid = le64_to_cpu(disk->devid);
84107e81dc9SJosef Bacik 	cpu->pstart = le64_to_cpu(disk->pstart);
84207e81dc9SJosef Bacik 	cpu->pend = le64_to_cpu(disk->pend);
84307e81dc9SJosef Bacik 	cpu->vstart = le64_to_cpu(disk->vstart);
84407e81dc9SJosef Bacik 	cpu->vend = le64_to_cpu(disk->vend);
84507e81dc9SJosef Bacik 	cpu->target = le64_to_cpu(disk->target);
84607e81dc9SJosef Bacik 	cpu->flags = le64_to_cpu(disk->flags);
84707e81dc9SJosef Bacik 	cpu->limit = le64_to_cpu(disk->limit);
84807e81dc9SJosef Bacik 	cpu->stripes_min = le32_to_cpu(disk->stripes_min);
84907e81dc9SJosef Bacik 	cpu->stripes_max = le32_to_cpu(disk->stripes_max);
85007e81dc9SJosef Bacik }
85107e81dc9SJosef Bacik 
btrfs_cpu_balance_args_to_disk(struct btrfs_disk_balance_args * disk,const struct btrfs_balance_args * cpu)85207e81dc9SJosef Bacik static inline void btrfs_cpu_balance_args_to_disk(
85307e81dc9SJosef Bacik 				struct btrfs_disk_balance_args *disk,
85407e81dc9SJosef Bacik 				const struct btrfs_balance_args *cpu)
85507e81dc9SJosef Bacik {
85607e81dc9SJosef Bacik 	memset(disk, 0, sizeof(*disk));
85707e81dc9SJosef Bacik 
85807e81dc9SJosef Bacik 	disk->profiles = cpu_to_le64(cpu->profiles);
85907e81dc9SJosef Bacik 	disk->usage = cpu_to_le64(cpu->usage);
86007e81dc9SJosef Bacik 	disk->devid = cpu_to_le64(cpu->devid);
86107e81dc9SJosef Bacik 	disk->pstart = cpu_to_le64(cpu->pstart);
86207e81dc9SJosef Bacik 	disk->pend = cpu_to_le64(cpu->pend);
86307e81dc9SJosef Bacik 	disk->vstart = cpu_to_le64(cpu->vstart);
86407e81dc9SJosef Bacik 	disk->vend = cpu_to_le64(cpu->vend);
86507e81dc9SJosef Bacik 	disk->target = cpu_to_le64(cpu->target);
86607e81dc9SJosef Bacik 	disk->flags = cpu_to_le64(cpu->flags);
86707e81dc9SJosef Bacik 	disk->limit = cpu_to_le64(cpu->limit);
86807e81dc9SJosef Bacik 	disk->stripes_min = cpu_to_le32(cpu->stripes_min);
86907e81dc9SJosef Bacik 	disk->stripes_max = cpu_to_le32(cpu->stripes_max);
87007e81dc9SJosef Bacik }
87107e81dc9SJosef Bacik 
87207e81dc9SJosef Bacik /* struct btrfs_super_block */
87307e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(super_bytenr, struct btrfs_super_block, bytenr, 64);
87407e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(super_flags, struct btrfs_super_block, flags, 64);
87507e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(super_generation, struct btrfs_super_block,
87607e81dc9SJosef Bacik 			 generation, 64);
87707e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(super_root, struct btrfs_super_block, root, 64);
87807e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(super_sys_array_size,
87907e81dc9SJosef Bacik 			 struct btrfs_super_block, sys_chunk_array_size, 32);
88007e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(super_chunk_root_generation,
88107e81dc9SJosef Bacik 			 struct btrfs_super_block, chunk_root_generation, 64);
88207e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(super_root_level, struct btrfs_super_block,
88307e81dc9SJosef Bacik 			 root_level, 8);
88407e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(super_chunk_root, struct btrfs_super_block,
88507e81dc9SJosef Bacik 			 chunk_root, 64);
88607e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(super_chunk_root_level, struct btrfs_super_block,
88707e81dc9SJosef Bacik 			 chunk_root_level, 8);
88807e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(super_log_root, struct btrfs_super_block, log_root, 64);
88907e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(super_log_root_level, struct btrfs_super_block,
89007e81dc9SJosef Bacik 			 log_root_level, 8);
89107e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(super_total_bytes, struct btrfs_super_block,
89207e81dc9SJosef Bacik 			 total_bytes, 64);
89307e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(super_bytes_used, struct btrfs_super_block,
89407e81dc9SJosef Bacik 			 bytes_used, 64);
89507e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(super_sectorsize, struct btrfs_super_block,
89607e81dc9SJosef Bacik 			 sectorsize, 32);
89707e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(super_nodesize, struct btrfs_super_block,
89807e81dc9SJosef Bacik 			 nodesize, 32);
89907e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(super_stripesize, struct btrfs_super_block,
90007e81dc9SJosef Bacik 			 stripesize, 32);
90107e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(super_root_dir, struct btrfs_super_block,
90207e81dc9SJosef Bacik 			 root_dir_objectid, 64);
90307e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(super_num_devices, struct btrfs_super_block,
90407e81dc9SJosef Bacik 			 num_devices, 64);
90507e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(super_compat_flags, struct btrfs_super_block,
90607e81dc9SJosef Bacik 			 compat_flags, 64);
90707e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(super_compat_ro_flags, struct btrfs_super_block,
90807e81dc9SJosef Bacik 			 compat_ro_flags, 64);
90907e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(super_incompat_flags, struct btrfs_super_block,
91007e81dc9SJosef Bacik 			 incompat_flags, 64);
91107e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(super_csum_type, struct btrfs_super_block,
91207e81dc9SJosef Bacik 			 csum_type, 16);
91307e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(super_cache_generation, struct btrfs_super_block,
91407e81dc9SJosef Bacik 			 cache_generation, 64);
91507e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(super_magic, struct btrfs_super_block, magic, 64);
91607e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(super_uuid_tree_generation, struct btrfs_super_block,
91707e81dc9SJosef Bacik 			 uuid_tree_generation, 64);
9180c703003SJosef Bacik BTRFS_SETGET_STACK_FUNCS(super_nr_global_roots, struct btrfs_super_block,
9190c703003SJosef Bacik 			 nr_global_roots, 64);
92007e81dc9SJosef Bacik 
92107e81dc9SJosef Bacik /* struct btrfs_file_extent_item */
92207e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_file_extent_type, struct btrfs_file_extent_item,
92307e81dc9SJosef Bacik 			 type, 8);
92407e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_file_extent_disk_bytenr,
92507e81dc9SJosef Bacik 			 struct btrfs_file_extent_item, disk_bytenr, 64);
92607e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_file_extent_offset,
92707e81dc9SJosef Bacik 			 struct btrfs_file_extent_item, offset, 64);
92807e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_file_extent_generation,
92907e81dc9SJosef Bacik 			 struct btrfs_file_extent_item, generation, 64);
93007e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_file_extent_num_bytes,
93107e81dc9SJosef Bacik 			 struct btrfs_file_extent_item, num_bytes, 64);
93207e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_file_extent_ram_bytes,
93307e81dc9SJosef Bacik 			 struct btrfs_file_extent_item, ram_bytes, 64);
93407e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_file_extent_disk_num_bytes,
93507e81dc9SJosef Bacik 			 struct btrfs_file_extent_item, disk_num_bytes, 64);
93607e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_file_extent_compression,
93707e81dc9SJosef Bacik 			 struct btrfs_file_extent_item, compression, 8);
93807e81dc9SJosef Bacik 
93907e81dc9SJosef Bacik 
94007e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(file_extent_type, struct btrfs_file_extent_item, type, 8);
94107e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(file_extent_disk_bytenr, struct btrfs_file_extent_item,
94207e81dc9SJosef Bacik 		   disk_bytenr, 64);
94307e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(file_extent_generation, struct btrfs_file_extent_item,
94407e81dc9SJosef Bacik 		   generation, 64);
94507e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(file_extent_disk_num_bytes, struct btrfs_file_extent_item,
94607e81dc9SJosef Bacik 		   disk_num_bytes, 64);
94707e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(file_extent_offset, struct btrfs_file_extent_item,
94807e81dc9SJosef Bacik 		  offset, 64);
94907e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(file_extent_num_bytes, struct btrfs_file_extent_item,
95007e81dc9SJosef Bacik 		   num_bytes, 64);
95107e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(file_extent_ram_bytes, struct btrfs_file_extent_item,
95207e81dc9SJosef Bacik 		   ram_bytes, 64);
95307e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(file_extent_compression, struct btrfs_file_extent_item,
95407e81dc9SJosef Bacik 		   compression, 8);
95507e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(file_extent_encryption, struct btrfs_file_extent_item,
95607e81dc9SJosef Bacik 		   encryption, 8);
95707e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(file_extent_other_encoding, struct btrfs_file_extent_item,
95807e81dc9SJosef Bacik 		   other_encoding, 16);
95907e81dc9SJosef Bacik 
96007e81dc9SJosef Bacik /* btrfs_qgroup_status_item */
96107e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(qgroup_status_generation, struct btrfs_qgroup_status_item,
96207e81dc9SJosef Bacik 		   generation, 64);
96307e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(qgroup_status_version, struct btrfs_qgroup_status_item,
96407e81dc9SJosef Bacik 		   version, 64);
96507e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(qgroup_status_flags, struct btrfs_qgroup_status_item,
96607e81dc9SJosef Bacik 		   flags, 64);
96707e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(qgroup_status_rescan, struct btrfs_qgroup_status_item,
96807e81dc9SJosef Bacik 		   rescan, 64);
96907e81dc9SJosef Bacik 
97007e81dc9SJosef Bacik /* btrfs_qgroup_info_item */
97107e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(qgroup_info_generation, struct btrfs_qgroup_info_item,
97207e81dc9SJosef Bacik 		   generation, 64);
97307e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(qgroup_info_rfer, struct btrfs_qgroup_info_item, rfer, 64);
97407e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(qgroup_info_rfer_cmpr, struct btrfs_qgroup_info_item,
97507e81dc9SJosef Bacik 		   rfer_cmpr, 64);
97607e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(qgroup_info_excl, struct btrfs_qgroup_info_item, excl, 64);
97707e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(qgroup_info_excl_cmpr, struct btrfs_qgroup_info_item,
97807e81dc9SJosef Bacik 		   excl_cmpr, 64);
97907e81dc9SJosef Bacik 
98007e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_qgroup_info_generation,
98107e81dc9SJosef Bacik 			 struct btrfs_qgroup_info_item, generation, 64);
98207e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_qgroup_info_rfer, struct btrfs_qgroup_info_item,
98307e81dc9SJosef Bacik 			 rfer, 64);
98407e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_qgroup_info_rfer_cmpr,
98507e81dc9SJosef Bacik 			 struct btrfs_qgroup_info_item, rfer_cmpr, 64);
98607e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_qgroup_info_excl, struct btrfs_qgroup_info_item,
98707e81dc9SJosef Bacik 			 excl, 64);
98807e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_qgroup_info_excl_cmpr,
98907e81dc9SJosef Bacik 			 struct btrfs_qgroup_info_item, excl_cmpr, 64);
99007e81dc9SJosef Bacik 
99107e81dc9SJosef Bacik /* btrfs_qgroup_limit_item */
99207e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(qgroup_limit_flags, struct btrfs_qgroup_limit_item, flags, 64);
99307e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(qgroup_limit_max_rfer, struct btrfs_qgroup_limit_item,
99407e81dc9SJosef Bacik 		   max_rfer, 64);
99507e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(qgroup_limit_max_excl, struct btrfs_qgroup_limit_item,
99607e81dc9SJosef Bacik 		   max_excl, 64);
99707e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(qgroup_limit_rsv_rfer, struct btrfs_qgroup_limit_item,
99807e81dc9SJosef Bacik 		   rsv_rfer, 64);
99907e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(qgroup_limit_rsv_excl, struct btrfs_qgroup_limit_item,
100007e81dc9SJosef Bacik 		   rsv_excl, 64);
1001054056bdSJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_qgroup_limit_flags,
1002054056bdSJosef Bacik 			 struct btrfs_qgroup_limit_item, flags, 64);
1003054056bdSJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_qgroup_limit_max_rfer,
1004054056bdSJosef Bacik 			 struct btrfs_qgroup_limit_item, max_rfer, 64);
1005054056bdSJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_qgroup_limit_max_excl,
1006054056bdSJosef Bacik 			 struct btrfs_qgroup_limit_item, max_excl, 64);
1007054056bdSJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_qgroup_limit_rsv_rfer,
1008054056bdSJosef Bacik 			 struct btrfs_qgroup_limit_item, rsv_rfer, 64);
1009054056bdSJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_qgroup_limit_rsv_excl,
1010054056bdSJosef Bacik 			 struct btrfs_qgroup_limit_item, rsv_excl, 64);
101107e81dc9SJosef Bacik 
101207e81dc9SJosef Bacik /* btrfs_dev_replace_item */
101307e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(dev_replace_src_devid,
101407e81dc9SJosef Bacik 		   struct btrfs_dev_replace_item, src_devid, 64);
101507e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(dev_replace_cont_reading_from_srcdev_mode,
101607e81dc9SJosef Bacik 		   struct btrfs_dev_replace_item, cont_reading_from_srcdev_mode,
101707e81dc9SJosef Bacik 		   64);
101807e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(dev_replace_replace_state, struct btrfs_dev_replace_item,
101907e81dc9SJosef Bacik 		   replace_state, 64);
102007e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(dev_replace_time_started, struct btrfs_dev_replace_item,
102107e81dc9SJosef Bacik 		   time_started, 64);
102207e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(dev_replace_time_stopped, struct btrfs_dev_replace_item,
102307e81dc9SJosef Bacik 		   time_stopped, 64);
102407e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(dev_replace_num_write_errors, struct btrfs_dev_replace_item,
102507e81dc9SJosef Bacik 		   num_write_errors, 64);
102607e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(dev_replace_num_uncorrectable_read_errors,
102707e81dc9SJosef Bacik 		   struct btrfs_dev_replace_item, num_uncorrectable_read_errors,
102807e81dc9SJosef Bacik 		   64);
102907e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(dev_replace_cursor_left, struct btrfs_dev_replace_item,
103007e81dc9SJosef Bacik 		   cursor_left, 64);
103107e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(dev_replace_cursor_right, struct btrfs_dev_replace_item,
103207e81dc9SJosef Bacik 		   cursor_right, 64);
103307e81dc9SJosef Bacik 
103407e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_dev_replace_src_devid,
103507e81dc9SJosef Bacik 			 struct btrfs_dev_replace_item, src_devid, 64);
103607e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_dev_replace_cont_reading_from_srcdev_mode,
103707e81dc9SJosef Bacik 			 struct btrfs_dev_replace_item,
103807e81dc9SJosef Bacik 			 cont_reading_from_srcdev_mode, 64);
103907e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_dev_replace_replace_state,
104007e81dc9SJosef Bacik 			 struct btrfs_dev_replace_item, replace_state, 64);
104107e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_dev_replace_time_started,
104207e81dc9SJosef Bacik 			 struct btrfs_dev_replace_item, time_started, 64);
104307e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_dev_replace_time_stopped,
104407e81dc9SJosef Bacik 			 struct btrfs_dev_replace_item, time_stopped, 64);
104507e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_dev_replace_num_write_errors,
104607e81dc9SJosef Bacik 			 struct btrfs_dev_replace_item, num_write_errors, 64);
104707e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_dev_replace_num_uncorrectable_read_errors,
104807e81dc9SJosef Bacik 			 struct btrfs_dev_replace_item,
104907e81dc9SJosef Bacik 			 num_uncorrectable_read_errors, 64);
105007e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_dev_replace_cursor_left,
105107e81dc9SJosef Bacik 			 struct btrfs_dev_replace_item, cursor_left, 64);
105207e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_dev_replace_cursor_right,
105307e81dc9SJosef Bacik 			 struct btrfs_dev_replace_item, cursor_right, 64);
105407e81dc9SJosef Bacik 
105507e81dc9SJosef Bacik /* btrfs_verity_descriptor_item */
105607e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(verity_descriptor_encryption, struct btrfs_verity_descriptor_item,
105707e81dc9SJosef Bacik 		   encryption, 8);
105807e81dc9SJosef Bacik BTRFS_SETGET_FUNCS(verity_descriptor_size, struct btrfs_verity_descriptor_item,
105907e81dc9SJosef Bacik 		   size, 64);
106007e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_verity_descriptor_encryption,
106107e81dc9SJosef Bacik 			 struct btrfs_verity_descriptor_item, encryption, 8);
106207e81dc9SJosef Bacik BTRFS_SETGET_STACK_FUNCS(stack_verity_descriptor_size,
106307e81dc9SJosef Bacik 			 struct btrfs_verity_descriptor_item, size, 64);
106407e81dc9SJosef Bacik 
106507e81dc9SJosef Bacik /* Cast into the data area of the leaf. */
106607e81dc9SJosef Bacik #define btrfs_item_ptr(leaf, slot, type)				\
10678009adf3SJosef Bacik 	((type *)(btrfs_item_nr_offset(leaf, 0) + btrfs_item_offset(leaf, slot)))
106807e81dc9SJosef Bacik 
106907e81dc9SJosef Bacik #define btrfs_item_ptr_offset(leaf, slot)				\
10708009adf3SJosef Bacik 	((unsigned long)(btrfs_item_nr_offset(leaf, 0) + btrfs_item_offset(leaf, slot)))
107107e81dc9SJosef Bacik 
1072ad1ac501SJosef Bacik #endif
1073