xfs_extfree_item.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. * 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. /*
  51. * This is the "extent free done" log item. It is used to log
  52. * the fact that some extents earlier mentioned in an efi item
  53. * have been freed.
  54. */
  55. struct xfs_efd_log_item {
  56. struct xfs_log_item efd_item;
  57. struct xfs_efi_log_item *efd_efip;
  58. uint efd_next_extent;
  59. xfs_efd_log_format_t efd_format;
  60. };
  61. /*
  62. * Max number of extents in fast allocation path.
  63. */
  64. #define XFS_EFD_MAX_FAST_EXTENTS 16
  65. extern struct kmem_zone *xfs_efi_zone;
  66. extern struct kmem_zone *xfs_efd_zone;
  67. #endif /* __XFS_EXTFREE_ITEM_H__ */