diff options
Diffstat (limited to 'fs/xfs/xfs_trans_ail.c')
-rw-r--r-- | fs/xfs/xfs_trans_ail.c | 340 |
1 files changed, 220 insertions, 120 deletions
diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c index 5b2ff59f19cf..4d6330eddc8d 100644 --- a/fs/xfs/xfs_trans_ail.c +++ b/fs/xfs/xfs_trans_ail.c | |||
@@ -34,9 +34,9 @@ STATIC xfs_log_item_t * xfs_ail_min(xfs_ail_entry_t *); | |||
34 | STATIC xfs_log_item_t * xfs_ail_next(xfs_ail_entry_t *, xfs_log_item_t *); | 34 | STATIC xfs_log_item_t * xfs_ail_next(xfs_ail_entry_t *, xfs_log_item_t *); |
35 | 35 | ||
36 | #ifdef DEBUG | 36 | #ifdef DEBUG |
37 | STATIC void xfs_ail_check(xfs_ail_entry_t *); | 37 | STATIC void xfs_ail_check(xfs_ail_entry_t *, xfs_log_item_t *); |
38 | #else | 38 | #else |
39 | #define xfs_ail_check(a) | 39 | #define xfs_ail_check(a,l) |
40 | #endif /* DEBUG */ | 40 | #endif /* DEBUG */ |
41 | 41 | ||
42 | 42 | ||
@@ -55,16 +55,15 @@ xfs_trans_tail_ail( | |||
55 | { | 55 | { |
56 | xfs_lsn_t lsn; | 56 | xfs_lsn_t lsn; |
57 | xfs_log_item_t *lip; | 57 | xfs_log_item_t *lip; |
58 | SPLDECL(s); | ||
59 | 58 | ||
60 | AIL_LOCK(mp,s); | 59 | spin_lock(&mp->m_ail_lock); |
61 | lip = xfs_ail_min(&(mp->m_ail)); | 60 | lip = xfs_ail_min(&(mp->m_ail.xa_ail)); |
62 | if (lip == NULL) { | 61 | if (lip == NULL) { |
63 | lsn = (xfs_lsn_t)0; | 62 | lsn = (xfs_lsn_t)0; |
64 | } else { | 63 | } else { |
65 | lsn = lip->li_lsn; | 64 | lsn = lip->li_lsn; |
66 | } | 65 | } |
67 | AIL_UNLOCK(mp, s); | 66 | spin_unlock(&mp->m_ail_lock); |
68 | 67 | ||
69 | return lsn; | 68 | return lsn; |
70 | } | 69 | } |
@@ -72,120 +71,185 @@ xfs_trans_tail_ail( | |||
72 | /* | 71 | /* |
73 | * xfs_trans_push_ail | 72 | * xfs_trans_push_ail |
74 | * | 73 | * |
75 | * This routine is called to move the tail of the AIL | 74 | * This routine is called to move the tail of the AIL forward. It does this by |
76 | * forward. It does this by trying to flush items in the AIL | 75 | * trying to flush items in the AIL whose lsns are below the given |
77 | * whose lsns are below the given threshold_lsn. | 76 | * threshold_lsn. |
78 | * | 77 | * |
79 | * The routine returns the lsn of the tail of the log. | 78 | * the push is run asynchronously in a separate thread, so we return the tail |
79 | * of the log right now instead of the tail after the push. This means we will | ||
80 | * either continue right away, or we will sleep waiting on the async thread to | ||
81 | * do it's work. | ||
82 | * | ||
83 | * We do this unlocked - we only need to know whether there is anything in the | ||
84 | * AIL at the time we are called. We don't need to access the contents of | ||
85 | * any of the objects, so the lock is not needed. | ||
80 | */ | 86 | */ |
81 | xfs_lsn_t | 87 | void |
82 | xfs_trans_push_ail( | 88 | xfs_trans_push_ail( |
83 | xfs_mount_t *mp, | 89 | xfs_mount_t *mp, |
84 | xfs_lsn_t threshold_lsn) | 90 | xfs_lsn_t threshold_lsn) |
85 | { | 91 | { |
86 | xfs_lsn_t lsn; | ||
87 | xfs_log_item_t *lip; | 92 | xfs_log_item_t *lip; |
88 | int gen; | ||
89 | int restarts; | ||
90 | int lock_result; | ||
91 | int flush_log; | ||
92 | SPLDECL(s); | ||
93 | 93 | ||
94 | #define XFS_TRANS_PUSH_AIL_RESTARTS 1000 | 94 | lip = xfs_ail_min(&mp->m_ail.xa_ail); |
95 | if (lip && !XFS_FORCED_SHUTDOWN(mp)) { | ||
96 | if (XFS_LSN_CMP(threshold_lsn, mp->m_ail.xa_target) > 0) | ||
97 | xfsaild_wakeup(mp, threshold_lsn); | ||
98 | } | ||
99 | } | ||
100 | |||
101 | /* | ||
102 | * Return the item in the AIL with the current lsn. | ||
103 | * Return the current tree generation number for use | ||
104 | * in calls to xfs_trans_next_ail(). | ||
105 | */ | ||
106 | STATIC xfs_log_item_t * | ||
107 | xfs_trans_first_push_ail( | ||
108 | xfs_mount_t *mp, | ||
109 | int *gen, | ||
110 | xfs_lsn_t lsn) | ||
111 | { | ||
112 | xfs_log_item_t *lip; | ||
113 | |||
114 | lip = xfs_ail_min(&(mp->m_ail.xa_ail)); | ||
115 | *gen = (int)mp->m_ail.xa_gen; | ||
116 | if (lsn == 0) | ||
117 | return lip; | ||
118 | |||
119 | while (lip && (XFS_LSN_CMP(lip->li_lsn, lsn) < 0)) | ||
120 | lip = lip->li_ail.ail_forw; | ||
95 | 121 | ||
96 | AIL_LOCK(mp,s); | 122 | return lip; |
97 | lip = xfs_trans_first_ail(mp, &gen); | 123 | } |
98 | if (lip == NULL || XFS_FORCED_SHUTDOWN(mp)) { | 124 | |
125 | /* | ||
126 | * Function that does the work of pushing on the AIL | ||
127 | */ | ||
128 | long | ||
129 | xfsaild_push( | ||
130 | xfs_mount_t *mp, | ||
131 | xfs_lsn_t *last_lsn) | ||
132 | { | ||
133 | long tout = 1000; /* milliseconds */ | ||
134 | xfs_lsn_t last_pushed_lsn = *last_lsn; | ||
135 | xfs_lsn_t target = mp->m_ail.xa_target; | ||
136 | xfs_lsn_t lsn; | ||
137 | xfs_log_item_t *lip; | ||
138 | int gen; | ||
139 | int restarts; | ||
140 | int flush_log, count, stuck; | ||
141 | |||
142 | #define XFS_TRANS_PUSH_AIL_RESTARTS 10 | ||
143 | |||
144 | spin_lock(&mp->m_ail_lock); | ||
145 | lip = xfs_trans_first_push_ail(mp, &gen, *last_lsn); | ||
146 | if (!lip || XFS_FORCED_SHUTDOWN(mp)) { | ||
99 | /* | 147 | /* |
100 | * Just return if the AIL is empty. | 148 | * AIL is empty or our push has reached the end. |
101 | */ | 149 | */ |
102 | AIL_UNLOCK(mp, s); | 150 | spin_unlock(&mp->m_ail_lock); |
103 | return (xfs_lsn_t)0; | 151 | last_pushed_lsn = 0; |
152 | goto out; | ||
104 | } | 153 | } |
105 | 154 | ||
106 | XFS_STATS_INC(xs_push_ail); | 155 | XFS_STATS_INC(xs_push_ail); |
107 | 156 | ||
108 | /* | 157 | /* |
109 | * While the item we are looking at is below the given threshold | 158 | * While the item we are looking at is below the given threshold |
110 | * try to flush it out. Make sure to limit the number of times | 159 | * try to flush it out. We'd like not to stop until we've at least |
111 | * we allow xfs_trans_next_ail() to restart scanning from the | ||
112 | * beginning of the list. We'd like not to stop until we've at least | ||
113 | * tried to push on everything in the AIL with an LSN less than | 160 | * tried to push on everything in the AIL with an LSN less than |
114 | * the given threshold. However, we may give up before that if | 161 | * the given threshold. |
115 | * we realize that we've been holding the AIL_LOCK for 'too long', | 162 | * |
116 | * blocking interrupts. Currently, too long is < 500us roughly. | 163 | * However, we will stop after a certain number of pushes and wait |
164 | * for a reduced timeout to fire before pushing further. This | ||
165 | * prevents use from spinning when we can't do anything or there is | ||
166 | * lots of contention on the AIL lists. | ||
117 | */ | 167 | */ |
118 | flush_log = 0; | 168 | tout = 10; |
119 | restarts = 0; | 169 | lsn = lip->li_lsn; |
120 | while (((restarts < XFS_TRANS_PUSH_AIL_RESTARTS) && | 170 | flush_log = stuck = count = restarts = 0; |
121 | (XFS_LSN_CMP(lip->li_lsn, threshold_lsn) < 0))) { | 171 | while ((XFS_LSN_CMP(lip->li_lsn, target) < 0)) { |
172 | int lock_result; | ||
122 | /* | 173 | /* |
123 | * If we can lock the item without sleeping, unlock | 174 | * If we can lock the item without sleeping, unlock the AIL |
124 | * the AIL lock and flush the item. Then re-grab the | 175 | * lock and flush the item. Then re-grab the AIL lock so we |
125 | * AIL lock so we can look for the next item on the | 176 | * can look for the next item on the AIL. List changes are |
126 | * AIL. Since we unlock the AIL while we flush the | 177 | * handled by the AIL lookup functions internally |
127 | * item, the next routine may start over again at the | ||
128 | * the beginning of the list if anything has changed. | ||
129 | * That is what the generation count is for. | ||
130 | * | 178 | * |
131 | * If we can't lock the item, either its holder will flush | 179 | * If we can't lock the item, either its holder will flush it |
132 | * it or it is already being flushed or it is being relogged. | 180 | * or it is already being flushed or it is being relogged. In |
133 | * In any of these case it is being taken care of and we | 181 | * any of these case it is being taken care of and we can just |
134 | * can just skip to the next item in the list. | 182 | * skip to the next item in the list. |
135 | */ | 183 | */ |
136 | lock_result = IOP_TRYLOCK(lip); | 184 | lock_result = IOP_TRYLOCK(lip); |
185 | spin_unlock(&mp->m_ail_lock); | ||
137 | switch (lock_result) { | 186 | switch (lock_result) { |
138 | case XFS_ITEM_SUCCESS: | 187 | case XFS_ITEM_SUCCESS: |
139 | AIL_UNLOCK(mp, s); | ||
140 | XFS_STATS_INC(xs_push_ail_success); | 188 | XFS_STATS_INC(xs_push_ail_success); |
141 | IOP_PUSH(lip); | 189 | IOP_PUSH(lip); |
142 | AIL_LOCK(mp,s); | 190 | last_pushed_lsn = lsn; |
143 | break; | 191 | break; |
144 | 192 | ||
145 | case XFS_ITEM_PUSHBUF: | 193 | case XFS_ITEM_PUSHBUF: |
146 | AIL_UNLOCK(mp, s); | ||
147 | XFS_STATS_INC(xs_push_ail_pushbuf); | 194 | XFS_STATS_INC(xs_push_ail_pushbuf); |
148 | #ifdef XFSRACEDEBUG | ||
149 | delay_for_intr(); | ||
150 | delay(300); | ||
151 | #endif | ||
152 | ASSERT(lip->li_ops->iop_pushbuf); | ||
153 | ASSERT(lip); | ||
154 | IOP_PUSHBUF(lip); | 195 | IOP_PUSHBUF(lip); |
155 | AIL_LOCK(mp,s); | 196 | last_pushed_lsn = lsn; |
156 | break; | 197 | break; |
157 | 198 | ||
158 | case XFS_ITEM_PINNED: | 199 | case XFS_ITEM_PINNED: |
159 | XFS_STATS_INC(xs_push_ail_pinned); | 200 | XFS_STATS_INC(xs_push_ail_pinned); |
201 | stuck++; | ||
160 | flush_log = 1; | 202 | flush_log = 1; |
161 | break; | 203 | break; |
162 | 204 | ||
163 | case XFS_ITEM_LOCKED: | 205 | case XFS_ITEM_LOCKED: |
164 | XFS_STATS_INC(xs_push_ail_locked); | 206 | XFS_STATS_INC(xs_push_ail_locked); |
207 | last_pushed_lsn = lsn; | ||
208 | stuck++; | ||
165 | break; | 209 | break; |
166 | 210 | ||
167 | case XFS_ITEM_FLUSHING: | 211 | case XFS_ITEM_FLUSHING: |
168 | XFS_STATS_INC(xs_push_ail_flushing); | 212 | XFS_STATS_INC(xs_push_ail_flushing); |
213 | last_pushed_lsn = lsn; | ||
214 | stuck++; | ||
169 | break; | 215 | break; |
170 | 216 | ||
171 | default: | 217 | default: |
172 | ASSERT(0); | 218 | ASSERT(0); |
173 | break; | 219 | break; |
174 | } | 220 | } |
175 | 221 | ||
176 | lip = xfs_trans_next_ail(mp, lip, &gen, &restarts); | 222 | spin_lock(&mp->m_ail_lock); |
177 | if (lip == NULL) { | 223 | /* should we bother continuing? */ |
224 | if (XFS_FORCED_SHUTDOWN(mp)) | ||
225 | break; | ||
226 | ASSERT(mp->m_log); | ||
227 | |||
228 | count++; | ||
229 | |||
230 | /* | ||
231 | * Are there too many items we can't do anything with? | ||
232 | * If we we are skipping too many items because we can't flush | ||
233 | * them or they are already being flushed, we back off and | ||
234 | * given them time to complete whatever operation is being | ||
235 | * done. i.e. remove pressure from the AIL while we can't make | ||
236 | * progress so traversals don't slow down further inserts and | ||
237 | * removals to/from the AIL. | ||
238 | * | ||
239 | * The value of 100 is an arbitrary magic number based on | ||
240 | * observation. | ||
241 | */ | ||
242 | if (stuck > 100) | ||
178 | break; | 243 | break; |
179 | } | ||
180 | if (XFS_FORCED_SHUTDOWN(mp)) { | ||
181 | /* | ||
182 | * Just return if we shut down during the last try. | ||
183 | */ | ||
184 | AIL_UNLOCK(mp, s); | ||
185 | return (xfs_lsn_t)0; | ||
186 | } | ||
187 | 244 | ||
245 | lip = xfs_trans_next_ail(mp, lip, &gen, &restarts); | ||
246 | if (lip == NULL) | ||
247 | break; | ||
248 | if (restarts > XFS_TRANS_PUSH_AIL_RESTARTS) | ||
249 | break; | ||
250 | lsn = lip->li_lsn; | ||
188 | } | 251 | } |
252 | spin_unlock(&mp->m_ail_lock); | ||
189 | 253 | ||
190 | if (flush_log) { | 254 | if (flush_log) { |
191 | /* | 255 | /* |
@@ -193,22 +257,35 @@ xfs_trans_push_ail( | |||
193 | * push out the log so it will become unpinned and | 257 | * push out the log so it will become unpinned and |
194 | * move forward in the AIL. | 258 | * move forward in the AIL. |
195 | */ | 259 | */ |
196 | AIL_UNLOCK(mp, s); | ||
197 | XFS_STATS_INC(xs_push_ail_flush); | 260 | XFS_STATS_INC(xs_push_ail_flush); |
198 | xfs_log_force(mp, (xfs_lsn_t)0, XFS_LOG_FORCE); | 261 | xfs_log_force(mp, (xfs_lsn_t)0, XFS_LOG_FORCE); |
199 | AIL_LOCK(mp, s); | ||
200 | } | 262 | } |
201 | 263 | ||
202 | lip = xfs_ail_min(&(mp->m_ail)); | 264 | /* |
203 | if (lip == NULL) { | 265 | * We reached the target so wait a bit longer for I/O to complete and |
204 | lsn = (xfs_lsn_t)0; | 266 | * remove pushed items from the AIL before we start the next scan from |
205 | } else { | 267 | * the start of the AIL. |
206 | lsn = lip->li_lsn; | 268 | */ |
269 | if ((XFS_LSN_CMP(lsn, target) >= 0)) { | ||
270 | tout += 20; | ||
271 | last_pushed_lsn = 0; | ||
272 | } else if ((restarts > XFS_TRANS_PUSH_AIL_RESTARTS) || | ||
273 | (count && ((stuck * 100) / count > 90))) { | ||
274 | /* | ||
275 | * Either there is a lot of contention on the AIL or we | ||
276 | * are stuck due to operations in progress. "Stuck" in this | ||
277 | * case is defined as >90% of the items we tried to push | ||
278 | * were stuck. | ||
279 | * | ||
280 | * Backoff a bit more to allow some I/O to complete before | ||
281 | * continuing from where we were. | ||
282 | */ | ||
283 | tout += 10; | ||
207 | } | 284 | } |
208 | 285 | out: | |
209 | AIL_UNLOCK(mp, s); | 286 | *last_lsn = last_pushed_lsn; |
210 | return lsn; | 287 | return tout; |
211 | } /* xfs_trans_push_ail */ | 288 | } /* xfsaild_push */ |
212 | 289 | ||
213 | 290 | ||
214 | /* | 291 | /* |
@@ -249,7 +326,7 @@ xfs_trans_unlocked_item( | |||
249 | * the call to xfs_log_move_tail() doesn't do anything if there's | 326 | * the call to xfs_log_move_tail() doesn't do anything if there's |
250 | * not enough free space to wake people up so we're safe calling it. | 327 | * not enough free space to wake people up so we're safe calling it. |
251 | */ | 328 | */ |
252 | min_lip = xfs_ail_min(&mp->m_ail); | 329 | min_lip = xfs_ail_min(&mp->m_ail.xa_ail); |
253 | 330 | ||
254 | if (min_lip == lip) | 331 | if (min_lip == lip) |
255 | xfs_log_move_tail(mp, 1); | 332 | xfs_log_move_tail(mp, 1); |
@@ -269,21 +346,19 @@ xfs_trans_unlocked_item( | |||
269 | * has changed. | 346 | * has changed. |
270 | * | 347 | * |
271 | * This function must be called with the AIL lock held. The lock | 348 | * This function must be called with the AIL lock held. The lock |
272 | * is dropped before returning, so the caller must pass in the | 349 | * is dropped before returning. |
273 | * cookie returned by AIL_LOCK. | ||
274 | */ | 350 | */ |
275 | void | 351 | void |
276 | xfs_trans_update_ail( | 352 | xfs_trans_update_ail( |
277 | xfs_mount_t *mp, | 353 | xfs_mount_t *mp, |
278 | xfs_log_item_t *lip, | 354 | xfs_log_item_t *lip, |
279 | xfs_lsn_t lsn, | 355 | xfs_lsn_t lsn) __releases(mp->m_ail_lock) |
280 | unsigned long s) __releases(mp->m_ail_lock) | ||
281 | { | 356 | { |
282 | xfs_ail_entry_t *ailp; | 357 | xfs_ail_entry_t *ailp; |
283 | xfs_log_item_t *dlip=NULL; | 358 | xfs_log_item_t *dlip=NULL; |
284 | xfs_log_item_t *mlip; /* ptr to minimum lip */ | 359 | xfs_log_item_t *mlip; /* ptr to minimum lip */ |
285 | 360 | ||
286 | ailp = &(mp->m_ail); | 361 | ailp = &(mp->m_ail.xa_ail); |
287 | mlip = xfs_ail_min(ailp); | 362 | mlip = xfs_ail_min(ailp); |
288 | 363 | ||
289 | if (lip->li_flags & XFS_LI_IN_AIL) { | 364 | if (lip->li_flags & XFS_LI_IN_AIL) { |
@@ -296,14 +371,14 @@ xfs_trans_update_ail( | |||
296 | lip->li_lsn = lsn; | 371 | lip->li_lsn = lsn; |
297 | 372 | ||
298 | xfs_ail_insert(ailp, lip); | 373 | xfs_ail_insert(ailp, lip); |
299 | mp->m_ail_gen++; | 374 | mp->m_ail.xa_gen++; |
300 | 375 | ||
301 | if (mlip == dlip) { | 376 | if (mlip == dlip) { |
302 | mlip = xfs_ail_min(&(mp->m_ail)); | 377 | mlip = xfs_ail_min(&(mp->m_ail.xa_ail)); |
303 | AIL_UNLOCK(mp, s); | 378 | spin_unlock(&mp->m_ail_lock); |
304 | xfs_log_move_tail(mp, mlip->li_lsn); | 379 | xfs_log_move_tail(mp, mlip->li_lsn); |
305 | } else { | 380 | } else { |
306 | AIL_UNLOCK(mp, s); | 381 | spin_unlock(&mp->m_ail_lock); |
307 | } | 382 | } |
308 | 383 | ||
309 | 384 | ||
@@ -322,21 +397,19 @@ xfs_trans_update_ail( | |||
322 | * has changed. | 397 | * has changed. |
323 | * | 398 | * |
324 | * This function must be called with the AIL lock held. The lock | 399 | * This function must be called with the AIL lock held. The lock |
325 | * is dropped before returning, so the caller must pass in the | 400 | * is dropped before returning. |
326 | * cookie returned by AIL_LOCK. | ||
327 | */ | 401 | */ |
328 | void | 402 | void |
329 | xfs_trans_delete_ail( | 403 | xfs_trans_delete_ail( |
330 | xfs_mount_t *mp, | 404 | xfs_mount_t *mp, |
331 | xfs_log_item_t *lip, | 405 | xfs_log_item_t *lip) __releases(mp->m_ail_lock) |
332 | unsigned long s) __releases(mp->m_ail_lock) | ||
333 | { | 406 | { |
334 | xfs_ail_entry_t *ailp; | 407 | xfs_ail_entry_t *ailp; |
335 | xfs_log_item_t *dlip; | 408 | xfs_log_item_t *dlip; |
336 | xfs_log_item_t *mlip; | 409 | xfs_log_item_t *mlip; |
337 | 410 | ||
338 | if (lip->li_flags & XFS_LI_IN_AIL) { | 411 | if (lip->li_flags & XFS_LI_IN_AIL) { |
339 | ailp = &(mp->m_ail); | 412 | ailp = &(mp->m_ail.xa_ail); |
340 | mlip = xfs_ail_min(ailp); | 413 | mlip = xfs_ail_min(ailp); |
341 | dlip = xfs_ail_delete(ailp, lip); | 414 | dlip = xfs_ail_delete(ailp, lip); |
342 | ASSERT(dlip == lip); | 415 | ASSERT(dlip == lip); |
@@ -344,14 +417,14 @@ xfs_trans_delete_ail( | |||
344 | 417 | ||
345 | lip->li_flags &= ~XFS_LI_IN_AIL; | 418 | lip->li_flags &= ~XFS_LI_IN_AIL; |
346 | lip->li_lsn = 0; | 419 | lip->li_lsn = 0; |
347 | mp->m_ail_gen++; | 420 | mp->m_ail.xa_gen++; |
348 | 421 | ||
349 | if (mlip == dlip) { | 422 | if (mlip == dlip) { |
350 | mlip = xfs_ail_min(&(mp->m_ail)); | 423 | mlip = xfs_ail_min(&(mp->m_ail.xa_ail)); |
351 | AIL_UNLOCK(mp, s); | 424 | spin_unlock(&mp->m_ail_lock); |
352 | xfs_log_move_tail(mp, (mlip ? mlip->li_lsn : 0)); | 425 | xfs_log_move_tail(mp, (mlip ? mlip->li_lsn : 0)); |
353 | } else { | 426 | } else { |
354 | AIL_UNLOCK(mp, s); | 427 | spin_unlock(&mp->m_ail_lock); |
355 | } | 428 | } |
356 | } | 429 | } |
357 | else { | 430 | else { |
@@ -360,12 +433,12 @@ xfs_trans_delete_ail( | |||
360 | * serious trouble if we get to this stage. | 433 | * serious trouble if we get to this stage. |
361 | */ | 434 | */ |
362 | if (XFS_FORCED_SHUTDOWN(mp)) | 435 | if (XFS_FORCED_SHUTDOWN(mp)) |
363 | AIL_UNLOCK(mp, s); | 436 | spin_unlock(&mp->m_ail_lock); |
364 | else { | 437 | else { |
365 | xfs_cmn_err(XFS_PTAG_AILDELETE, CE_ALERT, mp, | 438 | xfs_cmn_err(XFS_PTAG_AILDELETE, CE_ALERT, mp, |
366 | "%s: attempting to delete a log item that is not in the AIL", | 439 | "%s: attempting to delete a log item that is not in the AIL", |
367 | __FUNCTION__); | 440 | __FUNCTION__); |
368 | AIL_UNLOCK(mp, s); | 441 | spin_unlock(&mp->m_ail_lock); |
369 | xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); | 442 | xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); |
370 | } | 443 | } |
371 | } | 444 | } |
@@ -385,10 +458,10 @@ xfs_trans_first_ail( | |||
385 | { | 458 | { |
386 | xfs_log_item_t *lip; | 459 | xfs_log_item_t *lip; |
387 | 460 | ||
388 | lip = xfs_ail_min(&(mp->m_ail)); | 461 | lip = xfs_ail_min(&(mp->m_ail.xa_ail)); |
389 | *gen = (int)mp->m_ail_gen; | 462 | *gen = (int)mp->m_ail.xa_gen; |
390 | 463 | ||
391 | return (lip); | 464 | return lip; |
392 | } | 465 | } |
393 | 466 | ||
394 | /* | 467 | /* |
@@ -408,11 +481,11 @@ xfs_trans_next_ail( | |||
408 | xfs_log_item_t *nlip; | 481 | xfs_log_item_t *nlip; |
409 | 482 | ||
410 | ASSERT(mp && lip && gen); | 483 | ASSERT(mp && lip && gen); |
411 | if (mp->m_ail_gen == *gen) { | 484 | if (mp->m_ail.xa_gen == *gen) { |
412 | nlip = xfs_ail_next(&(mp->m_ail), lip); | 485 | nlip = xfs_ail_next(&(mp->m_ail.xa_ail), lip); |
413 | } else { | 486 | } else { |
414 | nlip = xfs_ail_min(&(mp->m_ail)); | 487 | nlip = xfs_ail_min(&(mp->m_ail).xa_ail); |
415 | *gen = (int)mp->m_ail_gen; | 488 | *gen = (int)mp->m_ail.xa_gen; |
416 | if (restarts != NULL) { | 489 | if (restarts != NULL) { |
417 | XFS_STATS_INC(xs_push_ail_restarts); | 490 | XFS_STATS_INC(xs_push_ail_restarts); |
418 | (*restarts)++; | 491 | (*restarts)++; |
@@ -437,12 +510,20 @@ xfs_trans_next_ail( | |||
437 | /* | 510 | /* |
438 | * Initialize the doubly linked list to point only to itself. | 511 | * Initialize the doubly linked list to point only to itself. |
439 | */ | 512 | */ |
440 | void | 513 | int |
441 | xfs_trans_ail_init( | 514 | xfs_trans_ail_init( |
442 | xfs_mount_t *mp) | 515 | xfs_mount_t *mp) |
443 | { | 516 | { |
444 | mp->m_ail.ail_forw = (xfs_log_item_t*)&(mp->m_ail); | 517 | mp->m_ail.xa_ail.ail_forw = (xfs_log_item_t*)&mp->m_ail.xa_ail; |
445 | mp->m_ail.ail_back = (xfs_log_item_t*)&(mp->m_ail); | 518 | mp->m_ail.xa_ail.ail_back = (xfs_log_item_t*)&mp->m_ail.xa_ail; |
519 | return xfsaild_start(mp); | ||
520 | } | ||
521 | |||
522 | void | ||
523 | xfs_trans_ail_destroy( | ||
524 | xfs_mount_t *mp) | ||
525 | { | ||
526 | xfsaild_stop(mp); | ||
446 | } | 527 | } |
447 | 528 | ||
448 | /* | 529 | /* |
@@ -482,7 +563,7 @@ xfs_ail_insert( | |||
482 | next_lip->li_ail.ail_forw = lip; | 563 | next_lip->li_ail.ail_forw = lip; |
483 | lip->li_ail.ail_forw->li_ail.ail_back = lip; | 564 | lip->li_ail.ail_forw->li_ail.ail_back = lip; |
484 | 565 | ||
485 | xfs_ail_check(base); | 566 | xfs_ail_check(base, lip); |
486 | return; | 567 | return; |
487 | } | 568 | } |
488 | 569 | ||
@@ -496,12 +577,12 @@ xfs_ail_delete( | |||
496 | xfs_log_item_t *lip) | 577 | xfs_log_item_t *lip) |
497 | /* ARGSUSED */ | 578 | /* ARGSUSED */ |
498 | { | 579 | { |
580 | xfs_ail_check(base, lip); | ||
499 | lip->li_ail.ail_forw->li_ail.ail_back = lip->li_ail.ail_back; | 581 | lip->li_ail.ail_forw->li_ail.ail_back = lip->li_ail.ail_back; |
500 | lip->li_ail.ail_back->li_ail.ail_forw = lip->li_ail.ail_forw; | 582 | lip->li_ail.ail_back->li_ail.ail_forw = lip->li_ail.ail_forw; |
501 | lip->li_ail.ail_forw = NULL; | 583 | lip->li_ail.ail_forw = NULL; |
502 | lip->li_ail.ail_back = NULL; | 584 | lip->li_ail.ail_back = NULL; |
503 | 585 | ||
504 | xfs_ail_check(base); | ||
505 | return lip; | 586 | return lip; |
506 | } | 587 | } |
507 | 588 | ||
@@ -545,13 +626,13 @@ xfs_ail_next( | |||
545 | */ | 626 | */ |
546 | STATIC void | 627 | STATIC void |
547 | xfs_ail_check( | 628 | xfs_ail_check( |
548 | xfs_ail_entry_t *base) | 629 | xfs_ail_entry_t *base, |
630 | xfs_log_item_t *lip) | ||
549 | { | 631 | { |
550 | xfs_log_item_t *lip; | ||
551 | xfs_log_item_t *prev_lip; | 632 | xfs_log_item_t *prev_lip; |
552 | 633 | ||
553 | lip = base->ail_forw; | 634 | prev_lip = base->ail_forw; |
554 | if (lip == (xfs_log_item_t*)base) { | 635 | if (prev_lip == (xfs_log_item_t*)base) { |
555 | /* | 636 | /* |
556 | * Make sure the pointers are correct when the list | 637 | * Make sure the pointers are correct when the list |
557 | * is empty. | 638 | * is empty. |
@@ -561,9 +642,27 @@ xfs_ail_check( | |||
561 | } | 642 | } |
562 | 643 | ||
563 | /* | 644 | /* |
645 | * Check the next and previous entries are valid. | ||
646 | */ | ||
647 | ASSERT((lip->li_flags & XFS_LI_IN_AIL) != 0); | ||
648 | prev_lip = lip->li_ail.ail_back; | ||
649 | if (prev_lip != (xfs_log_item_t*)base) { | ||
650 | ASSERT(prev_lip->li_ail.ail_forw == lip); | ||
651 | ASSERT(XFS_LSN_CMP(prev_lip->li_lsn, lip->li_lsn) <= 0); | ||
652 | } | ||
653 | prev_lip = lip->li_ail.ail_forw; | ||
654 | if (prev_lip != (xfs_log_item_t*)base) { | ||
655 | ASSERT(prev_lip->li_ail.ail_back == lip); | ||
656 | ASSERT(XFS_LSN_CMP(prev_lip->li_lsn, lip->li_lsn) >= 0); | ||
657 | } | ||
658 | |||
659 | |||
660 | #ifdef XFS_TRANS_DEBUG | ||
661 | /* | ||
564 | * Walk the list checking forward and backward pointers, | 662 | * Walk the list checking forward and backward pointers, |
565 | * lsn ordering, and that every entry has the XFS_LI_IN_AIL | 663 | * lsn ordering, and that every entry has the XFS_LI_IN_AIL |
566 | * flag set. | 664 | * flag set. This is really expensive, so only do it when |
665 | * specifically debugging the transaction subsystem. | ||
567 | */ | 666 | */ |
568 | prev_lip = (xfs_log_item_t*)base; | 667 | prev_lip = (xfs_log_item_t*)base; |
569 | while (lip != (xfs_log_item_t*)base) { | 668 | while (lip != (xfs_log_item_t*)base) { |
@@ -578,5 +677,6 @@ xfs_ail_check( | |||
578 | } | 677 | } |
579 | ASSERT(lip == (xfs_log_item_t*)base); | 678 | ASSERT(lip == (xfs_log_item_t*)base); |
580 | ASSERT(base->ail_back == prev_lip); | 679 | ASSERT(base->ail_back == prev_lip); |
680 | #endif /* XFS_TRANS_DEBUG */ | ||
581 | } | 681 | } |
582 | #endif /* DEBUG */ | 682 | #endif /* DEBUG */ |