xfs_refcount_item.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Copyright (C) 2016 Oracle. All Rights Reserved.
  3. *
  4. * Author: Darrick J. Wong <darrick.wong@oracle.com>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it would be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write the Free Software Foundation,
  18. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. #ifndef __XFS_REFCOUNT_ITEM_H__
  21. #define __XFS_REFCOUNT_ITEM_H__
  22. /*
  23. * There are (currently) two pairs of refcount btree redo item types:
  24. * increase and decrease. The log items for these are CUI (refcount
  25. * update intent) and CUD (refcount update done). The redo item type
  26. * is encoded in the flags field of each xfs_map_extent.
  27. *
  28. * *I items should be recorded in the *first* of a series of rolled
  29. * transactions, and the *D items should be recorded in the same
  30. * transaction that records the associated refcountbt updates.
  31. *
  32. * Should the system crash after the commit of the first transaction
  33. * but before the commit of the final transaction in a series, log
  34. * recovery will use the redo information recorded by the intent items
  35. * to replay the refcountbt metadata updates.
  36. */
  37. /* kernel only CUI/CUD definitions */
  38. struct xfs_mount;
  39. struct kmem_zone;
  40. /*
  41. * Max number of extents in fast allocation path.
  42. */
  43. #define XFS_CUI_MAX_FAST_EXTENTS 16
  44. /*
  45. * Define CUI flag bits. Manipulated by set/clear/test_bit operators.
  46. */
  47. #define XFS_CUI_RECOVERED 1
  48. /*
  49. * This is the "refcount update intent" log item. It is used to log
  50. * the fact that some reverse mappings need to change. It is used in
  51. * conjunction with the "refcount update done" log item described
  52. * below.
  53. *
  54. * These log items follow the same rules as struct xfs_efi_log_item;
  55. * see the comments about that structure (in xfs_extfree_item.h) for
  56. * more details.
  57. */
  58. struct xfs_cui_log_item {
  59. struct xfs_log_item cui_item;
  60. atomic_t cui_refcount;
  61. atomic_t cui_next_extent;
  62. unsigned long cui_flags; /* misc flags */
  63. struct xfs_cui_log_format cui_format;
  64. };
  65. static inline size_t
  66. xfs_cui_log_item_sizeof(
  67. unsigned int nr)
  68. {
  69. return offsetof(struct xfs_cui_log_item, cui_format) +
  70. xfs_cui_log_format_sizeof(nr);
  71. }
  72. /*
  73. * This is the "refcount update done" log item. It is used to log the
  74. * fact that some refcountbt updates mentioned in an earlier cui item
  75. * have been performed.
  76. */
  77. struct xfs_cud_log_item {
  78. struct xfs_log_item cud_item;
  79. struct xfs_cui_log_item *cud_cuip;
  80. struct xfs_cud_log_format cud_format;
  81. };
  82. extern struct kmem_zone *xfs_cui_zone;
  83. extern struct kmem_zone *xfs_cud_zone;
  84. struct xfs_cui_log_item *xfs_cui_init(struct xfs_mount *, uint);
  85. struct xfs_cud_log_item *xfs_cud_init(struct xfs_mount *,
  86. struct xfs_cui_log_item *);
  87. void xfs_cui_item_free(struct xfs_cui_log_item *);
  88. void xfs_cui_release(struct xfs_cui_log_item *);
  89. int xfs_cui_recover(struct xfs_mount *mp, struct xfs_cui_log_item *cuip);
  90. #endif /* __XFS_REFCOUNT_ITEM_H__ */