aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_trans_ail.c
diff options
context:
space:
mode:
authorDavid Chinner <david@fromorbit.com>2008-10-30 02:39:23 -0400
committerLachlan McIlroy <lachlan@sgi.com>2008-10-30 02:39:23 -0400
commitc7e8f268278a292d3823b4352182fa7755a71410 (patch)
treef7316f830fdc7feedfd9ae486ac097e8f5df8dad /fs/xfs/xfs_trans_ail.c
parent7b2e2a31f5c23b5f028af8c895137b4c512cc1c8 (diff)
[XFS] Move the AIL lock into the struct xfs_ail
Bring the ail lock inside the struct xfs_ail. This means the AIL can be entirely manipulated via the struct xfs_ail rather than needing both the struct xfs_mount and the struct xfs_ail. SGI-PV: 988143 SGI-Modid: xfs-linux-melb:xfs-kern:32350a Signed-off-by: David Chinner <david@fromorbit.com> Signed-off-by: Lachlan McIlroy <lachlan@sgi.com> Signed-off-by: Christoph Hellwig <hch@infradead.org>
Diffstat (limited to 'fs/xfs/xfs_trans_ail.c')
-rw-r--r--fs/xfs/xfs_trans_ail.c56
1 files changed, 29 insertions, 27 deletions
diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c
index 286934d56ec7..0cd47a797d32 100644
--- a/fs/xfs/xfs_trans_ail.c
+++ b/fs/xfs/xfs_trans_ail.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * Copyright (c) 2008 Dave Chinner
3 * All Rights Reserved. 4 * All Rights Reserved.
4 * 5 *
5 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
@@ -56,14 +57,14 @@ xfs_trans_ail_tail(
56 xfs_lsn_t lsn; 57 xfs_lsn_t lsn;
57 xfs_log_item_t *lip; 58 xfs_log_item_t *lip;
58 59
59 spin_lock(&ailp->xa_mount->m_ail_lock); 60 spin_lock(&ailp->xa_lock);
60 lip = xfs_ail_min(ailp); 61 lip = xfs_ail_min(ailp);
61 if (lip == NULL) { 62 if (lip == NULL) {
62 lsn = (xfs_lsn_t)0; 63 lsn = (xfs_lsn_t)0;
63 } else { 64 } else {
64 lsn = lip->li_lsn; 65 lsn = lip->li_lsn;
65 } 66 }
66 spin_unlock(&ailp->xa_mount->m_ail_lock); 67 spin_unlock(&ailp->xa_lock);
67 68
68 return lsn; 69 return lsn;
69} 70}
@@ -252,7 +253,7 @@ xfsaild_push(
252 xfs_mount_t *mp = ailp->xa_mount; 253 xfs_mount_t *mp = ailp->xa_mount;
253 struct xfs_ail_cursor *cur = &ailp->xa_cursors; 254 struct xfs_ail_cursor *cur = &ailp->xa_cursors;
254 255
255 spin_lock(&mp->m_ail_lock); 256 spin_lock(&ailp->xa_lock);
256 xfs_trans_ail_cursor_init(ailp, cur); 257 xfs_trans_ail_cursor_init(ailp, cur);
257 lip = xfs_trans_ail_cursor_first(ailp, cur, *last_lsn); 258 lip = xfs_trans_ail_cursor_first(ailp, cur, *last_lsn);
258 if (!lip || XFS_FORCED_SHUTDOWN(mp)) { 259 if (!lip || XFS_FORCED_SHUTDOWN(mp)) {
@@ -260,7 +261,7 @@ xfsaild_push(
260 * AIL is empty or our push has reached the end. 261 * AIL is empty or our push has reached the end.
261 */ 262 */
262 xfs_trans_ail_cursor_done(ailp, cur); 263 xfs_trans_ail_cursor_done(ailp, cur);
263 spin_unlock(&mp->m_ail_lock); 264 spin_unlock(&ailp->xa_lock);
264 last_pushed_lsn = 0; 265 last_pushed_lsn = 0;
265 return tout; 266 return tout;
266 } 267 }
@@ -295,7 +296,7 @@ xfsaild_push(
295 * skip to the next item in the list. 296 * skip to the next item in the list.
296 */ 297 */
297 lock_result = IOP_TRYLOCK(lip); 298 lock_result = IOP_TRYLOCK(lip);
298 spin_unlock(&mp->m_ail_lock); 299 spin_unlock(&ailp->xa_lock);
299 switch (lock_result) { 300 switch (lock_result) {
300 case XFS_ITEM_SUCCESS: 301 case XFS_ITEM_SUCCESS:
301 XFS_STATS_INC(xs_push_ail_success); 302 XFS_STATS_INC(xs_push_ail_success);
@@ -332,7 +333,7 @@ xfsaild_push(
332 break; 333 break;
333 } 334 }
334 335
335 spin_lock(&mp->m_ail_lock); 336 spin_lock(&ailp->xa_lock);
336 /* should we bother continuing? */ 337 /* should we bother continuing? */
337 if (XFS_FORCED_SHUTDOWN(mp)) 338 if (XFS_FORCED_SHUTDOWN(mp))
338 break; 339 break;
@@ -361,7 +362,7 @@ xfsaild_push(
361 lsn = lip->li_lsn; 362 lsn = lip->li_lsn;
362 } 363 }
363 xfs_trans_ail_cursor_done(ailp, cur); 364 xfs_trans_ail_cursor_done(ailp, cur);
364 spin_unlock(&mp->m_ail_lock); 365 spin_unlock(&ailp->xa_lock);
365 366
366 if (flush_log) { 367 if (flush_log) {
367 /* 368 /*
@@ -462,30 +463,31 @@ void
462xfs_trans_update_ail( 463xfs_trans_update_ail(
463 xfs_mount_t *mp, 464 xfs_mount_t *mp,
464 xfs_log_item_t *lip, 465 xfs_log_item_t *lip,
465 xfs_lsn_t lsn) __releases(mp->m_ail_lock) 466 xfs_lsn_t lsn) __releases(ailp->xa_lock)
466{ 467{
467 xfs_log_item_t *dlip=NULL; 468 struct xfs_ail *ailp = mp->m_ail;
469 xfs_log_item_t *dlip = NULL;
468 xfs_log_item_t *mlip; /* ptr to minimum lip */ 470 xfs_log_item_t *mlip; /* ptr to minimum lip */
469 471
470 mlip = xfs_ail_min(mp->m_ail); 472 mlip = xfs_ail_min(ailp);
471 473
472 if (lip->li_flags & XFS_LI_IN_AIL) { 474 if (lip->li_flags & XFS_LI_IN_AIL) {
473 dlip = xfs_ail_delete(mp->m_ail, lip); 475 dlip = xfs_ail_delete(ailp, lip);
474 ASSERT(dlip == lip); 476 ASSERT(dlip == lip);
475 xfs_trans_ail_cursor_clear(mp->m_ail, dlip); 477 xfs_trans_ail_cursor_clear(ailp, dlip);
476 } else { 478 } else {
477 lip->li_flags |= XFS_LI_IN_AIL; 479 lip->li_flags |= XFS_LI_IN_AIL;
478 } 480 }
479 481
480 lip->li_lsn = lsn; 482 lip->li_lsn = lsn;
481 xfs_ail_insert(mp->m_ail, lip); 483 xfs_ail_insert(ailp, lip);
482 484
483 if (mlip == dlip) { 485 if (mlip == dlip) {
484 mlip = xfs_ail_min(mp->m_ail); 486 mlip = xfs_ail_min(ailp);
485 spin_unlock(&mp->m_ail_lock); 487 spin_unlock(&ailp->xa_lock);
486 xfs_log_move_tail(mp, mlip->li_lsn); 488 xfs_log_move_tail(mp, mlip->li_lsn);
487 } else { 489 } else {
488 spin_unlock(&mp->m_ail_lock); 490 spin_unlock(&ailp->xa_lock);
489 } 491 }
490 492
491 493
@@ -509,27 +511,28 @@ xfs_trans_update_ail(
509void 511void
510xfs_trans_delete_ail( 512xfs_trans_delete_ail(
511 xfs_mount_t *mp, 513 xfs_mount_t *mp,
512 xfs_log_item_t *lip) __releases(mp->m_ail_lock) 514 xfs_log_item_t *lip) __releases(ailp->xa_lock)
513{ 515{
516 struct xfs_ail *ailp = mp->m_ail;
514 xfs_log_item_t *dlip; 517 xfs_log_item_t *dlip;
515 xfs_log_item_t *mlip; 518 xfs_log_item_t *mlip;
516 519
517 if (lip->li_flags & XFS_LI_IN_AIL) { 520 if (lip->li_flags & XFS_LI_IN_AIL) {
518 mlip = xfs_ail_min(mp->m_ail); 521 mlip = xfs_ail_min(ailp);
519 dlip = xfs_ail_delete(mp->m_ail, lip); 522 dlip = xfs_ail_delete(ailp, lip);
520 ASSERT(dlip == lip); 523 ASSERT(dlip == lip);
521 xfs_trans_ail_cursor_clear(mp->m_ail, dlip); 524 xfs_trans_ail_cursor_clear(ailp, dlip);
522 525
523 526
524 lip->li_flags &= ~XFS_LI_IN_AIL; 527 lip->li_flags &= ~XFS_LI_IN_AIL;
525 lip->li_lsn = 0; 528 lip->li_lsn = 0;
526 529
527 if (mlip == dlip) { 530 if (mlip == dlip) {
528 mlip = xfs_ail_min(mp->m_ail); 531 mlip = xfs_ail_min(ailp);
529 spin_unlock(&mp->m_ail_lock); 532 spin_unlock(&ailp->xa_lock);
530 xfs_log_move_tail(mp, (mlip ? mlip->li_lsn : 0)); 533 xfs_log_move_tail(mp, (mlip ? mlip->li_lsn : 0));
531 } else { 534 } else {
532 spin_unlock(&mp->m_ail_lock); 535 spin_unlock(&ailp->xa_lock);
533 } 536 }
534 } 537 }
535 else { 538 else {
@@ -537,13 +540,11 @@ xfs_trans_delete_ail(
537 * If the file system is not being shutdown, we are in 540 * If the file system is not being shutdown, we are in
538 * serious trouble if we get to this stage. 541 * serious trouble if we get to this stage.
539 */ 542 */
540 if (XFS_FORCED_SHUTDOWN(mp)) 543 spin_unlock(&ailp->xa_lock);
541 spin_unlock(&mp->m_ail_lock); 544 if (!XFS_FORCED_SHUTDOWN(mp)) {
542 else {
543 xfs_cmn_err(XFS_PTAG_AILDELETE, CE_ALERT, mp, 545 xfs_cmn_err(XFS_PTAG_AILDELETE, CE_ALERT, mp,
544 "%s: attempting to delete a log item that is not in the AIL", 546 "%s: attempting to delete a log item that is not in the AIL",
545 __func__); 547 __func__);
546 spin_unlock(&mp->m_ail_lock);
547 xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); 548 xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
548 } 549 }
549 } 550 }
@@ -578,6 +579,7 @@ xfs_trans_ail_init(
578 579
579 ailp->xa_mount = mp; 580 ailp->xa_mount = mp;
580 INIT_LIST_HEAD(&ailp->xa_ail); 581 INIT_LIST_HEAD(&ailp->xa_ail);
582 spin_lock_init(&ailp->xa_lock);
581 error = xfsaild_start(ailp); 583 error = xfsaild_start(ailp);
582 if (error) 584 if (error)
583 goto out_free_ailp; 585 goto out_free_ailp;