aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c28
-rw-r--r--fs/xfs/xfs_mount.h10
-rw-r--r--fs/xfs/xfs_trans_ail.c87
-rw-r--r--fs/xfs/xfs_trans_priv.h17
4 files changed, 77 insertions, 65 deletions
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 206a949e3870..655508ce2b73 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -814,18 +814,18 @@ xfs_setup_devices(
814 */ 814 */
815void 815void
816xfsaild_wakeup( 816xfsaild_wakeup(
817 xfs_mount_t *mp, 817 struct xfs_ail *ailp,
818 xfs_lsn_t threshold_lsn) 818 xfs_lsn_t threshold_lsn)
819{ 819{
820 mp->m_ail.xa_target = threshold_lsn; 820 ailp->xa_target = threshold_lsn;
821 wake_up_process(mp->m_ail.xa_task); 821 wake_up_process(ailp->xa_task);
822} 822}
823 823
824int 824int
825xfsaild( 825xfsaild(
826 void *data) 826 void *data)
827{ 827{
828 xfs_mount_t *mp = (xfs_mount_t *)data; 828 struct xfs_ail *ailp = data;
829 xfs_lsn_t last_pushed_lsn = 0; 829 xfs_lsn_t last_pushed_lsn = 0;
830 long tout = 0; 830 long tout = 0;
831 831
@@ -837,11 +837,11 @@ xfsaild(
837 /* swsusp */ 837 /* swsusp */
838 try_to_freeze(); 838 try_to_freeze();
839 839
840 ASSERT(mp->m_log); 840 ASSERT(ailp->xa_mount->m_log);
841 if (XFS_FORCED_SHUTDOWN(mp)) 841 if (XFS_FORCED_SHUTDOWN(ailp->xa_mount))
842 continue; 842 continue;
843 843
844 tout = xfsaild_push(mp, &last_pushed_lsn); 844 tout = xfsaild_push(ailp, &last_pushed_lsn);
845 } 845 }
846 846
847 return 0; 847 return 0;
@@ -849,20 +849,20 @@ xfsaild(
849 849
850int 850int
851xfsaild_start( 851xfsaild_start(
852 xfs_mount_t *mp) 852 struct xfs_ail *ailp)
853{ 853{
854 mp->m_ail.xa_target = 0; 854 ailp->xa_target = 0;
855 mp->m_ail.xa_task = kthread_run(xfsaild, mp, "xfsaild"); 855 ailp->xa_task = kthread_run(xfsaild, ailp, "xfsaild");
856 if (IS_ERR(mp->m_ail.xa_task)) 856 if (IS_ERR(ailp->xa_task))
857 return -PTR_ERR(mp->m_ail.xa_task); 857 return -PTR_ERR(ailp->xa_task);
858 return 0; 858 return 0;
859} 859}
860 860
861void 861void
862xfsaild_stop( 862xfsaild_stop(
863 xfs_mount_t *mp) 863 struct xfs_ail *ailp)
864{ 864{
865 kthread_stop(mp->m_ail.xa_task); 865 kthread_stop(ailp->xa_task);
866} 866}
867 867
868 868
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index 67cf0b2bb848..287f90011ed5 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -63,6 +63,7 @@ struct xfs_extdelta;
63struct xfs_swapext; 63struct xfs_swapext;
64struct xfs_mru_cache; 64struct xfs_mru_cache;
65struct xfs_nameops; 65struct xfs_nameops;
66struct xfs_ail;
66 67
67/* 68/*
68 * Prototypes and functions for the Data Migration subsystem. 69 * Prototypes and functions for the Data Migration subsystem.
@@ -224,18 +225,11 @@ extern void xfs_icsb_sync_counters_locked(struct xfs_mount *, int);
224#define xfs_icsb_sync_counters_locked(mp, flags) do { } while (0) 225#define xfs_icsb_sync_counters_locked(mp, flags) do { } while (0)
225#endif 226#endif
226 227
227typedef struct xfs_ail {
228 struct list_head xa_ail;
229 uint xa_gen;
230 struct task_struct *xa_task;
231 xfs_lsn_t xa_target;
232} xfs_ail_t;
233
234typedef struct xfs_mount { 228typedef struct xfs_mount {
235 struct super_block *m_super; 229 struct super_block *m_super;
236 xfs_tid_t m_tid; /* next unused tid for fs */ 230 xfs_tid_t m_tid; /* next unused tid for fs */
237 spinlock_t m_ail_lock; /* fs AIL mutex */ 231 spinlock_t m_ail_lock; /* fs AIL mutex */
238 xfs_ail_t m_ail; /* fs active log item list */ 232 struct xfs_ail *m_ail; /* fs active log item list */
239 xfs_sb_t m_sb; /* copy of fs superblock */ 233 xfs_sb_t m_sb; /* copy of fs superblock */
240 spinlock_t m_sb_lock; /* sb counter lock */ 234 spinlock_t m_sb_lock; /* sb counter lock */
241 struct xfs_buf *m_sb_bp; /* buffer for superblock */ 235 struct xfs_buf *m_sb_bp; /* buffer for superblock */
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;
diff --git a/fs/xfs/xfs_trans_priv.h b/fs/xfs/xfs_trans_priv.h
index 3c748c456ed4..98317fdc33b5 100644
--- a/fs/xfs/xfs_trans_priv.h
+++ b/fs/xfs/xfs_trans_priv.h
@@ -56,13 +56,20 @@ struct xfs_log_item *xfs_trans_first_ail(struct xfs_mount *, int *);
56struct xfs_log_item *xfs_trans_next_ail(struct xfs_mount *, 56struct xfs_log_item *xfs_trans_next_ail(struct xfs_mount *,
57 struct xfs_log_item *, int *, int *); 57 struct xfs_log_item *, int *, int *);
58 58
59
60/* 59/*
61 * AIL push thread support 60 * AIL push thread support
62 */ 61 */
63long xfsaild_push(struct xfs_mount *, xfs_lsn_t *); 62struct xfs_ail {
64void xfsaild_wakeup(struct xfs_mount *, xfs_lsn_t); 63 struct xfs_mount *xa_mount;
65int xfsaild_start(struct xfs_mount *); 64 struct list_head xa_ail;
66void xfsaild_stop(struct xfs_mount *); 65 uint xa_gen;
66 struct task_struct *xa_task;
67 xfs_lsn_t xa_target;
68};
69
70long xfsaild_push(struct xfs_ail *, xfs_lsn_t *);
71void xfsaild_wakeup(struct xfs_ail *, xfs_lsn_t);
72int xfsaild_start(struct xfs_ail *);
73void xfsaild_stop(struct xfs_ail *);
67 74
68#endif /* __XFS_TRANS_PRIV_H__ */ 75#endif /* __XFS_TRANS_PRIV_H__ */