inode-item.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef BTRFS_INODE_ITEM_H
  3. #define BTRFS_INODE_ITEM_H
  4. #include <linux/types.h>
  5. struct btrfs_trans_handle;
  6. struct btrfs_root;
  7. struct btrfs_path;
  8. struct btrfs_key;
  9. struct btrfs_inode_extref;
  10. struct btrfs_inode;
  11. struct extent_buffer;
  12. /*
  13. * Return this if we need to call truncate_block for the last bit of the
  14. * truncate.
  15. */
  16. #define BTRFS_NEED_TRUNCATE_BLOCK 1
  17. struct btrfs_truncate_control {
  18. /*
  19. * IN: the inode we're operating on, this can be NULL if
  20. * ->clear_extent_range is false.
  21. */
  22. struct btrfs_inode *inode;
  23. /* IN: the size we're truncating to. */
  24. u64 new_size;
  25. /* OUT: the number of extents truncated. */
  26. u64 extents_found;
  27. /* OUT: the last size we truncated this inode to. */
  28. u64 last_size;
  29. /* OUT: the number of bytes to sub from this inode. */
  30. u64 sub_bytes;
  31. /* IN: the ino we are truncating. */
  32. u64 ino;
  33. /*
  34. * IN: minimum key type to remove. All key types with this type are
  35. * removed only if their offset >= new_size.
  36. */
  37. u32 min_type;
  38. /*
  39. * IN: true if we don't want to do extent reference updates for any file
  40. * extents we drop.
  41. */
  42. bool skip_ref_updates;
  43. /*
  44. * IN: true if we need to clear the file extent range for the inode as
  45. * we drop the file extent items.
  46. */
  47. bool clear_extent_range;
  48. };
  49. int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
  50. struct btrfs_root *root,
  51. struct btrfs_truncate_control *control);
  52. int btrfs_insert_inode_ref(struct btrfs_trans_handle *trans,
  53. struct btrfs_root *root, const struct fscrypt_str *name,
  54. u64 inode_objectid, u64 ref_objectid, u64 index);
  55. int btrfs_del_inode_ref(struct btrfs_trans_handle *trans,
  56. struct btrfs_root *root, const struct fscrypt_str *name,
  57. u64 inode_objectid, u64 ref_objectid, u64 *index);
  58. int btrfs_insert_empty_inode(struct btrfs_trans_handle *trans,
  59. struct btrfs_root *root,
  60. struct btrfs_path *path, u64 objectid);
  61. int btrfs_lookup_inode(struct btrfs_trans_handle *trans,
  62. struct btrfs_root *root, struct btrfs_path *path,
  63. struct btrfs_key *location, int mod);
  64. struct btrfs_inode_extref *btrfs_lookup_inode_extref(
  65. struct btrfs_trans_handle *trans,
  66. struct btrfs_root *root,
  67. struct btrfs_path *path,
  68. const struct fscrypt_str *name,
  69. u64 inode_objectid, u64 ref_objectid, int ins_len,
  70. int cow);
  71. struct btrfs_inode_ref *btrfs_find_name_in_backref(struct extent_buffer *leaf,
  72. int slot,
  73. const struct fscrypt_str *name);
  74. struct btrfs_inode_extref *btrfs_find_name_in_ext_backref(
  75. struct extent_buffer *leaf, int slot, u64 ref_objectid,
  76. const struct fscrypt_str *name);
  77. #endif