xfs_trans_priv.h 4.3 KB

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