refcounttree.h 4.4 KB

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