xfs_trans_priv.h 3.8 KB

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