1/* SPDX-License-Identifier: GPL-2.0 */
2
3#ifndef BTRFS_FILE_ITEM_H
4#define BTRFS_FILE_ITEM_H
5
6#include <linux/blk_types.h>
7#include <linux/list.h>
8#include <uapi/linux/btrfs_tree.h>
9#include "ctree.h"
10#include "accessors.h"
11
12struct extent_map;
13struct btrfs_file_extent_item;
14struct btrfs_fs_info;
15struct btrfs_path;
16struct btrfs_bio;
17struct btrfs_trans_handle;
18struct btrfs_root;
19struct btrfs_ordered_sum;
20struct btrfs_path;
21struct btrfs_inode;
22
23#define BTRFS_FILE_EXTENT_INLINE_DATA_START \
24 (offsetof(struct btrfs_file_extent_item, disk_bytenr))
25
26static inline u32 BTRFS_MAX_INLINE_DATA_SIZE(const struct btrfs_fs_info *info)
27{
28 return BTRFS_MAX_ITEM_SIZE(info) - BTRFS_FILE_EXTENT_INLINE_DATA_START;
29}
30
31/*
32 * Return the number of bytes used by the item on disk, minus the size of any
33 * extent headers. If a file is compressed on disk, this is the compressed
34 * size.
35 */
36static inline u32 btrfs_file_extent_inline_item_len(
37 const struct extent_buffer *eb,
38 int nr)
39{
40 return btrfs_item_size(eb, slot: nr) - BTRFS_FILE_EXTENT_INLINE_DATA_START;
41}
42
43static inline unsigned long btrfs_file_extent_inline_start(
44 const struct btrfs_file_extent_item *e)
45{
46 return (unsigned long)e + BTRFS_FILE_EXTENT_INLINE_DATA_START;
47}
48
49static inline u32 btrfs_file_extent_calc_inline_size(u32 datasize)
50{
51 return BTRFS_FILE_EXTENT_INLINE_DATA_START + datasize;
52}
53
54int btrfs_del_csums(struct btrfs_trans_handle *trans,
55 struct btrfs_root *root, u64 bytenr, u64 len);
56int btrfs_lookup_bio_sums(struct btrfs_bio *bbio);
57int btrfs_insert_hole_extent(struct btrfs_trans_handle *trans,
58 struct btrfs_root *root, u64 objectid, u64 pos,
59 u64 num_bytes);
60int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans,
61 struct btrfs_root *root,
62 struct btrfs_path *path, u64 objectid,
63 u64 bytenr, int mod);
64int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans,
65 struct btrfs_root *root,
66 struct btrfs_ordered_sum *sums);
67int btrfs_csum_one_bio(struct btrfs_bio *bbio);
68int btrfs_alloc_dummy_sum(struct btrfs_bio *bbio);
69int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end,
70 struct list_head *list, int search_commit,
71 bool nowait);
72int btrfs_lookup_csums_list(struct btrfs_root *root, u64 start, u64 end,
73 struct list_head *list, bool nowait);
74int btrfs_lookup_csums_bitmap(struct btrfs_root *root, struct btrfs_path *path,
75 u64 start, u64 end, u8 *csum_buf,
76 unsigned long *csum_bitmap);
77void btrfs_extent_item_to_extent_map(struct btrfs_inode *inode,
78 const struct btrfs_path *path,
79 const struct btrfs_file_extent_item *fi,
80 struct extent_map *em);
81int btrfs_inode_clear_file_extent_range(struct btrfs_inode *inode, u64 start,
82 u64 len);
83int btrfs_inode_set_file_extent_range(struct btrfs_inode *inode, u64 start, u64 len);
84void btrfs_inode_safe_disk_i_size_write(struct btrfs_inode *inode, u64 new_i_size);
85u64 btrfs_file_extent_end(const struct btrfs_path *path);
86
87#endif
88

source code of linux/fs/btrfs/file-item.h