162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci 362306a36Sopenharmony_ci#ifndef BTRFS_FILE_ITEM_H 462306a36Sopenharmony_ci#define BTRFS_FILE_ITEM_H 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#include "accessors.h" 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#define BTRFS_FILE_EXTENT_INLINE_DATA_START \ 962306a36Sopenharmony_ci (offsetof(struct btrfs_file_extent_item, disk_bytenr)) 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_cistatic inline u32 BTRFS_MAX_INLINE_DATA_SIZE(const struct btrfs_fs_info *info) 1262306a36Sopenharmony_ci{ 1362306a36Sopenharmony_ci return BTRFS_MAX_ITEM_SIZE(info) - BTRFS_FILE_EXTENT_INLINE_DATA_START; 1462306a36Sopenharmony_ci} 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci/* 1762306a36Sopenharmony_ci * Return the number of bytes used by the item on disk, minus the size of any 1862306a36Sopenharmony_ci * extent headers. If a file is compressed on disk, this is the compressed 1962306a36Sopenharmony_ci * size. 2062306a36Sopenharmony_ci */ 2162306a36Sopenharmony_cistatic inline u32 btrfs_file_extent_inline_item_len( 2262306a36Sopenharmony_ci const struct extent_buffer *eb, 2362306a36Sopenharmony_ci int nr) 2462306a36Sopenharmony_ci{ 2562306a36Sopenharmony_ci return btrfs_item_size(eb, nr) - BTRFS_FILE_EXTENT_INLINE_DATA_START; 2662306a36Sopenharmony_ci} 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_cistatic inline unsigned long btrfs_file_extent_inline_start( 2962306a36Sopenharmony_ci const struct btrfs_file_extent_item *e) 3062306a36Sopenharmony_ci{ 3162306a36Sopenharmony_ci return (unsigned long)e + BTRFS_FILE_EXTENT_INLINE_DATA_START; 3262306a36Sopenharmony_ci} 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_cistatic inline u32 btrfs_file_extent_calc_inline_size(u32 datasize) 3562306a36Sopenharmony_ci{ 3662306a36Sopenharmony_ci return BTRFS_FILE_EXTENT_INLINE_DATA_START + datasize; 3762306a36Sopenharmony_ci} 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ciint btrfs_del_csums(struct btrfs_trans_handle *trans, 4062306a36Sopenharmony_ci struct btrfs_root *root, u64 bytenr, u64 len); 4162306a36Sopenharmony_ciblk_status_t btrfs_lookup_bio_sums(struct btrfs_bio *bbio); 4262306a36Sopenharmony_ciint btrfs_insert_hole_extent(struct btrfs_trans_handle *trans, 4362306a36Sopenharmony_ci struct btrfs_root *root, u64 objectid, u64 pos, 4462306a36Sopenharmony_ci u64 num_bytes); 4562306a36Sopenharmony_ciint btrfs_lookup_file_extent(struct btrfs_trans_handle *trans, 4662306a36Sopenharmony_ci struct btrfs_root *root, 4762306a36Sopenharmony_ci struct btrfs_path *path, u64 objectid, 4862306a36Sopenharmony_ci u64 bytenr, int mod); 4962306a36Sopenharmony_ciint btrfs_csum_file_blocks(struct btrfs_trans_handle *trans, 5062306a36Sopenharmony_ci struct btrfs_root *root, 5162306a36Sopenharmony_ci struct btrfs_ordered_sum *sums); 5262306a36Sopenharmony_ciblk_status_t btrfs_csum_one_bio(struct btrfs_bio *bbio); 5362306a36Sopenharmony_ciblk_status_t btrfs_alloc_dummy_sum(struct btrfs_bio *bbio); 5462306a36Sopenharmony_ciint btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end, 5562306a36Sopenharmony_ci struct list_head *list, int search_commit, 5662306a36Sopenharmony_ci bool nowait); 5762306a36Sopenharmony_ciint btrfs_lookup_csums_list(struct btrfs_root *root, u64 start, u64 end, 5862306a36Sopenharmony_ci struct list_head *list, int search_commit, 5962306a36Sopenharmony_ci bool nowait); 6062306a36Sopenharmony_ciint btrfs_lookup_csums_bitmap(struct btrfs_root *root, struct btrfs_path *path, 6162306a36Sopenharmony_ci u64 start, u64 end, u8 *csum_buf, 6262306a36Sopenharmony_ci unsigned long *csum_bitmap); 6362306a36Sopenharmony_civoid btrfs_extent_item_to_extent_map(struct btrfs_inode *inode, 6462306a36Sopenharmony_ci const struct btrfs_path *path, 6562306a36Sopenharmony_ci struct btrfs_file_extent_item *fi, 6662306a36Sopenharmony_ci struct extent_map *em); 6762306a36Sopenharmony_ciint btrfs_inode_clear_file_extent_range(struct btrfs_inode *inode, u64 start, 6862306a36Sopenharmony_ci u64 len); 6962306a36Sopenharmony_ciint btrfs_inode_set_file_extent_range(struct btrfs_inode *inode, u64 start, u64 len); 7062306a36Sopenharmony_civoid btrfs_inode_safe_disk_i_size_write(struct btrfs_inode *inode, u64 new_i_size); 7162306a36Sopenharmony_ciu64 btrfs_file_extent_end(const struct btrfs_path *path); 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci#endif 74