xfs_extfree_item.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2000,2005 Silicon Graphics, Inc.
  4. * All Rights Reserved.
  5. */
  6. #ifndef __XFS_EXTFREE_ITEM_H__
  7. #define __XFS_EXTFREE_ITEM_H__
  8. /* kernel only EFI/EFD definitions */
  9. struct xfs_mount;
  10. struct kmem_cache;
  11. /*
  12. * Max number of extents in fast allocation path.
  13. */
  14. #define XFS_EFI_MAX_FAST_EXTENTS 16
  15. /*
  16. * This is the "extent free intention" log item. It is used to log the fact
  17. * that some extents need to be free. It is used in conjunction with the
  18. * "extent free done" log item described below.
  19. *
  20. * The EFI is reference counted so that it is not freed prior to both the EFI
  21. * and EFD being committed and unpinned. This ensures the EFI is inserted into
  22. * the AIL even in the event of out of order EFI/EFD processing. In other words,
  23. * an EFI is born with two references:
  24. *
  25. * 1.) an EFI held reference to track EFI AIL insertion
  26. * 2.) an EFD held reference to track EFD commit
  27. *
  28. * On allocation, both references are the responsibility of the caller. Once the
  29. * EFI is added to and dirtied in a transaction, ownership of reference one
  30. * transfers to the transaction. The reference is dropped once the EFI is
  31. * inserted to the AIL or in the event of failure along the way (e.g., commit
  32. * failure, log I/O error, etc.). Note that the caller remains responsible for
  33. * the EFD reference under all circumstances to this point. The caller has no
  34. * means to detect failure once the transaction is committed, however.
  35. * Therefore, an EFD is required after this point, even in the event of
  36. * unrelated failure.
  37. *
  38. * Once an EFD is allocated and dirtied in a transaction, reference two
  39. * transfers to the transaction. The EFD reference is dropped once it reaches
  40. * the unpin handler. Similar to the EFI, the reference also drops in the event
  41. * of commit failure or log I/O errors. Note that the EFD is not inserted in the
  42. * AIL, so at this point both the EFI and EFD are freed.
  43. */
  44. struct xfs_efi_log_item {
  45. struct xfs_log_item efi_item;
  46. atomic_t efi_refcount;
  47. atomic_t efi_next_extent;
  48. xfs_efi_log_format_t efi_format;
  49. };
  50. static inline size_t
  51. xfs_efi_log_item_sizeof(
  52. unsigned int nr)
  53. {
  54. return offsetof(struct xfs_efi_log_item, efi_format) +
  55. xfs_efi_log_format_sizeof(nr);
  56. }
  57. /*
  58. * This is the "extent free done" log item. It is used to log
  59. * the fact that some extents earlier mentioned in an efi item
  60. * have been freed.
  61. */
  62. struct xfs_efd_log_item {
  63. struct xfs_log_item efd_item;
  64. struct xfs_efi_log_item *efd_efip;
  65. uint efd_next_extent;
  66. xfs_efd_log_format_t efd_format;
  67. };
  68. static inline size_t
  69. xfs_efd_log_item_sizeof(
  70. unsigned int nr)
  71. {
  72. return offsetof(struct xfs_efd_log_item, efd_format) +
  73. xfs_efd_log_format_sizeof(nr);
  74. }
  75. /*
  76. * Max number of extents in fast allocation path.
  77. */
  78. #define XFS_EFD_MAX_FAST_EXTENTS 16
  79. extern struct kmem_cache *xfs_efi_cache;
  80. extern struct kmem_cache *xfs_efd_cache;
  81. #endif /* __XFS_EXTFREE_ITEM_H__ */