aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_log_recover.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2012-04-23 01:58:39 -0400
committerBen Myers <bpm@sgi.com>2012-05-14 17:20:31 -0400
commit43ff2122e6492bcc88b065c433453dce88223b30 (patch)
tree0f762cfb753edd73402b8830e0927d9efba30c61 /fs/xfs/xfs_log_recover.c
parent960c60af8b9481595e68875e79b2602e73169c29 (diff)
xfs: on-stack delayed write buffer lists
Queue delwri buffers on a local on-stack list instead of a per-buftarg one, and write back the buffers per-process instead of by waking up xfsbufd. This is now easily doable given that we have very few places left that write delwri buffers: - log recovery: Only done at mount time, and already forcing out the buffers synchronously using xfs_flush_buftarg - quotacheck: Same story. - dquot reclaim: Writes out dirty dquots on the LRU under memory pressure. We might want to look into doing more of this via xfsaild, but it's already more optimal than the synchronous inode reclaim that writes each buffer synchronously. - xfsaild: This is the main beneficiary of the change. By keeping a local list of buffers to write we reduce latency of writing out buffers, and more importably we can remove all the delwri list promotions which were hitting the buffer cache hard under sustained metadata loads. The implementation is very straight forward - xfs_buf_delwri_queue now gets a new list_head pointer that it adds the delwri buffers to, and all callers need to eventually submit the list using xfs_buf_delwi_submit or xfs_buf_delwi_submit_nowait. Buffers that already are on a delwri list are skipped in xfs_buf_delwri_queue, assuming they already are on another delwri list. The biggest change to pass down the buffer list was done to the AIL pushing. Now that we operate on buffers the trylock, push and pushbuf log item methods are merged into a single push routine, which tries to lock the item, and if possible add the buffer that needs writeback to the buffer list. This leads to much simpler code than the previous split but requires the individual IOP_PUSH instances to unlock and reacquire the AIL around calls to blocking routines. Given that xfsailds now also handle writing out buffers, the conditions for log forcing and the sleep times needed some small changes. The most important one is that we consider an AIL busy as long we still have buffers to push, and the other one is that we do increment the pushed LSN for buffers that are under flushing at this moment, but still count them towards the stuck items for restart purposes. Without this we could hammer on stuck items without ever forcing the log and not make progress under heavy random delete workloads on fast flash storage devices. [ Dave Chinner: - rebase on previous patches. - improved comments for XBF_DELWRI_Q handling - fix XBF_ASYNC handling in queue submission (test 106 failure) - rename delwri submit function buffer list parameters for clarity - xfs_efd_item_push() should return XFS_ITEM_PINNED ] Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Mark Tinguely <tinguely@sgi.com> Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_log_recover.c')
-rw-r--r--fs/xfs/xfs_log_recover.c46
1 files changed, 29 insertions, 17 deletions
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 8ecad5bad66c..5e864a9c0ccf 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -2103,6 +2103,7 @@ xlog_recover_do_dquot_buffer(
2103STATIC int 2103STATIC int
2104xlog_recover_buffer_pass2( 2104xlog_recover_buffer_pass2(
2105 xlog_t *log, 2105 xlog_t *log,
2106 struct list_head *buffer_list,
2106 xlog_recover_item_t *item) 2107 xlog_recover_item_t *item)
2107{ 2108{
2108 xfs_buf_log_format_t *buf_f = item->ri_buf[0].i_addr; 2109 xfs_buf_log_format_t *buf_f = item->ri_buf[0].i_addr;
@@ -2173,7 +2174,7 @@ xlog_recover_buffer_pass2(
2173 } else { 2174 } else {
2174 ASSERT(bp->b_target->bt_mount == mp); 2175 ASSERT(bp->b_target->bt_mount == mp);
2175 bp->b_iodone = xlog_recover_iodone; 2176 bp->b_iodone = xlog_recover_iodone;
2176 xfs_buf_delwri_queue(bp); 2177 xfs_buf_delwri_queue(bp, buffer_list);
2177 } 2178 }
2178 2179
2179 xfs_buf_relse(bp); 2180 xfs_buf_relse(bp);
@@ -2183,6 +2184,7 @@ xlog_recover_buffer_pass2(
2183STATIC int 2184STATIC int
2184xlog_recover_inode_pass2( 2185xlog_recover_inode_pass2(
2185 xlog_t *log, 2186 xlog_t *log,
2187 struct list_head *buffer_list,
2186 xlog_recover_item_t *item) 2188 xlog_recover_item_t *item)
2187{ 2189{
2188 xfs_inode_log_format_t *in_f; 2190 xfs_inode_log_format_t *in_f;
@@ -2436,7 +2438,7 @@ xlog_recover_inode_pass2(
2436write_inode_buffer: 2438write_inode_buffer:
2437 ASSERT(bp->b_target->bt_mount == mp); 2439 ASSERT(bp->b_target->bt_mount == mp);
2438 bp->b_iodone = xlog_recover_iodone; 2440 bp->b_iodone = xlog_recover_iodone;
2439 xfs_buf_delwri_queue(bp); 2441 xfs_buf_delwri_queue(bp, buffer_list);
2440 xfs_buf_relse(bp); 2442 xfs_buf_relse(bp);
2441error: 2443error:
2442 if (need_free) 2444 if (need_free)
@@ -2477,6 +2479,7 @@ xlog_recover_quotaoff_pass1(
2477STATIC int 2479STATIC int
2478xlog_recover_dquot_pass2( 2480xlog_recover_dquot_pass2(
2479 xlog_t *log, 2481 xlog_t *log,
2482 struct list_head *buffer_list,
2480 xlog_recover_item_t *item) 2483 xlog_recover_item_t *item)
2481{ 2484{
2482 xfs_mount_t *mp = log->l_mp; 2485 xfs_mount_t *mp = log->l_mp;
@@ -2558,7 +2561,7 @@ xlog_recover_dquot_pass2(
2558 ASSERT(dq_f->qlf_size == 2); 2561 ASSERT(dq_f->qlf_size == 2);
2559 ASSERT(bp->b_target->bt_mount == mp); 2562 ASSERT(bp->b_target->bt_mount == mp);
2560 bp->b_iodone = xlog_recover_iodone; 2563 bp->b_iodone = xlog_recover_iodone;
2561 xfs_buf_delwri_queue(bp); 2564 xfs_buf_delwri_queue(bp, buffer_list);
2562 xfs_buf_relse(bp); 2565 xfs_buf_relse(bp);
2563 2566
2564 return (0); 2567 return (0);
@@ -2712,21 +2715,22 @@ STATIC int
2712xlog_recover_commit_pass2( 2715xlog_recover_commit_pass2(
2713 struct log *log, 2716 struct log *log,
2714 struct xlog_recover *trans, 2717 struct xlog_recover *trans,
2718 struct list_head *buffer_list,
2715 xlog_recover_item_t *item) 2719 xlog_recover_item_t *item)
2716{ 2720{
2717 trace_xfs_log_recover_item_recover(log, trans, item, XLOG_RECOVER_PASS2); 2721 trace_xfs_log_recover_item_recover(log, trans, item, XLOG_RECOVER_PASS2);
2718 2722
2719 switch (ITEM_TYPE(item)) { 2723 switch (ITEM_TYPE(item)) {
2720 case XFS_LI_BUF: 2724 case XFS_LI_BUF:
2721 return xlog_recover_buffer_pass2(log, item); 2725 return xlog_recover_buffer_pass2(log, buffer_list, item);
2722 case XFS_LI_INODE: 2726 case XFS_LI_INODE:
2723 return xlog_recover_inode_pass2(log, item); 2727 return xlog_recover_inode_pass2(log, buffer_list, item);
2724 case XFS_LI_EFI: 2728 case XFS_LI_EFI:
2725 return xlog_recover_efi_pass2(log, item, trans->r_lsn); 2729 return xlog_recover_efi_pass2(log, item, trans->r_lsn);
2726 case XFS_LI_EFD: 2730 case XFS_LI_EFD:
2727 return xlog_recover_efd_pass2(log, item); 2731 return xlog_recover_efd_pass2(log, item);
2728 case XFS_LI_DQUOT: 2732 case XFS_LI_DQUOT:
2729 return xlog_recover_dquot_pass2(log, item); 2733 return xlog_recover_dquot_pass2(log, buffer_list, item);
2730 case XFS_LI_QUOTAOFF: 2734 case XFS_LI_QUOTAOFF:
2731 /* nothing to do in pass2 */ 2735 /* nothing to do in pass2 */
2732 return 0; 2736 return 0;
@@ -2750,8 +2754,9 @@ xlog_recover_commit_trans(
2750 struct xlog_recover *trans, 2754 struct xlog_recover *trans,
2751 int pass) 2755 int pass)
2752{ 2756{
2753 int error = 0; 2757 int error = 0, error2;
2754 xlog_recover_item_t *item; 2758 xlog_recover_item_t *item;
2759 LIST_HEAD (buffer_list);
2755 2760
2756 hlist_del(&trans->r_list); 2761 hlist_del(&trans->r_list);
2757 2762
@@ -2760,16 +2765,27 @@ xlog_recover_commit_trans(
2760 return error; 2765 return error;
2761 2766
2762 list_for_each_entry(item, &trans->r_itemq, ri_list) { 2767 list_for_each_entry(item, &trans->r_itemq, ri_list) {
2763 if (pass == XLOG_RECOVER_PASS1) 2768 switch (pass) {
2769 case XLOG_RECOVER_PASS1:
2764 error = xlog_recover_commit_pass1(log, trans, item); 2770 error = xlog_recover_commit_pass1(log, trans, item);
2765 else 2771 break;
2766 error = xlog_recover_commit_pass2(log, trans, item); 2772 case XLOG_RECOVER_PASS2:
2773 error = xlog_recover_commit_pass2(log, trans,
2774 &buffer_list, item);
2775 break;
2776 default:
2777 ASSERT(0);
2778 }
2779
2767 if (error) 2780 if (error)
2768 return error; 2781 goto out;
2769 } 2782 }
2770 2783
2771 xlog_recover_free_trans(trans); 2784 xlog_recover_free_trans(trans);
2772 return 0; 2785
2786out:
2787 error2 = xfs_buf_delwri_submit(&buffer_list);
2788 return error ? error : error2;
2773} 2789}
2774 2790
2775STATIC int 2791STATIC int
@@ -3639,11 +3655,8 @@ xlog_do_recover(
3639 * First replay the images in the log. 3655 * First replay the images in the log.
3640 */ 3656 */
3641 error = xlog_do_log_recovery(log, head_blk, tail_blk); 3657 error = xlog_do_log_recovery(log, head_blk, tail_blk);
3642 if (error) { 3658 if (error)
3643 return error; 3659 return error;
3644 }
3645
3646 xfs_flush_buftarg(log->l_mp->m_ddev_targp, 1);
3647 3660
3648 /* 3661 /*
3649 * If IO errors happened during recovery, bail out. 3662 * If IO errors happened during recovery, bail out.
@@ -3670,7 +3683,6 @@ xlog_do_recover(
3670 bp = xfs_getsb(log->l_mp, 0); 3683 bp = xfs_getsb(log->l_mp, 0);
3671 XFS_BUF_UNDONE(bp); 3684 XFS_BUF_UNDONE(bp);
3672 ASSERT(!(XFS_BUF_ISWRITE(bp))); 3685 ASSERT(!(XFS_BUF_ISWRITE(bp)));
3673 ASSERT(!(XFS_BUF_ISDELAYWRITE(bp)));
3674 XFS_BUF_READ(bp); 3686 XFS_BUF_READ(bp);
3675 XFS_BUF_UNASYNC(bp); 3687 XFS_BUF_UNASYNC(bp);
3676 xfsbdstrat(log->l_mp, bp); 3688 xfsbdstrat(log->l_mp, bp);