xfs_trans_ail.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  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. #include "xfs.h"
  19. #include "xfs_fs.h"
  20. #include "xfs_types.h"
  21. #include "xfs_log.h"
  22. #include "xfs_inum.h"
  23. #include "xfs_trans.h"
  24. #include "xfs_sb.h"
  25. #include "xfs_ag.h"
  26. #include "xfs_dmapi.h"
  27. #include "xfs_mount.h"
  28. #include "xfs_trans_priv.h"
  29. #include "xfs_error.h"
  30. STATIC void xfs_ail_insert(xfs_ail_entry_t *, xfs_log_item_t *);
  31. STATIC xfs_log_item_t * xfs_ail_delete(xfs_ail_entry_t *, xfs_log_item_t *);
  32. STATIC xfs_log_item_t * xfs_ail_min(xfs_ail_entry_t *);
  33. STATIC xfs_log_item_t * xfs_ail_next(xfs_ail_entry_t *, xfs_log_item_t *);
  34. #ifdef DEBUG
  35. STATIC void xfs_ail_check(xfs_ail_entry_t *, xfs_log_item_t *);
  36. #else
  37. #define xfs_ail_check(a,l)
  38. #endif /* DEBUG */
  39. /*
  40. * This is called by the log manager code to determine the LSN
  41. * of the tail of the log. This is exactly the LSN of the first
  42. * item in the AIL. If the AIL is empty, then this function
  43. * returns 0.
  44. *
  45. * We need the AIL lock in order to get a coherent read of the
  46. * lsn of the last item in the AIL.
  47. */
  48. xfs_lsn_t
  49. xfs_trans_tail_ail(
  50. xfs_mount_t *mp)
  51. {
  52. xfs_lsn_t lsn;
  53. xfs_log_item_t *lip;
  54. spin_lock(&mp->m_ail_lock);
  55. lip = xfs_ail_min(&(mp->m_ail.xa_ail));
  56. if (lip == NULL) {
  57. lsn = (xfs_lsn_t)0;
  58. } else {
  59. lsn = lip->li_lsn;
  60. }
  61. spin_unlock(&mp->m_ail_lock);
  62. return lsn;
  63. }
  64. /*
  65. * xfs_trans_push_ail
  66. *
  67. * This routine is called to move the tail of the AIL forward. It does this by
  68. * trying to flush items in the AIL whose lsns are below the given
  69. * threshold_lsn.
  70. *
  71. * the push is run asynchronously in a separate thread, so we return the tail
  72. * of the log right now instead of the tail after the push. This means we will
  73. * either continue right away, or we will sleep waiting on the async thread to
  74. * do it's work.
  75. *
  76. * We do this unlocked - we only need to know whether there is anything in the
  77. * AIL at the time we are called. We don't need to access the contents of
  78. * any of the objects, so the lock is not needed.
  79. */
  80. void
  81. xfs_trans_push_ail(
  82. xfs_mount_t *mp,
  83. xfs_lsn_t threshold_lsn)
  84. {
  85. xfs_log_item_t *lip;
  86. lip = xfs_ail_min(&mp->m_ail.xa_ail);
  87. if (lip && !XFS_FORCED_SHUTDOWN(mp)) {
  88. if (XFS_LSN_CMP(threshold_lsn, mp->m_ail.xa_target) > 0)
  89. xfsaild_wakeup(mp, threshold_lsn);
  90. }
  91. }
  92. /*
  93. * Return the item in the AIL with the current lsn.
  94. * Return the current tree generation number for use
  95. * in calls to xfs_trans_next_ail().
  96. */
  97. STATIC xfs_log_item_t *
  98. xfs_trans_first_push_ail(
  99. xfs_mount_t *mp,
  100. int *gen,
  101. xfs_lsn_t lsn)
  102. {
  103. xfs_log_item_t *lip;
  104. lip = xfs_ail_min(&(mp->m_ail.xa_ail));
  105. *gen = (int)mp->m_ail.xa_gen;
  106. if (lsn == 0)
  107. return lip;
  108. while (lip && (XFS_LSN_CMP(lip->li_lsn, lsn) < 0))
  109. lip = lip->li_ail.ail_forw;
  110. return lip;
  111. }
  112. /*
  113. * Function that does the work of pushing on the AIL
  114. */
  115. long
  116. xfsaild_push(
  117. xfs_mount_t *mp,
  118. xfs_lsn_t *last_lsn)
  119. {
  120. long tout = 1000; /* milliseconds */
  121. xfs_lsn_t last_pushed_lsn = *last_lsn;
  122. xfs_lsn_t target = mp->m_ail.xa_target;
  123. xfs_lsn_t lsn;
  124. xfs_log_item_t *lip;
  125. int gen;
  126. int restarts;
  127. int flush_log, count, stuck;
  128. #define XFS_TRANS_PUSH_AIL_RESTARTS 10
  129. spin_lock(&mp->m_ail_lock);
  130. lip = xfs_trans_first_push_ail(mp, &gen, *last_lsn);
  131. if (!lip || XFS_FORCED_SHUTDOWN(mp)) {
  132. /*
  133. * AIL is empty or our push has reached the end.
  134. */
  135. spin_unlock(&mp->m_ail_lock);
  136. last_pushed_lsn = 0;
  137. goto out;
  138. }
  139. XFS_STATS_INC(xs_push_ail);
  140. /*
  141. * While the item we are looking at is below the given threshold
  142. * try to flush it out. We'd like not to stop until we've at least
  143. * tried to push on everything in the AIL with an LSN less than
  144. * the given threshold.
  145. *
  146. * However, we will stop after a certain number of pushes and wait
  147. * for a reduced timeout to fire before pushing further. This
  148. * prevents use from spinning when we can't do anything or there is
  149. * lots of contention on the AIL lists.
  150. */
  151. tout = 10;
  152. lsn = lip->li_lsn;
  153. flush_log = stuck = count = restarts = 0;
  154. while ((XFS_LSN_CMP(lip->li_lsn, target) < 0)) {
  155. int lock_result;
  156. /*
  157. * If we can lock the item without sleeping, unlock the AIL
  158. * lock and flush the item. Then re-grab the AIL lock so we
  159. * can look for the next item on the AIL. List changes are
  160. * handled by the AIL lookup functions internally
  161. *
  162. * If we can't lock the item, either its holder will flush it
  163. * or it is already being flushed or it is being relogged. In
  164. * any of these case it is being taken care of and we can just
  165. * skip to the next item in the list.
  166. */
  167. lock_result = IOP_TRYLOCK(lip);
  168. spin_unlock(&mp->m_ail_lock);
  169. switch (lock_result) {
  170. case XFS_ITEM_SUCCESS:
  171. XFS_STATS_INC(xs_push_ail_success);
  172. IOP_PUSH(lip);
  173. last_pushed_lsn = lsn;
  174. break;
  175. case XFS_ITEM_PUSHBUF:
  176. XFS_STATS_INC(xs_push_ail_pushbuf);
  177. IOP_PUSHBUF(lip);
  178. last_pushed_lsn = lsn;
  179. break;
  180. case XFS_ITEM_PINNED:
  181. XFS_STATS_INC(xs_push_ail_pinned);
  182. stuck++;
  183. flush_log = 1;
  184. break;
  185. case XFS_ITEM_LOCKED:
  186. XFS_STATS_INC(xs_push_ail_locked);
  187. last_pushed_lsn = lsn;
  188. stuck++;
  189. break;
  190. case XFS_ITEM_FLUSHING:
  191. XFS_STATS_INC(xs_push_ail_flushing);
  192. last_pushed_lsn = lsn;
  193. stuck++;
  194. break;
  195. default:
  196. ASSERT(0);
  197. break;
  198. }
  199. spin_lock(&mp->m_ail_lock);
  200. /* should we bother continuing? */
  201. if (XFS_FORCED_SHUTDOWN(mp))
  202. break;
  203. ASSERT(mp->m_log);
  204. count++;
  205. /*
  206. * Are there too many items we can't do anything with?
  207. * If we we are skipping too many items because we can't flush
  208. * them or they are already being flushed, we back off and
  209. * given them time to complete whatever operation is being
  210. * done. i.e. remove pressure from the AIL while we can't make
  211. * progress so traversals don't slow down further inserts and
  212. * removals to/from the AIL.
  213. *
  214. * The value of 100 is an arbitrary magic number based on
  215. * observation.
  216. */
  217. if (stuck > 100)
  218. break;
  219. lip = xfs_trans_next_ail(mp, lip, &gen, &restarts);
  220. if (lip == NULL)
  221. break;
  222. if (restarts > XFS_TRANS_PUSH_AIL_RESTARTS)
  223. break;
  224. lsn = lip->li_lsn;
  225. }
  226. spin_unlock(&mp->m_ail_lock);
  227. if (flush_log) {
  228. /*
  229. * If something we need to push out was pinned, then
  230. * push out the log so it will become unpinned and
  231. * move forward in the AIL.
  232. */
  233. XFS_STATS_INC(xs_push_ail_flush);
  234. xfs_log_force(mp, (xfs_lsn_t)0, XFS_LOG_FORCE);
  235. }
  236. /*
  237. * We reached the target so wait a bit longer for I/O to complete and
  238. * remove pushed items from the AIL before we start the next scan from
  239. * the start of the AIL.
  240. */
  241. if ((XFS_LSN_CMP(lsn, target) >= 0)) {
  242. tout += 20;
  243. last_pushed_lsn = 0;
  244. } else if ((restarts > XFS_TRANS_PUSH_AIL_RESTARTS) ||
  245. (count && ((stuck * 100) / count > 90))) {
  246. /*
  247. * Either there is a lot of contention on the AIL or we
  248. * are stuck due to operations in progress. "Stuck" in this
  249. * case is defined as >90% of the items we tried to push
  250. * were stuck.
  251. *
  252. * Backoff a bit more to allow some I/O to complete before
  253. * continuing from where we were.
  254. */
  255. tout += 10;
  256. }
  257. out:
  258. *last_lsn = last_pushed_lsn;
  259. return tout;
  260. } /* xfsaild_push */
  261. /*
  262. * This is to be called when an item is unlocked that may have
  263. * been in the AIL. It will wake up the first member of the AIL
  264. * wait list if this item's unlocking might allow it to progress.
  265. * If the item is in the AIL, then we need to get the AIL lock
  266. * while doing our checking so we don't race with someone going
  267. * to sleep waiting for this event in xfs_trans_push_ail().
  268. */
  269. void
  270. xfs_trans_unlocked_item(
  271. xfs_mount_t *mp,
  272. xfs_log_item_t *lip)
  273. {
  274. xfs_log_item_t *min_lip;
  275. /*
  276. * If we're forcibly shutting down, we may have
  277. * unlocked log items arbitrarily. The last thing
  278. * we want to do is to move the tail of the log
  279. * over some potentially valid data.
  280. */
  281. if (!(lip->li_flags & XFS_LI_IN_AIL) ||
  282. XFS_FORCED_SHUTDOWN(mp)) {
  283. return;
  284. }
  285. /*
  286. * This is the one case where we can call into xfs_ail_min()
  287. * without holding the AIL lock because we only care about the
  288. * case where we are at the tail of the AIL. If the object isn't
  289. * at the tail, it doesn't matter what result we get back. This
  290. * is slightly racy because since we were just unlocked, we could
  291. * go to sleep between the call to xfs_ail_min and the call to
  292. * xfs_log_move_tail, have someone else lock us, commit to us disk,
  293. * move us out of the tail of the AIL, and then we wake up. However,
  294. * the call to xfs_log_move_tail() doesn't do anything if there's
  295. * not enough free space to wake people up so we're safe calling it.
  296. */
  297. min_lip = xfs_ail_min(&mp->m_ail.xa_ail);
  298. if (min_lip == lip)
  299. xfs_log_move_tail(mp, 1);
  300. } /* xfs_trans_unlocked_item */
  301. /*
  302. * Update the position of the item in the AIL with the new
  303. * lsn. If it is not yet in the AIL, add it. Otherwise, move
  304. * it to its new position by removing it and re-adding it.
  305. *
  306. * Wakeup anyone with an lsn less than the item's lsn. If the item
  307. * we move in the AIL is the minimum one, update the tail lsn in the
  308. * log manager.
  309. *
  310. * Increment the AIL's generation count to indicate that the tree
  311. * has changed.
  312. *
  313. * This function must be called with the AIL lock held. The lock
  314. * is dropped before returning.
  315. */
  316. void
  317. xfs_trans_update_ail(
  318. xfs_mount_t *mp,
  319. xfs_log_item_t *lip,
  320. xfs_lsn_t lsn) __releases(mp->m_ail_lock)
  321. {
  322. xfs_ail_entry_t *ailp;
  323. xfs_log_item_t *dlip=NULL;
  324. xfs_log_item_t *mlip; /* ptr to minimum lip */
  325. ailp = &(mp->m_ail.xa_ail);
  326. mlip = xfs_ail_min(ailp);
  327. if (lip->li_flags & XFS_LI_IN_AIL) {
  328. dlip = xfs_ail_delete(ailp, lip);
  329. ASSERT(dlip == lip);
  330. } else {
  331. lip->li_flags |= XFS_LI_IN_AIL;
  332. }
  333. lip->li_lsn = lsn;
  334. xfs_ail_insert(ailp, lip);
  335. mp->m_ail.xa_gen++;
  336. if (mlip == dlip) {
  337. mlip = xfs_ail_min(&(mp->m_ail.xa_ail));
  338. spin_unlock(&mp->m_ail_lock);
  339. xfs_log_move_tail(mp, mlip->li_lsn);
  340. } else {
  341. spin_unlock(&mp->m_ail_lock);
  342. }
  343. } /* xfs_trans_update_ail */
  344. /*
  345. * Delete the given item from the AIL. It must already be in
  346. * the AIL.
  347. *
  348. * Wakeup anyone with an lsn less than item's lsn. If the item
  349. * we delete in the AIL is the minimum one, update the tail lsn in the
  350. * log manager.
  351. *
  352. * Clear the IN_AIL flag from the item, reset its lsn to 0, and
  353. * bump the AIL's generation count to indicate that the tree
  354. * has changed.
  355. *
  356. * This function must be called with the AIL lock held. The lock
  357. * is dropped before returning.
  358. */
  359. void
  360. xfs_trans_delete_ail(
  361. xfs_mount_t *mp,
  362. xfs_log_item_t *lip) __releases(mp->m_ail_lock)
  363. {
  364. xfs_ail_entry_t *ailp;
  365. xfs_log_item_t *dlip;
  366. xfs_log_item_t *mlip;
  367. if (lip->li_flags & XFS_LI_IN_AIL) {
  368. ailp = &(mp->m_ail.xa_ail);
  369. mlip = xfs_ail_min(ailp);
  370. dlip = xfs_ail_delete(ailp, lip);
  371. ASSERT(dlip == lip);
  372. lip->li_flags &= ~XFS_LI_IN_AIL;
  373. lip->li_lsn = 0;
  374. mp->m_ail.xa_gen++;
  375. if (mlip == dlip) {
  376. mlip = xfs_ail_min(&(mp->m_ail.xa_ail));
  377. spin_unlock(&mp->m_ail_lock);
  378. xfs_log_move_tail(mp, (mlip ? mlip->li_lsn : 0));
  379. } else {
  380. spin_unlock(&mp->m_ail_lock);
  381. }
  382. }
  383. else {
  384. /*
  385. * If the file system is not being shutdown, we are in
  386. * serious trouble if we get to this stage.
  387. */
  388. if (XFS_FORCED_SHUTDOWN(mp))
  389. spin_unlock(&mp->m_ail_lock);
  390. else {
  391. xfs_cmn_err(XFS_PTAG_AILDELETE, CE_ALERT, mp,
  392. "%s: attempting to delete a log item that is not in the AIL",
  393. __FUNCTION__);
  394. spin_unlock(&mp->m_ail_lock);
  395. xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
  396. }
  397. }
  398. }
  399. /*
  400. * Return the item in the AIL with the smallest lsn.
  401. * Return the current tree generation number for use
  402. * in calls to xfs_trans_next_ail().
  403. */
  404. xfs_log_item_t *
  405. xfs_trans_first_ail(
  406. xfs_mount_t *mp,
  407. int *gen)
  408. {
  409. xfs_log_item_t *lip;
  410. lip = xfs_ail_min(&(mp->m_ail.xa_ail));
  411. *gen = (int)mp->m_ail.xa_gen;
  412. return lip;
  413. }
  414. /*
  415. * If the generation count of the tree has not changed since the
  416. * caller last took something from the AIL, then return the elmt
  417. * in the tree which follows the one given. If the count has changed,
  418. * then return the minimum elmt of the AIL and bump the restarts counter
  419. * if one is given.
  420. */
  421. xfs_log_item_t *
  422. xfs_trans_next_ail(
  423. xfs_mount_t *mp,
  424. xfs_log_item_t *lip,
  425. int *gen,
  426. int *restarts)
  427. {
  428. xfs_log_item_t *nlip;
  429. ASSERT(mp && lip && gen);
  430. if (mp->m_ail.xa_gen == *gen) {
  431. nlip = xfs_ail_next(&(mp->m_ail.xa_ail), lip);
  432. } else {
  433. nlip = xfs_ail_min(&(mp->m_ail).xa_ail);
  434. *gen = (int)mp->m_ail.xa_gen;
  435. if (restarts != NULL) {
  436. XFS_STATS_INC(xs_push_ail_restarts);
  437. (*restarts)++;
  438. }
  439. }
  440. return (nlip);
  441. }
  442. /*
  443. * The active item list (AIL) is a doubly linked list of log
  444. * items sorted by ascending lsn. The base of the list is
  445. * a forw/back pointer pair embedded in the xfs mount structure.
  446. * The base is initialized with both pointers pointing to the
  447. * base. This case always needs to be distinguished, because
  448. * the base has no lsn to look at. We almost always insert
  449. * at the end of the list, so on inserts we search from the
  450. * end of the list to find where the new item belongs.
  451. */
  452. /*
  453. * Initialize the doubly linked list to point only to itself.
  454. */
  455. int
  456. xfs_trans_ail_init(
  457. xfs_mount_t *mp)
  458. {
  459. mp->m_ail.xa_ail.ail_forw = (xfs_log_item_t*)&mp->m_ail.xa_ail;
  460. mp->m_ail.xa_ail.ail_back = (xfs_log_item_t*)&mp->m_ail.xa_ail;
  461. return xfsaild_start(mp);
  462. }
  463. void
  464. xfs_trans_ail_destroy(
  465. xfs_mount_t *mp)
  466. {
  467. xfsaild_stop(mp);
  468. }
  469. /*
  470. * Insert the given log item into the AIL.
  471. * We almost always insert at the end of the list, so on inserts
  472. * we search from the end of the list to find where the
  473. * new item belongs.
  474. */
  475. STATIC void
  476. xfs_ail_insert(
  477. xfs_ail_entry_t *base,
  478. xfs_log_item_t *lip)
  479. /* ARGSUSED */
  480. {
  481. xfs_log_item_t *next_lip;
  482. /*
  483. * If the list is empty, just insert the item.
  484. */
  485. if (base->ail_back == (xfs_log_item_t*)base) {
  486. base->ail_forw = lip;
  487. base->ail_back = lip;
  488. lip->li_ail.ail_forw = (xfs_log_item_t*)base;
  489. lip->li_ail.ail_back = (xfs_log_item_t*)base;
  490. return;
  491. }
  492. next_lip = base->ail_back;
  493. while ((next_lip != (xfs_log_item_t*)base) &&
  494. (XFS_LSN_CMP(next_lip->li_lsn, lip->li_lsn) > 0)) {
  495. next_lip = next_lip->li_ail.ail_back;
  496. }
  497. ASSERT((next_lip == (xfs_log_item_t*)base) ||
  498. (XFS_LSN_CMP(next_lip->li_lsn, lip->li_lsn) <= 0));
  499. lip->li_ail.ail_forw = next_lip->li_ail.ail_forw;
  500. lip->li_ail.ail_back = next_lip;
  501. next_lip->li_ail.ail_forw = lip;
  502. lip->li_ail.ail_forw->li_ail.ail_back = lip;
  503. xfs_ail_check(base, lip);
  504. return;
  505. }
  506. /*
  507. * Delete the given item from the AIL. Return a pointer to the item.
  508. */
  509. /*ARGSUSED*/
  510. STATIC xfs_log_item_t *
  511. xfs_ail_delete(
  512. xfs_ail_entry_t *base,
  513. xfs_log_item_t *lip)
  514. /* ARGSUSED */
  515. {
  516. xfs_ail_check(base, lip);
  517. lip->li_ail.ail_forw->li_ail.ail_back = lip->li_ail.ail_back;
  518. lip->li_ail.ail_back->li_ail.ail_forw = lip->li_ail.ail_forw;
  519. lip->li_ail.ail_forw = NULL;
  520. lip->li_ail.ail_back = NULL;
  521. return lip;
  522. }
  523. /*
  524. * Return a pointer to the first item in the AIL.
  525. * If the AIL is empty, then return NULL.
  526. */
  527. STATIC xfs_log_item_t *
  528. xfs_ail_min(
  529. xfs_ail_entry_t *base)
  530. /* ARGSUSED */
  531. {
  532. register xfs_log_item_t *forw = base->ail_forw;
  533. if (forw == (xfs_log_item_t*)base) {
  534. return NULL;
  535. }
  536. return forw;
  537. }
  538. /*
  539. * Return a pointer to the item which follows
  540. * the given item in the AIL. If the given item
  541. * is the last item in the list, then return NULL.
  542. */
  543. STATIC xfs_log_item_t *
  544. xfs_ail_next(
  545. xfs_ail_entry_t *base,
  546. xfs_log_item_t *lip)
  547. /* ARGSUSED */
  548. {
  549. if (lip->li_ail.ail_forw == (xfs_log_item_t*)base) {
  550. return NULL;
  551. }
  552. return lip->li_ail.ail_forw;
  553. }
  554. #ifdef DEBUG
  555. /*
  556. * Check that the list is sorted as it should be.
  557. */
  558. STATIC void
  559. xfs_ail_check(
  560. xfs_ail_entry_t *base,
  561. xfs_log_item_t *lip)
  562. {
  563. xfs_log_item_t *prev_lip;
  564. prev_lip = base->ail_forw;
  565. if (prev_lip == (xfs_log_item_t*)base) {
  566. /*
  567. * Make sure the pointers are correct when the list
  568. * is empty.
  569. */
  570. ASSERT(base->ail_back == (xfs_log_item_t*)base);
  571. return;
  572. }
  573. /*
  574. * Check the next and previous entries are valid.
  575. */
  576. ASSERT((lip->li_flags & XFS_LI_IN_AIL) != 0);
  577. prev_lip = lip->li_ail.ail_back;
  578. if (prev_lip != (xfs_log_item_t*)base) {
  579. ASSERT(prev_lip->li_ail.ail_forw == lip);
  580. ASSERT(XFS_LSN_CMP(prev_lip->li_lsn, lip->li_lsn) <= 0);
  581. }
  582. prev_lip = lip->li_ail.ail_forw;
  583. if (prev_lip != (xfs_log_item_t*)base) {
  584. ASSERT(prev_lip->li_ail.ail_back == lip);
  585. ASSERT(XFS_LSN_CMP(prev_lip->li_lsn, lip->li_lsn) >= 0);
  586. }
  587. #ifdef XFS_TRANS_DEBUG
  588. /*
  589. * Walk the list checking forward and backward pointers,
  590. * lsn ordering, and that every entry has the XFS_LI_IN_AIL
  591. * flag set. This is really expensive, so only do it when
  592. * specifically debugging the transaction subsystem.
  593. */
  594. prev_lip = (xfs_log_item_t*)base;
  595. while (lip != (xfs_log_item_t*)base) {
  596. if (prev_lip != (xfs_log_item_t*)base) {
  597. ASSERT(prev_lip->li_ail.ail_forw == lip);
  598. ASSERT(XFS_LSN_CMP(prev_lip->li_lsn, lip->li_lsn) <= 0);
  599. }
  600. ASSERT(lip->li_ail.ail_back == prev_lip);
  601. ASSERT((lip->li_flags & XFS_LI_IN_AIL) != 0);
  602. prev_lip = lip;
  603. lip = lip->li_ail.ail_forw;
  604. }
  605. ASSERT(lip == (xfs_log_item_t*)base);
  606. ASSERT(base->ail_back == prev_lip);
  607. #endif /* XFS_TRANS_DEBUG */
  608. }
  609. #endif /* DEBUG */