refcounttree.h 4.3 KB

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