xfs_trans_priv.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * Copyright (c) 2000,2002,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_TRANS_PRIV_H__
  19. #define __XFS_TRANS_PRIV_H__
  20. struct xfs_log_item;
  21. struct xfs_log_item_desc;
  22. struct xfs_mount;
  23. struct xfs_trans;
  24. /*
  25. * From xfs_trans_item.c
  26. */
  27. struct xfs_log_item_desc *xfs_trans_add_item(struct xfs_trans *,
  28. struct xfs_log_item *);
  29. void xfs_trans_free_item(struct xfs_trans *,
  30. struct xfs_log_item_desc *);
  31. struct xfs_log_item_desc *xfs_trans_find_item(struct xfs_trans *,
  32. struct xfs_log_item *);
  33. struct xfs_log_item_desc *xfs_trans_first_item(struct xfs_trans *);
  34. struct xfs_log_item_desc *xfs_trans_next_item(struct xfs_trans *,
  35. struct xfs_log_item_desc *);
  36. void xfs_trans_free_items(struct xfs_trans *, int);
  37. void xfs_trans_unlock_items(struct xfs_trans *,
  38. xfs_lsn_t);
  39. void xfs_trans_free_busy(xfs_trans_t *tp);
  40. xfs_log_busy_slot_t *xfs_trans_add_busy(xfs_trans_t *tp,
  41. xfs_agnumber_t ag,
  42. xfs_extlen_t idx);
  43. /*
  44. * AIL traversal cursor.
  45. *
  46. * Rather than using a generation number for detecting changes in the ail, use
  47. * a cursor that is protected by the ail lock. The aild cursor exists in the
  48. * struct xfs_ail, but other traversals can declare it on the stack and link it
  49. * to the ail list.
  50. *
  51. * When an object is deleted from or moved int the AIL, the cursor list is
  52. * searched to see if the object is a designated cursor item. If it is, it is
  53. * deleted from the cursor so that the next time the cursor is used traversal
  54. * will return to the start.
  55. *
  56. * This means a traversal colliding with a removal will cause a restart of the
  57. * list scan, rather than any insertion or deletion anywhere in the list. The
  58. * low bit of the item pointer is set if the cursor has been invalidated so
  59. * that we can tell the difference between invalidation and reaching the end
  60. * of the list to trigger traversal restarts.
  61. */
  62. struct xfs_ail_cursor {
  63. struct xfs_ail_cursor *next;
  64. struct xfs_log_item *item;
  65. };
  66. /*
  67. * Private AIL structures.
  68. *
  69. * Eventually we need to drive the locking in here as well.
  70. */
  71. struct xfs_ail {
  72. struct xfs_mount *xa_mount;
  73. struct list_head xa_ail;
  74. uint xa_gen;
  75. struct task_struct *xa_task;
  76. xfs_lsn_t xa_target;
  77. struct xfs_ail_cursor xa_cursors;
  78. spinlock_t xa_lock;
  79. };
  80. /*
  81. * From xfs_trans_ail.c
  82. */
  83. void xfs_trans_ail_update(struct xfs_ail *ailp,
  84. struct xfs_log_item *lip, xfs_lsn_t lsn)
  85. __releases(ailp->xa_lock);
  86. void xfs_trans_ail_delete(struct xfs_ail *ailp,
  87. struct xfs_log_item *lip)
  88. __releases(ailp->xa_lock);
  89. void xfs_trans_ail_push(struct xfs_ail *, xfs_lsn_t);
  90. void xfs_trans_unlocked_item(struct xfs_ail *,
  91. xfs_log_item_t *);
  92. xfs_lsn_t xfs_trans_ail_tail(struct xfs_ail *ailp);
  93. struct xfs_log_item *xfs_trans_ail_cursor_first(struct xfs_ail *ailp,
  94. struct xfs_ail_cursor *cur,
  95. xfs_lsn_t lsn);
  96. struct xfs_log_item *xfs_trans_ail_cursor_next(struct xfs_ail *ailp,
  97. struct xfs_ail_cursor *cur);
  98. void xfs_trans_ail_cursor_done(struct xfs_ail *ailp,
  99. struct xfs_ail_cursor *cur);
  100. long xfsaild_push(struct xfs_ail *, xfs_lsn_t *);
  101. void xfsaild_wakeup(struct xfs_ail *, xfs_lsn_t);
  102. int xfsaild_start(struct xfs_ail *);
  103. void xfsaild_stop(struct xfs_ail *);
  104. #if BITS_PER_LONG != 64
  105. static inline void
  106. xfs_trans_ail_copy_lsn(
  107. struct xfs_ail *ailp,
  108. xfs_lsn_t *dst,
  109. xfs_lsn_t *src)
  110. {
  111. ASSERT(sizeof(xfs_lsn_t) == 8); /* don't lock if it shrinks */
  112. spin_lock(&ailp->xa_lock);
  113. *dst = *src;
  114. spin_unlock(&ailp->xa_lock);
  115. }
  116. #else
  117. static inline void
  118. xfs_trans_ail_copy_lsn(
  119. struct xfs_ail *ailp,
  120. xfs_lsn_t *dst,
  121. xfs_lsn_t *src)
  122. {
  123. ASSERT(sizeof(xfs_lsn_t) == 8);
  124. *dst = *src;
  125. }
  126. #endif
  127. #endif /* __XFS_TRANS_PRIV_H__ */