xfs_bmap_item.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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_BMAP_ITEM_H__
  21. #define __XFS_BMAP_ITEM_H__
  22. /*
  23. * There are (currently) two pairs of bmap btree redo item types: map & unmap.
  24. * The common abbreviations for these are BUI (bmap update intent) and BUD
  25. * (bmap update done). The redo item type is encoded in the flags field of
  26. * 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 bmbt updates.
  31. *
  32. * Should the system crash after the commit of the first transaction but
  33. * before the commit of the final transaction in a series, log recovery will
  34. * use the redo information recorded by the intent items to replay the
  35. * bmbt metadata updates in the non-first transaction.
  36. */
  37. /* kernel only BUI/BUD definitions */
  38. struct xfs_mount;
  39. struct kmem_zone;
  40. /*
  41. * Max number of extents in fast allocation path.
  42. */
  43. #define XFS_BUI_MAX_FAST_EXTENTS 1
  44. /*
  45. * Define BUI flag bits. Manipulated by set/clear/test_bit operators.
  46. */
  47. #define XFS_BUI_RECOVERED 1
  48. /*
  49. * This is the "bmap update intent" log item. It is used to log the fact that
  50. * some reverse mappings need to change. It is used in conjunction with the
  51. * "bmap update done" log item described below.
  52. *
  53. * These log items follow the same rules as struct xfs_efi_log_item; see the
  54. * comments about that structure (in xfs_extfree_item.h) for more details.
  55. */
  56. struct xfs_bui_log_item {
  57. struct xfs_log_item bui_item;
  58. atomic_t bui_refcount;
  59. atomic_t bui_next_extent;
  60. unsigned long bui_flags; /* misc flags */
  61. struct xfs_bui_log_format bui_format;
  62. };
  63. static inline size_t
  64. xfs_bui_log_item_sizeof(
  65. unsigned int nr)
  66. {
  67. return offsetof(struct xfs_bui_log_item, bui_format) +
  68. xfs_bui_log_format_sizeof(nr);
  69. }
  70. /*
  71. * This is the "bmap update done" log item. It is used to log the fact that
  72. * some bmbt updates mentioned in an earlier bui item have been performed.
  73. */
  74. struct xfs_bud_log_item {
  75. struct xfs_log_item bud_item;
  76. struct xfs_bui_log_item *bud_buip;
  77. struct xfs_bud_log_format bud_format;
  78. };
  79. extern struct kmem_zone *xfs_bui_zone;
  80. extern struct kmem_zone *xfs_bud_zone;
  81. struct xfs_bui_log_item *xfs_bui_init(struct xfs_mount *);
  82. struct xfs_bud_log_item *xfs_bud_init(struct xfs_mount *,
  83. struct xfs_bui_log_item *);
  84. void xfs_bui_item_free(struct xfs_bui_log_item *);
  85. void xfs_bui_release(struct xfs_bui_log_item *);
  86. int xfs_bui_recover(struct xfs_mount *mp, struct xfs_bui_log_item *buip);
  87. #endif /* __XFS_BMAP_ITEM_H__ */