2 * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
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.
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.
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
18 #ifndef __XFS_TRANS_PRIV_H__
19 #define __XFS_TRANS_PRIV_H__
28 void xfs_trans_init(struct xfs_mount *);
29 void xfs_trans_add_item(struct xfs_trans *, struct xfs_log_item *);
30 void xfs_trans_del_item(struct xfs_log_item *);
31 void xfs_trans_free_items(struct xfs_trans *tp, xfs_lsn_t commit_lsn,
33 void xfs_trans_unreserve_and_mod_sb(struct xfs_trans *tp);
35 void xfs_trans_committed_bulk(struct xfs_ail *ailp, struct xfs_log_vec *lv,
36 xfs_lsn_t commit_lsn, int aborted);
38 * AIL traversal cursor.
40 * Rather than using a generation number for detecting changes in the ail, use
41 * a cursor that is protected by the ail lock. The aild cursor exists in the
42 * struct xfs_ail, but other traversals can declare it on the stack and link it
45 * When an object is deleted from or moved int the AIL, the cursor list is
46 * searched to see if the object is a designated cursor item. If it is, it is
47 * deleted from the cursor so that the next time the cursor is used traversal
48 * will return to the start.
50 * This means a traversal colliding with a removal will cause a restart of the
51 * list scan, rather than any insertion or deletion anywhere in the list. The
52 * low bit of the item pointer is set if the cursor has been invalidated so
53 * that we can tell the difference between invalidation and reaching the end
54 * of the list to trigger traversal restarts.
56 struct xfs_ail_cursor {
57 struct list_head list;
58 struct xfs_log_item *item;
62 * Private AIL structures.
64 * Eventually we need to drive the locking in here as well.
67 struct xfs_mount *ail_mount;
68 struct task_struct *ail_task;
69 struct list_head ail_head;
71 xfs_lsn_t ail_target_prev;
72 struct list_head ail_cursors;
74 xfs_lsn_t ail_last_pushed_lsn;
76 struct list_head ail_buf_list;
77 wait_queue_head_t ail_empty;
81 * From xfs_trans_ail.c
83 void xfs_trans_ail_update_bulk(struct xfs_ail *ailp,
84 struct xfs_ail_cursor *cur,
85 struct xfs_log_item **log_items, int nr_items,
86 xfs_lsn_t lsn) __releases(ailp->ail_lock);
88 * Return a pointer to the first item in the AIL. If the AIL is empty, then
91 static inline struct xfs_log_item *
95 return list_first_entry_or_null(&ailp->ail_head, struct xfs_log_item,
100 xfs_trans_ail_update(
101 struct xfs_ail *ailp,
102 struct xfs_log_item *lip,
103 xfs_lsn_t lsn) __releases(ailp->ail_lock)
105 xfs_trans_ail_update_bulk(ailp, NULL, &lip, 1, lsn);
108 bool xfs_ail_delete_one(struct xfs_ail *ailp, struct xfs_log_item *lip);
109 void xfs_trans_ail_delete(struct xfs_ail *ailp, struct xfs_log_item *lip,
110 int shutdown_type) __releases(ailp->ail_lock);
113 xfs_trans_ail_remove(
114 struct xfs_log_item *lip,
117 struct xfs_ail *ailp = lip->li_ailp;
119 spin_lock(&ailp->ail_lock);
120 /* xfs_trans_ail_delete() drops the AIL lock */
121 if (test_bit(XFS_LI_IN_AIL, &lip->li_flags))
122 xfs_trans_ail_delete(ailp, lip, shutdown_type);
124 spin_unlock(&ailp->ail_lock);
127 void xfs_ail_push(struct xfs_ail *, xfs_lsn_t);
128 void xfs_ail_push_all(struct xfs_ail *);
129 void xfs_ail_push_all_sync(struct xfs_ail *);
130 struct xfs_log_item *xfs_ail_min(struct xfs_ail *ailp);
131 xfs_lsn_t xfs_ail_min_lsn(struct xfs_ail *ailp);
133 struct xfs_log_item * xfs_trans_ail_cursor_first(struct xfs_ail *ailp,
134 struct xfs_ail_cursor *cur,
136 struct xfs_log_item * xfs_trans_ail_cursor_last(struct xfs_ail *ailp,
137 struct xfs_ail_cursor *cur,
139 struct xfs_log_item * xfs_trans_ail_cursor_next(struct xfs_ail *ailp,
140 struct xfs_ail_cursor *cur);
141 void xfs_trans_ail_cursor_done(struct xfs_ail_cursor *cur);
143 #if BITS_PER_LONG != 64
145 xfs_trans_ail_copy_lsn(
146 struct xfs_ail *ailp,
150 ASSERT(sizeof(xfs_lsn_t) == 8); /* don't lock if it shrinks */
151 spin_lock(&ailp->ail_lock);
153 spin_unlock(&ailp->ail_lock);
157 xfs_trans_ail_copy_lsn(
158 struct xfs_ail *ailp,
162 ASSERT(sizeof(xfs_lsn_t) == 8);
169 struct xfs_log_item *lip)
171 struct xfs_buf *bp = lip->li_buf;
173 ASSERT(test_bit(XFS_LI_IN_AIL, &lip->li_flags));
174 lockdep_assert_held(&lip->li_ailp->ail_lock);
176 if (test_and_clear_bit(XFS_LI_FAILED, &lip->li_flags)) {
184 struct xfs_log_item *lip,
187 lockdep_assert_held(&lip->li_ailp->ail_lock);
189 if (!test_and_set_bit(XFS_LI_FAILED, &lip->li_flags)) {
195 #endif /* __XFS_TRANS_PRIV_H__ */