refcounttree.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * refcounttree.h
  4. *
  5. * Copyright (C) 2009 Oracle. All rights reserved.
  6. */
  7. #ifndef OCFS2_REFCOUNTTREE_H
  8. #define OCFS2_REFCOUNTTREE_H
  9. struct ocfs2_refcount_tree {
  10. struct rb_node rf_node;
  11. u64 rf_blkno;
  12. u32 rf_generation;
  13. struct kref rf_getcnt;
  14. struct rw_semaphore rf_sem;
  15. struct ocfs2_lock_res rf_lockres;
  16. int rf_removed;
  17. /* the following 4 fields are used by caching_info. */
  18. spinlock_t rf_lock;
  19. struct ocfs2_caching_info rf_ci;
  20. struct mutex rf_io_mutex;
  21. struct super_block *rf_sb;
  22. };
  23. void ocfs2_purge_refcount_trees(struct ocfs2_super *osb);
  24. int ocfs2_lock_refcount_tree(struct ocfs2_super *osb, u64 ref_blkno, int rw,
  25. struct ocfs2_refcount_tree **tree,
  26. struct buffer_head **ref_bh);
  27. void ocfs2_unlock_refcount_tree(struct ocfs2_super *osb,
  28. struct ocfs2_refcount_tree *tree,
  29. int rw);
  30. int ocfs2_decrease_refcount(struct inode *inode,
  31. handle_t *handle, u32 cpos, u32 len,
  32. struct ocfs2_alloc_context *meta_ac,
  33. struct ocfs2_cached_dealloc_ctxt *dealloc,
  34. int delete);
  35. int ocfs2_prepare_refcount_change_for_del(struct inode *inode,
  36. u64 refcount_loc,
  37. u64 phys_blkno,
  38. u32 clusters,
  39. int *credits,
  40. int *ref_blocks);
  41. int ocfs2_refcount_cow(struct inode *inode,
  42. struct buffer_head *di_bh,
  43. u32 cpos, u32 write_len, u32 max_cpos);
  44. typedef int (ocfs2_post_refcount_func)(struct inode *inode,
  45. handle_t *handle,
  46. void *para);
  47. /*
  48. * Some refcount caller need to do more work after we modify the data b-tree
  49. * during refcount operation(including CoW and add refcount flag), and make the
  50. * transaction complete. So it must give us this structure so that we can do it
  51. * within our transaction.
  52. *
  53. */
  54. struct ocfs2_post_refcount {
  55. int credits; /* credits it need for journal. */
  56. ocfs2_post_refcount_func *func; /* real function. */
  57. void *para;
  58. };
  59. int ocfs2_refcounted_xattr_delete_need(struct inode *inode,
  60. struct ocfs2_caching_info *ref_ci,
  61. struct buffer_head *ref_root_bh,
  62. struct ocfs2_xattr_value_root *xv,
  63. int *meta_add, int *credits);
  64. int ocfs2_refcount_cow_xattr(struct inode *inode,
  65. struct ocfs2_dinode *di,
  66. struct ocfs2_xattr_value_buf *vb,
  67. struct ocfs2_refcount_tree *ref_tree,
  68. struct buffer_head *ref_root_bh,
  69. u32 cpos, u32 write_len,
  70. struct ocfs2_post_refcount *post);
  71. int ocfs2_duplicate_clusters_by_page(handle_t *handle,
  72. struct inode *inode,
  73. u32 cpos, u32 old_cluster,
  74. u32 new_cluster, u32 new_len);
  75. int ocfs2_duplicate_clusters_by_jbd(handle_t *handle,
  76. struct inode *inode,
  77. u32 cpos, u32 old_cluster,
  78. u32 new_cluster, u32 new_len);
  79. int ocfs2_cow_sync_writeback(struct super_block *sb,
  80. struct inode *inode,
  81. u32 cpos, u32 num_clusters);
  82. int ocfs2_add_refcount_flag(struct inode *inode,
  83. struct ocfs2_extent_tree *data_et,
  84. struct ocfs2_caching_info *ref_ci,
  85. struct buffer_head *ref_root_bh,
  86. u32 cpos, u32 p_cluster, u32 num_clusters,
  87. struct ocfs2_cached_dealloc_ctxt *dealloc,
  88. struct ocfs2_post_refcount *post);
  89. int ocfs2_remove_refcount_tree(struct inode *inode, struct buffer_head *di_bh);
  90. int ocfs2_try_remove_refcount_tree(struct inode *inode,
  91. struct buffer_head *di_bh);
  92. int ocfs2_increase_refcount(handle_t *handle,
  93. struct ocfs2_caching_info *ci,
  94. struct buffer_head *ref_root_bh,
  95. u64 cpos, u32 len,
  96. struct ocfs2_alloc_context *meta_ac,
  97. struct ocfs2_cached_dealloc_ctxt *dealloc);
  98. int ocfs2_reflink_ioctl(struct inode *inode,
  99. const char __user *oldname,
  100. const char __user *newname,
  101. bool preserve);
  102. loff_t ocfs2_reflink_remap_blocks(struct inode *s_inode,
  103. struct buffer_head *s_bh,
  104. loff_t pos_in,
  105. struct inode *t_inode,
  106. struct buffer_head *t_bh,
  107. loff_t pos_out,
  108. loff_t len);
  109. int ocfs2_reflink_inodes_lock(struct inode *s_inode,
  110. struct buffer_head **bh1,
  111. struct inode *t_inode,
  112. struct buffer_head **bh2);
  113. void ocfs2_reflink_inodes_unlock(struct inode *s_inode,
  114. struct buffer_head *s_bh,
  115. struct inode *t_inode,
  116. struct buffer_head *t_bh);
  117. int ocfs2_reflink_update_dest(struct inode *dest,
  118. struct buffer_head *d_bh,
  119. loff_t newlen);
  120. #endif /* OCFS2_REFCOUNTTREE_H */