diff options
author | David Chinner <dgc@sgi.com> | 2008-02-04 20:13:32 -0500 |
---|---|---|
committer | Lachlan McIlroy <lachlan@redback.melbourne.sgi.com> | 2008-02-07 02:22:51 -0500 |
commit | 249a8c1124653fa90f3a3afff869095a31bc229f (patch) | |
tree | e0681990b5b61155a64a9fd3c0cf73d4d6bb4ce5 /fs/xfs/xfs_log.c | |
parent | 4576758db5817a91b8974c696247d459dc653db2 (diff) |
[XFS] Move AIL pushing into it's own thread
When many hundreds to thousands of threads all try to do simultaneous
transactions and the log is in a tail-pushing situation (i.e. full), we
can get multiple threads walking the AIL list and contending on the AIL
lock.
The AIL push is, in effect, a simple I/O dispatch algorithm complicated by
the ordering constraints placed on it by the transaction subsystem. It
really does not need multiple threads to push on it - even when only a
single CPU is pushing the AIL, it can push the I/O out far faster that
pretty much any disk subsystem can handle.
So, to avoid contention problems stemming from multiple list walkers, move
the list walk off into another thread and simply provide a "target" to
push to. When a thread requires a push, it sets the target and wakes the
push thread, then goes to sleep waiting for the required amount of space
to become available in the log.
This mechanism should also be a lot fairer under heavy load as the waiters
will queue in arrival order, rather than queuing in "who completed a push
first" order.
Also, by moving the pushing to a separate thread we can do more
effectively overload detection and prevention as we can keep context from
loop iteration to loop iteration. That is, we can push only part of the
list each loop and not have to loop back to the start of the list every
time we run. This should also help by reducing the number of items we try
to lock and/or push items that we cannot move.
Note that this patch is not intended to solve the inefficiencies in the
AIL structure and the associated issues with extremely large list
contents. That needs to be addresses separately; parallel access would
cause problems to any new structure as well, so I'm only aiming to isolate
the structure from unbounded parallelism here.
SGI-PV: 972759
SGI-Modid: xfs-linux-melb:xfs-kern:30371a
Signed-off-by: David Chinner <dgc@sgi.com>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_log.c')
-rw-r--r-- | fs/xfs/xfs_log.c | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 4c86a26330a..b3ac3805d3c 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c | |||
@@ -498,11 +498,14 @@ xfs_log_reserve(xfs_mount_t *mp, | |||
498 | * Return error or zero. | 498 | * Return error or zero. |
499 | */ | 499 | */ |
500 | int | 500 | int |
501 | xfs_log_mount(xfs_mount_t *mp, | 501 | xfs_log_mount( |
502 | xfs_buftarg_t *log_target, | 502 | xfs_mount_t *mp, |
503 | xfs_daddr_t blk_offset, | 503 | xfs_buftarg_t *log_target, |
504 | int num_bblks) | 504 | xfs_daddr_t blk_offset, |
505 | int num_bblks) | ||
505 | { | 506 | { |
507 | int error; | ||
508 | |||
506 | if (!(mp->m_flags & XFS_MOUNT_NORECOVERY)) | 509 | if (!(mp->m_flags & XFS_MOUNT_NORECOVERY)) |
507 | cmn_err(CE_NOTE, "XFS mounting filesystem %s", mp->m_fsname); | 510 | cmn_err(CE_NOTE, "XFS mounting filesystem %s", mp->m_fsname); |
508 | else { | 511 | else { |
@@ -515,11 +518,21 @@ xfs_log_mount(xfs_mount_t *mp, | |||
515 | mp->m_log = xlog_alloc_log(mp, log_target, blk_offset, num_bblks); | 518 | mp->m_log = xlog_alloc_log(mp, log_target, blk_offset, num_bblks); |
516 | 519 | ||
517 | /* | 520 | /* |
521 | * Initialize the AIL now we have a log. | ||
522 | */ | ||
523 | spin_lock_init(&mp->m_ail_lock); | ||
524 | error = xfs_trans_ail_init(mp); | ||
525 | if (error) { | ||
526 | cmn_err(CE_WARN, "XFS: AIL initialisation failed: error %d", error); | ||
527 | goto error; | ||
528 | } | ||
529 | |||
530 | /* | ||
518 | * skip log recovery on a norecovery mount. pretend it all | 531 | * skip log recovery on a norecovery mount. pretend it all |
519 | * just worked. | 532 | * just worked. |
520 | */ | 533 | */ |
521 | if (!(mp->m_flags & XFS_MOUNT_NORECOVERY)) { | 534 | if (!(mp->m_flags & XFS_MOUNT_NORECOVERY)) { |
522 | int error, readonly = (mp->m_flags & XFS_MOUNT_RDONLY); | 535 | int readonly = (mp->m_flags & XFS_MOUNT_RDONLY); |
523 | 536 | ||
524 | if (readonly) | 537 | if (readonly) |
525 | mp->m_flags &= ~XFS_MOUNT_RDONLY; | 538 | mp->m_flags &= ~XFS_MOUNT_RDONLY; |
@@ -530,8 +543,7 @@ xfs_log_mount(xfs_mount_t *mp, | |||
530 | mp->m_flags |= XFS_MOUNT_RDONLY; | 543 | mp->m_flags |= XFS_MOUNT_RDONLY; |
531 | if (error) { | 544 | if (error) { |
532 | cmn_err(CE_WARN, "XFS: log mount/recovery failed: error %d", error); | 545 | cmn_err(CE_WARN, "XFS: log mount/recovery failed: error %d", error); |
533 | xlog_dealloc_log(mp->m_log); | 546 | goto error; |
534 | return error; | ||
535 | } | 547 | } |
536 | } | 548 | } |
537 | 549 | ||
@@ -540,6 +552,9 @@ xfs_log_mount(xfs_mount_t *mp, | |||
540 | 552 | ||
541 | /* End mounting message in xfs_log_mount_finish */ | 553 | /* End mounting message in xfs_log_mount_finish */ |
542 | return 0; | 554 | return 0; |
555 | error: | ||
556 | xfs_log_unmount_dealloc(mp); | ||
557 | return error; | ||
543 | } /* xfs_log_mount */ | 558 | } /* xfs_log_mount */ |
544 | 559 | ||
545 | /* | 560 | /* |
@@ -722,10 +737,14 @@ xfs_log_unmount_write(xfs_mount_t *mp) | |||
722 | 737 | ||
723 | /* | 738 | /* |
724 | * Deallocate log structures for unmount/relocation. | 739 | * Deallocate log structures for unmount/relocation. |
740 | * | ||
741 | * We need to stop the aild from running before we destroy | ||
742 | * and deallocate the log as the aild references the log. | ||
725 | */ | 743 | */ |
726 | void | 744 | void |
727 | xfs_log_unmount_dealloc(xfs_mount_t *mp) | 745 | xfs_log_unmount_dealloc(xfs_mount_t *mp) |
728 | { | 746 | { |
747 | xfs_trans_ail_destroy(mp); | ||
729 | xlog_dealloc_log(mp->m_log); | 748 | xlog_dealloc_log(mp->m_log); |
730 | } | 749 | } |
731 | 750 | ||