xfs_extfree_item.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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_zone;
  11. /*
  12. * Max number of extents in fast allocation path.
  13. */
  14. #define XFS_EFI_MAX_FAST_EXTENTS 16
  15. /*
  16. * Define EFI flag bits. Manipulated by set/clear/test_bit operators.
  17. */
  18. #define XFS_EFI_RECOVERED 1
  19. /*
  20. * This is the "extent free intention" log item. It is used to log the fact
  21. * that some extents need to be free. It is used in conjunction with the
  22. * "extent free done" log item described below.
  23. *
  24. * The EFI is reference counted so that it is not freed prior to both the EFI
  25. * and EFD being committed and unpinned. This ensures the EFI is inserted into
  26. * the AIL even in the event of out of order EFI/EFD processing. In other words,
  27. * an EFI is born with two references:
  28. *
  29. * 1.) an EFI held reference to track EFI AIL insertion
  30. * 2.) an EFD held reference to track EFD commit
  31. *
  32. * On allocation, both references are the responsibility of the caller. Once the
  33. * EFI is added to and dirtied in a transaction, ownership of reference one
  34. * transfers to the transaction. The reference is dropped once the EFI is
  35. * inserted to the AIL or in the event of failure along the way (e.g., commit
  36. * failure, log I/O error, etc.). Note that the caller remains responsible for
  37. * the EFD reference under all circumstances to this point. The caller has no
  38. * means to detect failure once the transaction is committed, however.
  39. * Therefore, an EFD is required after this point, even in the event of
  40. * unrelated failure.
  41. *
  42. * Once an EFD is allocated and dirtied in a transaction, reference two
  43. * transfers to the transaction. The EFD reference is dropped once it reaches
  44. * the unpin handler. Similar to the EFI, the reference also drops in the event
  45. * of commit failure or log I/O errors. Note that the EFD is not inserted in the
  46. * AIL, so at this point both the EFI and EFD are freed.
  47. */
  48. typedef struct xfs_efi_log_item {
  49. xfs_log_item_t efi_item;
  50. atomic_t efi_refcount;
  51. atomic_t efi_next_extent;
  52. unsigned long efi_flags; /* misc flags */
  53. xfs_efi_log_format_t efi_format;
  54. } xfs_efi_log_item_t;
  55. /*
  56. * This is the "extent free done" log item. It is used to log
  57. * the fact that some extents earlier mentioned in an efi item
  58. * have been freed.
  59. */
  60. typedef struct xfs_efd_log_item {
  61. xfs_log_item_t efd_item;
  62. xfs_efi_log_item_t *efd_efip;
  63. uint efd_next_extent;
  64. xfs_efd_log_format_t efd_format;
  65. } xfs_efd_log_item_t;
  66. /*
  67. * Max number of extents in fast allocation path.
  68. */
  69. #define XFS_EFD_MAX_FAST_EXTENTS 16
  70. extern struct kmem_zone *xfs_efi_zone;
  71. extern struct kmem_zone *xfs_efd_zone;
  72. xfs_efi_log_item_t *xfs_efi_init(struct xfs_mount *, uint);
  73. xfs_efd_log_item_t *xfs_efd_init(struct xfs_mount *, xfs_efi_log_item_t *,
  74. uint);
  75. int xfs_efi_copy_format(xfs_log_iovec_t *buf,
  76. xfs_efi_log_format_t *dst_efi_fmt);
  77. void xfs_efi_item_free(xfs_efi_log_item_t *);
  78. void xfs_efi_release(struct xfs_efi_log_item *);
  79. int xfs_efi_recover(struct xfs_mount *mp,
  80. struct xfs_efi_log_item *efip);
  81. #endif /* __XFS_EXTFREE_ITEM_H__ */