xfs_trans_priv.h 3.8 KB

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