aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_trans_ail.c
diff options
context:
space:
mode:
authorDavid Chinner <david@fromorbit.com>2008-10-30 02:38:26 -0400
committerLachlan McIlroy <lachlan@sgi.com>2008-10-30 02:38:26 -0400
commit82fa9012458d867936d7bf130e6e14bdebc6873c (patch)
treee2d8d7aa9a30c55b7d314df7406f1c47832340d7 /fs/xfs/xfs_trans_ail.c
parenta7444053fb3ebd3d905e3c7a7bd5ea80a54b083a (diff)
[XFS] Allocate the struct xfs_ail
Rather than embedding the struct xfs_ail in the struct xfs_mount, allocate it during AIL initialisation. Add a back pointer to the struct xfs_ail so that we can pass around the xfs_ail and still be able to access the xfs_mount if need be. This is th first step involved in isolating the AIL implementation from the surrounding filesystem code. SGI-PV: 988143 SGI-Modid: xfs-linux-melb:xfs-kern:32346a 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.c87
1 files changed, 49 insertions, 38 deletions
diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c
index 1f77c00af566..db72b52cd428 100644
--- a/fs/xfs/xfs_trans_ail.c
+++ b/fs/xfs/xfs_trans_ail.c
@@ -28,13 +28,13 @@
28#include "xfs_trans_priv.h" 28#include "xfs_trans_priv.h"
29#include "xfs_error.h" 29#include "xfs_error.h"
30 30
31STATIC void xfs_ail_insert(xfs_ail_t *, xfs_log_item_t *); 31STATIC void xfs_ail_insert(struct xfs_ail *, xfs_log_item_t *);
32STATIC xfs_log_item_t * xfs_ail_delete(xfs_ail_t *, xfs_log_item_t *); 32STATIC xfs_log_item_t * xfs_ail_delete(struct xfs_ail *, xfs_log_item_t *);
33STATIC xfs_log_item_t * xfs_ail_min(xfs_ail_t *); 33STATIC xfs_log_item_t * xfs_ail_min(struct xfs_ail *);
34STATIC xfs_log_item_t * xfs_ail_next(xfs_ail_t *, xfs_log_item_t *); 34STATIC xfs_log_item_t * xfs_ail_next(struct xfs_ail *, xfs_log_item_t *);
35 35
36#ifdef DEBUG 36#ifdef DEBUG
37STATIC void xfs_ail_check(xfs_ail_t *, xfs_log_item_t *); 37STATIC void xfs_ail_check(struct xfs_ail *, xfs_log_item_t *);
38#else 38#else
39#define xfs_ail_check(a,l) 39#define xfs_ail_check(a,l)
40#endif /* DEBUG */ 40#endif /* DEBUG */
@@ -57,7 +57,7 @@ xfs_trans_tail_ail(
57 xfs_log_item_t *lip; 57 xfs_log_item_t *lip;
58 58
59 spin_lock(&mp->m_ail_lock); 59 spin_lock(&mp->m_ail_lock);
60 lip = xfs_ail_min(&mp->m_ail); 60 lip = xfs_ail_min(mp->m_ail);
61 if (lip == NULL) { 61 if (lip == NULL) {
62 lsn = (xfs_lsn_t)0; 62 lsn = (xfs_lsn_t)0;
63 } else { 63 } else {
@@ -91,10 +91,10 @@ xfs_trans_push_ail(
91{ 91{
92 xfs_log_item_t *lip; 92 xfs_log_item_t *lip;
93 93
94 lip = xfs_ail_min(&mp->m_ail); 94 lip = xfs_ail_min(mp->m_ail);
95 if (lip && !XFS_FORCED_SHUTDOWN(mp)) { 95 if (lip && !XFS_FORCED_SHUTDOWN(mp)) {
96 if (XFS_LSN_CMP(threshold_lsn, mp->m_ail.xa_target) > 0) 96 if (XFS_LSN_CMP(threshold_lsn, mp->m_ail->xa_target) > 0)
97 xfsaild_wakeup(mp, threshold_lsn); 97 xfsaild_wakeup(mp->m_ail, threshold_lsn);
98 } 98 }
99} 99}
100 100
@@ -111,12 +111,12 @@ xfs_trans_first_push_ail(
111{ 111{
112 xfs_log_item_t *lip; 112 xfs_log_item_t *lip;
113 113
114 lip = xfs_ail_min(&mp->m_ail); 114 lip = xfs_ail_min(mp->m_ail);
115 *gen = (int)mp->m_ail.xa_gen; 115 *gen = (int)mp->m_ail->xa_gen;
116 if (lsn == 0) 116 if (lsn == 0)
117 return lip; 117 return lip;
118 118
119 list_for_each_entry(lip, &mp->m_ail.xa_ail, li_ail) { 119 list_for_each_entry(lip, &mp->m_ail->xa_ail, li_ail) {
120 if (XFS_LSN_CMP(lip->li_lsn, lsn) >= 0) 120 if (XFS_LSN_CMP(lip->li_lsn, lsn) >= 0)
121 return lip; 121 return lip;
122 } 122 }
@@ -129,17 +129,18 @@ xfs_trans_first_push_ail(
129 */ 129 */
130long 130long
131xfsaild_push( 131xfsaild_push(
132 xfs_mount_t *mp, 132 struct xfs_ail *ailp,
133 xfs_lsn_t *last_lsn) 133 xfs_lsn_t *last_lsn)
134{ 134{
135 long tout = 1000; /* milliseconds */ 135 long tout = 1000; /* milliseconds */
136 xfs_lsn_t last_pushed_lsn = *last_lsn; 136 xfs_lsn_t last_pushed_lsn = *last_lsn;
137 xfs_lsn_t target = mp->m_ail.xa_target; 137 xfs_lsn_t target = ailp->xa_target;
138 xfs_lsn_t lsn; 138 xfs_lsn_t lsn;
139 xfs_log_item_t *lip; 139 xfs_log_item_t *lip;
140 int gen; 140 int gen;
141 int restarts; 141 int restarts;
142 int flush_log, count, stuck; 142 int flush_log, count, stuck;
143 xfs_mount_t *mp = ailp->xa_mount;
143 144
144#define XFS_TRANS_PUSH_AIL_RESTARTS 10 145#define XFS_TRANS_PUSH_AIL_RESTARTS 10
145 146
@@ -331,7 +332,7 @@ xfs_trans_unlocked_item(
331 * the call to xfs_log_move_tail() doesn't do anything if there's 332 * the call to xfs_log_move_tail() doesn't do anything if there's
332 * not enough free space to wake people up so we're safe calling it. 333 * not enough free space to wake people up so we're safe calling it.
333 */ 334 */
334 min_lip = xfs_ail_min(&mp->m_ail); 335 min_lip = xfs_ail_min(mp->m_ail);
335 336
336 if (min_lip == lip) 337 if (min_lip == lip)
337 xfs_log_move_tail(mp, 1); 338 xfs_log_move_tail(mp, 1);
@@ -362,10 +363,10 @@ xfs_trans_update_ail(
362 xfs_log_item_t *dlip=NULL; 363 xfs_log_item_t *dlip=NULL;
363 xfs_log_item_t *mlip; /* ptr to minimum lip */ 364 xfs_log_item_t *mlip; /* ptr to minimum lip */
364 365
365 mlip = xfs_ail_min(&mp->m_ail); 366 mlip = xfs_ail_min(mp->m_ail);
366 367
367 if (lip->li_flags & XFS_LI_IN_AIL) { 368 if (lip->li_flags & XFS_LI_IN_AIL) {
368 dlip = xfs_ail_delete(&mp->m_ail, lip); 369 dlip = xfs_ail_delete(mp->m_ail, lip);
369 ASSERT(dlip == lip); 370 ASSERT(dlip == lip);
370 } else { 371 } else {
371 lip->li_flags |= XFS_LI_IN_AIL; 372 lip->li_flags |= XFS_LI_IN_AIL;
@@ -373,11 +374,11 @@ xfs_trans_update_ail(
373 374
374 lip->li_lsn = lsn; 375 lip->li_lsn = lsn;
375 376
376 xfs_ail_insert(&mp->m_ail, lip); 377 xfs_ail_insert(mp->m_ail, lip);
377 mp->m_ail.xa_gen++; 378 mp->m_ail->xa_gen++;
378 379
379 if (mlip == dlip) { 380 if (mlip == dlip) {
380 mlip = xfs_ail_min(&mp->m_ail); 381 mlip = xfs_ail_min(mp->m_ail);
381 spin_unlock(&mp->m_ail_lock); 382 spin_unlock(&mp->m_ail_lock);
382 xfs_log_move_tail(mp, mlip->li_lsn); 383 xfs_log_move_tail(mp, mlip->li_lsn);
383 } else { 384 } else {
@@ -411,17 +412,17 @@ xfs_trans_delete_ail(
411 xfs_log_item_t *mlip; 412 xfs_log_item_t *mlip;
412 413
413 if (lip->li_flags & XFS_LI_IN_AIL) { 414 if (lip->li_flags & XFS_LI_IN_AIL) {
414 mlip = xfs_ail_min(&mp->m_ail); 415 mlip = xfs_ail_min(mp->m_ail);
415 dlip = xfs_ail_delete(&mp->m_ail, lip); 416 dlip = xfs_ail_delete(mp->m_ail, lip);
416 ASSERT(dlip == lip); 417 ASSERT(dlip == lip);
417 418
418 419
419 lip->li_flags &= ~XFS_LI_IN_AIL; 420 lip->li_flags &= ~XFS_LI_IN_AIL;
420 lip->li_lsn = 0; 421 lip->li_lsn = 0;
421 mp->m_ail.xa_gen++; 422 mp->m_ail->xa_gen++;
422 423
423 if (mlip == dlip) { 424 if (mlip == dlip) {
424 mlip = xfs_ail_min(&mp->m_ail); 425 mlip = xfs_ail_min(mp->m_ail);
425 spin_unlock(&mp->m_ail_lock); 426 spin_unlock(&mp->m_ail_lock);
426 xfs_log_move_tail(mp, (mlip ? mlip->li_lsn : 0)); 427 xfs_log_move_tail(mp, (mlip ? mlip->li_lsn : 0));
427 } else { 428 } else {
@@ -459,8 +460,8 @@ xfs_trans_first_ail(
459{ 460{
460 xfs_log_item_t *lip; 461 xfs_log_item_t *lip;
461 462
462 lip = xfs_ail_min(&mp->m_ail); 463 lip = xfs_ail_min(mp->m_ail);
463 *gen = (int)mp->m_ail.xa_gen; 464 *gen = (int)mp->m_ail->xa_gen;
464 465
465 return lip; 466 return lip;
466} 467}
@@ -482,11 +483,11 @@ xfs_trans_next_ail(
482 xfs_log_item_t *nlip; 483 xfs_log_item_t *nlip;
483 484
484 ASSERT(mp && lip && gen); 485 ASSERT(mp && lip && gen);
485 if (mp->m_ail.xa_gen == *gen) { 486 if (mp->m_ail->xa_gen == *gen) {
486 nlip = xfs_ail_next(&mp->m_ail, lip); 487 nlip = xfs_ail_next(mp->m_ail, lip);
487 } else { 488 } else {
488 nlip = xfs_ail_min(&mp->m_ail); 489 nlip = xfs_ail_min(mp->m_ail);
489 *gen = (int)mp->m_ail.xa_gen; 490 *gen = (int)mp->m_ail->xa_gen;
490 if (restarts != NULL) { 491 if (restarts != NULL) {
491 XFS_STATS_INC(xs_push_ail_restarts); 492 XFS_STATS_INC(xs_push_ail_restarts);
492 (*restarts)++; 493 (*restarts)++;
@@ -515,15 +516,25 @@ int
515xfs_trans_ail_init( 516xfs_trans_ail_init(
516 xfs_mount_t *mp) 517 xfs_mount_t *mp)
517{ 518{
518 INIT_LIST_HEAD(&mp->m_ail.xa_ail); 519 struct xfs_ail *ailp;
519 return xfsaild_start(mp); 520
521 ailp = kmem_zalloc(sizeof(struct xfs_ail), KM_MAYFAIL);
522 if (!ailp)
523 return ENOMEM;
524
525 ailp->xa_mount = mp;
526 INIT_LIST_HEAD(&ailp->xa_ail);
527 return xfsaild_start(ailp);
520} 528}
521 529
522void 530void
523xfs_trans_ail_destroy( 531xfs_trans_ail_destroy(
524 xfs_mount_t *mp) 532 xfs_mount_t *mp)
525{ 533{
526 xfsaild_stop(mp); 534 struct xfs_ail *ailp = mp->m_ail;
535
536 xfsaild_stop(ailp);
537 kmem_free(ailp);
527} 538}
528 539
529/* 540/*
@@ -534,7 +545,7 @@ xfs_trans_ail_destroy(
534 */ 545 */
535STATIC void 546STATIC void
536xfs_ail_insert( 547xfs_ail_insert(
537 xfs_ail_t *ailp, 548 struct xfs_ail *ailp,
538 xfs_log_item_t *lip) 549 xfs_log_item_t *lip)
539/* ARGSUSED */ 550/* ARGSUSED */
540{ 551{
@@ -568,7 +579,7 @@ xfs_ail_insert(
568/*ARGSUSED*/ 579/*ARGSUSED*/
569STATIC xfs_log_item_t * 580STATIC xfs_log_item_t *
570xfs_ail_delete( 581xfs_ail_delete(
571 xfs_ail_t *ailp, 582 struct xfs_ail *ailp,
572 xfs_log_item_t *lip) 583 xfs_log_item_t *lip)
573/* ARGSUSED */ 584/* ARGSUSED */
574{ 585{
@@ -585,7 +596,7 @@ xfs_ail_delete(
585 */ 596 */
586STATIC xfs_log_item_t * 597STATIC xfs_log_item_t *
587xfs_ail_min( 598xfs_ail_min(
588 xfs_ail_t *ailp) 599 struct xfs_ail *ailp)
589/* ARGSUSED */ 600/* ARGSUSED */
590{ 601{
591 if (list_empty(&ailp->xa_ail)) 602 if (list_empty(&ailp->xa_ail))
@@ -601,7 +612,7 @@ xfs_ail_min(
601 */ 612 */
602STATIC xfs_log_item_t * 613STATIC xfs_log_item_t *
603xfs_ail_next( 614xfs_ail_next(
604 xfs_ail_t *ailp, 615 struct xfs_ail *ailp,
605 xfs_log_item_t *lip) 616 xfs_log_item_t *lip)
606/* ARGSUSED */ 617/* ARGSUSED */
607{ 618{
@@ -617,7 +628,7 @@ xfs_ail_next(
617 */ 628 */
618STATIC void 629STATIC void
619xfs_ail_check( 630xfs_ail_check(
620 xfs_ail_t *ailp, 631 struct xfs_ail *ailp,
621 xfs_log_item_t *lip) 632 xfs_log_item_t *lip)
622{ 633{
623 xfs_log_item_t *prev_lip; 634 xfs_log_item_t *prev_lip;