xfs_rmap_item.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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_RMAP_ITEM_H__
  21. #define __XFS_RMAP_ITEM_H__
  22. /*
  23. * There are (currently) three pairs of rmap btree redo item types: map, unmap,
  24. * and convert. The common abbreviations for these are RUI (rmap update
  25. * intent) and RUD (rmap update done). The redo item type is encoded in the
  26. * 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 transaction
  30. * that records the associated rmapbt updates. Typically, the first
  31. * transaction will record a bmbt update, followed by some number of
  32. * transactions containing rmapbt updates, and finally transactions with any
  33. * bnobt/cntbt updates.
  34. *
  35. * Should the system crash after the commit of the first transaction but
  36. * before the commit of the final transaction in a series, log recovery will
  37. * use the redo information recorded by the intent items to replay the
  38. * (rmapbt/bnobt/cntbt) metadata updates in the non-first transaction.
  39. */
  40. /* kernel only RUI/RUD definitions */
  41. struct xfs_mount;
  42. struct kmem_zone;
  43. /*
  44. * Max number of extents in fast allocation path.
  45. */
  46. #define XFS_RUI_MAX_FAST_EXTENTS 16
  47. /*
  48. * Define RUI flag bits. Manipulated by set/clear/test_bit operators.
  49. */
  50. #define XFS_RUI_RECOVERED 1
  51. /*
  52. * This is the "rmap update intent" log item. It is used to log the fact that
  53. * some reverse mappings need to change. It is used in conjunction with the
  54. * "rmap update done" log item described below.
  55. *
  56. * These log items follow the same rules as struct xfs_efi_log_item; see the
  57. * comments about that structure (in xfs_extfree_item.h) for more details.
  58. */
  59. struct xfs_rui_log_item {
  60. struct xfs_log_item rui_item;
  61. atomic_t rui_refcount;
  62. atomic_t rui_next_extent;
  63. unsigned long rui_flags; /* misc flags */
  64. struct xfs_rui_log_format rui_format;
  65. };
  66. static inline size_t
  67. xfs_rui_log_item_sizeof(
  68. unsigned int nr)
  69. {
  70. return offsetof(struct xfs_rui_log_item, rui_format) +
  71. xfs_rui_log_format_sizeof(nr);
  72. }
  73. /*
  74. * This is the "rmap update done" log item. It is used to log the fact that
  75. * some rmapbt updates mentioned in an earlier rui item have been performed.
  76. */
  77. struct xfs_rud_log_item {
  78. struct xfs_log_item rud_item;
  79. struct xfs_rui_log_item *rud_ruip;
  80. struct xfs_rud_log_format rud_format;
  81. };
  82. extern struct kmem_zone *xfs_rui_zone;
  83. extern struct kmem_zone *xfs_rud_zone;
  84. struct xfs_rui_log_item *xfs_rui_init(struct xfs_mount *, uint);
  85. struct xfs_rud_log_item *xfs_rud_init(struct xfs_mount *,
  86. struct xfs_rui_log_item *);
  87. int xfs_rui_copy_format(struct xfs_log_iovec *buf,
  88. struct xfs_rui_log_format *dst_rui_fmt);
  89. void xfs_rui_item_free(struct xfs_rui_log_item *);
  90. void xfs_rui_release(struct xfs_rui_log_item *);
  91. int xfs_rui_recover(struct xfs_mount *mp, struct xfs_rui_log_item *ruip);
  92. #endif /* __XFS_RMAP_ITEM_H__ */