1 /* SPDX-License-Identifier: GPL-2.0 */
3 #ifndef BTRFS_INODE_ITEM_H
4 #define BTRFS_INODE_ITEM_H
6 #include <linux/types.h>
8 struct btrfs_trans_handle;
12 struct btrfs_inode_extref;
17 * Return this if we need to call truncate_block for the last bit of the
20 #define BTRFS_NEED_TRUNCATE_BLOCK 1
22 struct btrfs_truncate_control {
24 * IN: the inode we're operating on, this can be NULL if
25 * ->clear_extent_range is false.
27 struct btrfs_inode *inode;
29 /* IN: the size we're truncating to. */
32 /* OUT: the number of extents truncated. */
35 /* OUT: the last size we truncated this inode to. */
38 /* OUT: the number of bytes to sub from this inode. */
41 /* IN: the ino we are truncating. */
45 * IN: minimum key type to remove. All key types with this type are
46 * removed only if their offset >= new_size.
51 * IN: true if we don't want to do extent reference updates for any file
54 bool skip_ref_updates;
57 * IN: true if we need to clear the file extent range for the inode as
58 * we drop the file extent items.
60 bool clear_extent_range;
63 int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
64 struct btrfs_root *root,
65 struct btrfs_truncate_control *control);
66 int btrfs_insert_inode_ref(struct btrfs_trans_handle *trans,
67 struct btrfs_root *root,
68 const char *name, int name_len,
69 u64 inode_objectid, u64 ref_objectid, u64 index);
70 int btrfs_del_inode_ref(struct btrfs_trans_handle *trans,
71 struct btrfs_root *root,
72 const char *name, int name_len,
73 u64 inode_objectid, u64 ref_objectid, u64 *index);
74 int btrfs_insert_empty_inode(struct btrfs_trans_handle *trans,
75 struct btrfs_root *root,
76 struct btrfs_path *path, u64 objectid);
77 int btrfs_lookup_inode(struct btrfs_trans_handle *trans, struct btrfs_root
78 *root, struct btrfs_path *path,
79 struct btrfs_key *location, int mod);
81 struct btrfs_inode_extref *btrfs_lookup_inode_extref(
82 struct btrfs_trans_handle *trans,
83 struct btrfs_root *root,
84 struct btrfs_path *path,
85 const char *name, int name_len,
86 u64 inode_objectid, u64 ref_objectid, int ins_len,
89 struct btrfs_inode_ref *btrfs_find_name_in_backref(struct extent_buffer *leaf,
90 int slot, const char *name,
92 struct btrfs_inode_extref *btrfs_find_name_in_ext_backref(
93 struct extent_buffer *leaf, int slot, u64 ref_objectid,
94 const char *name, int name_len);