xfs_extfree_item.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Copyright (c) 2000,2005 Silicon Graphics, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it would be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write the Free Software Foundation,
  16. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef __XFS_EXTFREE_ITEM_H__
  19. #define __XFS_EXTFREE_ITEM_H__
  20. /* kernel only EFI/EFD definitions */
  21. struct xfs_mount;
  22. struct kmem_zone;
  23. /*
  24. * Max number of extents in fast allocation path.
  25. */
  26. #define XFS_EFI_MAX_FAST_EXTENTS 16
  27. /*
  28. * Define EFI flag bits. Manipulated by set/clear/test_bit operators.
  29. */
  30. #define XFS_EFI_RECOVERED 1
  31. /*
  32. * This is the "extent free intention" log item. It is used to log the fact
  33. * that some extents need to be free. It is used in conjunction with the
  34. * "extent free done" log item described below.
  35. *
  36. * The EFI is reference counted so that it is not freed prior to both the EFI
  37. * and EFD being committed and unpinned. This ensures the EFI is inserted into
  38. * the AIL even in the event of out of order EFI/EFD processing. In other words,
  39. * an EFI is born with two references:
  40. *
  41. * 1.) an EFI held reference to track EFI AIL insertion
  42. * 2.) an EFD held reference to track EFD commit
  43. *
  44. * On allocation, both references are the responsibility of the caller. Once the
  45. * EFI is added to and dirtied in a transaction, ownership of reference one
  46. * transfers to the transaction. The reference is dropped once the EFI is
  47. * inserted to the AIL or in the event of failure along the way (e.g., commit
  48. * failure, log I/O error, etc.). Note that the caller remains responsible for
  49. * the EFD reference under all circumstances to this point. The caller has no
  50. * means to detect failure once the transaction is committed, however.
  51. * Therefore, an EFD is required after this point, even in the event of
  52. * unrelated failure.
  53. *
  54. * Once an EFD is allocated and dirtied in a transaction, reference two
  55. * transfers to the transaction. The EFD reference is dropped once it reaches
  56. * the unpin handler. Similar to the EFI, the reference also drops in the event
  57. * of commit failure or log I/O errors. Note that the EFD is not inserted in the
  58. * AIL, so at this point both the EFI and EFD are freed.
  59. */
  60. typedef struct xfs_efi_log_item {
  61. xfs_log_item_t efi_item;
  62. atomic_t efi_refcount;
  63. atomic_t efi_next_extent;
  64. unsigned long efi_flags; /* misc flags */
  65. xfs_efi_log_format_t efi_format;
  66. } xfs_efi_log_item_t;
  67. /*
  68. * This is the "extent free done" log item. It is used to log
  69. * the fact that some extents earlier mentioned in an efi item
  70. * have been freed.
  71. */
  72. typedef struct xfs_efd_log_item {
  73. xfs_log_item_t efd_item;
  74. xfs_efi_log_item_t *efd_efip;
  75. uint efd_next_extent;
  76. xfs_efd_log_format_t efd_format;
  77. } xfs_efd_log_item_t;
  78. /*
  79. * Max number of extents in fast allocation path.
  80. */
  81. #define XFS_EFD_MAX_FAST_EXTENTS 16
  82. extern struct kmem_zone *xfs_efi_zone;
  83. extern struct kmem_zone *xfs_efd_zone;
  84. xfs_efi_log_item_t *xfs_efi_init(struct xfs_mount *, uint);
  85. xfs_efd_log_item_t *xfs_efd_init(struct xfs_mount *, xfs_efi_log_item_t *,
  86. uint);
  87. int xfs_efi_copy_format(xfs_log_iovec_t *buf,
  88. xfs_efi_log_format_t *dst_efi_fmt);
  89. void xfs_efi_item_free(xfs_efi_log_item_t *);
  90. void xfs_efi_release(struct xfs_efi_log_item *);
  91. #endif /* __XFS_EXTFREE_ITEM_H__ */