refcounttree.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 rw_semaphore rf_sem;
  24. struct ocfs2_lock_res rf_lockres;
  25. struct kref rf_getcnt;
  26. int rf_removed;
  27. /* the following 4 fields are used by caching_info. */
  28. struct ocfs2_caching_info rf_ci;
  29. spinlock_t rf_lock;
  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. struct buffer_head *di_bh,
  47. u64 phys_blkno,
  48. u32 clusters,
  49. int *credits,
  50. struct ocfs2_alloc_context **meta_ac);
  51. int ocfs2_refcount_cow(struct inode *inode, struct buffer_head *di_bh,
  52. u32 cpos, u32 write_len, u32 max_cpos);
  53. #endif /* OCFS2_REFCOUNTTREE_H */