Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 
0003 #ifndef BTRFS_INODE_ITEM_H
0004 #define BTRFS_INODE_ITEM_H
0005 
0006 #include <linux/types.h>
0007 
0008 struct btrfs_trans_handle;
0009 struct btrfs_root;
0010 struct btrfs_path;
0011 struct btrfs_key;
0012 struct btrfs_inode_extref;
0013 struct btrfs_inode;
0014 struct extent_buffer;
0015 
0016 /*
0017  * Return this if we need to call truncate_block for the last bit of the
0018  * truncate.
0019  */
0020 #define BTRFS_NEED_TRUNCATE_BLOCK       1
0021 
0022 struct btrfs_truncate_control {
0023     /*
0024      * IN: the inode we're operating on, this can be NULL if
0025      * ->clear_extent_range is false.
0026      */
0027     struct btrfs_inode *inode;
0028 
0029     /* IN: the size we're truncating to. */
0030     u64 new_size;
0031 
0032     /* OUT: the number of extents truncated. */
0033     u64 extents_found;
0034 
0035     /* OUT: the last size we truncated this inode to. */
0036     u64 last_size;
0037 
0038     /* OUT: the number of bytes to sub from this inode. */
0039     u64 sub_bytes;
0040 
0041     /* IN: the ino we are truncating. */
0042     u64 ino;
0043 
0044     /*
0045      * IN: minimum key type to remove.  All key types with this type are
0046      * removed only if their offset >= new_size.
0047      */
0048     u32 min_type;
0049 
0050     /*
0051      * IN: true if we don't want to do extent reference updates for any file
0052      * extents we drop.
0053      */
0054     bool skip_ref_updates;
0055 
0056     /*
0057      * IN: true if we need to clear the file extent range for the inode as
0058      * we drop the file extent items.
0059      */
0060     bool clear_extent_range;
0061 };
0062 
0063 int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
0064                    struct btrfs_root *root,
0065                    struct btrfs_truncate_control *control);
0066 int btrfs_insert_inode_ref(struct btrfs_trans_handle *trans,
0067                struct btrfs_root *root,
0068                const char *name, int name_len,
0069                u64 inode_objectid, u64 ref_objectid, u64 index);
0070 int btrfs_del_inode_ref(struct btrfs_trans_handle *trans,
0071                struct btrfs_root *root,
0072                const char *name, int name_len,
0073                u64 inode_objectid, u64 ref_objectid, u64 *index);
0074 int btrfs_insert_empty_inode(struct btrfs_trans_handle *trans,
0075                  struct btrfs_root *root,
0076                  struct btrfs_path *path, u64 objectid);
0077 int btrfs_lookup_inode(struct btrfs_trans_handle *trans, struct btrfs_root
0078                *root, struct btrfs_path *path,
0079                struct btrfs_key *location, int mod);
0080 
0081 struct btrfs_inode_extref *btrfs_lookup_inode_extref(
0082               struct btrfs_trans_handle *trans,
0083               struct btrfs_root *root,
0084               struct btrfs_path *path,
0085               const char *name, int name_len,
0086               u64 inode_objectid, u64 ref_objectid, int ins_len,
0087               int cow);
0088 
0089 struct btrfs_inode_ref *btrfs_find_name_in_backref(struct extent_buffer *leaf,
0090                            int slot, const char *name,
0091                            int name_len);
0092 struct btrfs_inode_extref *btrfs_find_name_in_ext_backref(
0093         struct extent_buffer *leaf, int slot, u64 ref_objectid,
0094         const char *name, int name_len);
0095 
0096 #endif