aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_trans_buf.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_trans_buf.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_trans_buf.c')
-rw-r--r--fs/xfs/xfs_trans_buf.c84
1 files changed, 27 insertions, 57 deletions
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c
index 296a7995a007..9132d162c4b8 100644
--- a/fs/xfs/xfs_trans_buf.c
+++ b/fs/xfs/xfs_trans_buf.c
@@ -165,14 +165,6 @@ xfs_trans_get_buf(xfs_trans_t *tp,
165 XFS_BUF_DONE(bp); 165 XFS_BUF_DONE(bp);
166 } 166 }
167 167
168 /*
169 * If the buffer is stale then it was binval'ed
170 * since last read. This doesn't matter since the
171 * caller isn't allowed to use the data anyway.
172 */
173 else if (XFS_BUF_ISSTALE(bp))
174 ASSERT(!XFS_BUF_ISDELAYWRITE(bp));
175
176 ASSERT(bp->b_transp == tp); 168 ASSERT(bp->b_transp == tp);
177 bip = bp->b_fspriv; 169 bip = bp->b_fspriv;
178 ASSERT(bip != NULL); 170 ASSERT(bip != NULL);
@@ -418,19 +410,6 @@ xfs_trans_read_buf(
418 return 0; 410 return 0;
419 411
420shutdown_abort: 412shutdown_abort:
421 /*
422 * the theory here is that buffer is good but we're
423 * bailing out because the filesystem is being forcibly
424 * shut down. So we should leave the b_flags alone since
425 * the buffer's not staled and just get out.
426 */
427#if defined(DEBUG)
428 if (XFS_BUF_ISSTALE(bp) && XFS_BUF_ISDELAYWRITE(bp))
429 xfs_notice(mp, "about to pop assert, bp == 0x%p", bp);
430#endif
431 ASSERT((bp->b_flags & (XBF_STALE|XBF_DELWRI)) !=
432 (XBF_STALE|XBF_DELWRI));
433
434 trace_xfs_trans_read_buf_shut(bp, _RET_IP_); 413 trace_xfs_trans_read_buf_shut(bp, _RET_IP_);
435 xfs_buf_relse(bp); 414 xfs_buf_relse(bp);
436 *bpp = NULL; 415 *bpp = NULL;
@@ -649,22 +628,33 @@ xfs_trans_log_buf(xfs_trans_t *tp,
649 628
650 629
651/* 630/*
652 * This called to invalidate a buffer that is being used within 631 * Invalidate a buffer that is being used within a transaction.
653 * a transaction. Typically this is because the blocks in the 632 *
654 * buffer are being freed, so we need to prevent it from being 633 * Typically this is because the blocks in the buffer are being freed, so we
655 * written out when we're done. Allowing it to be written again 634 * need to prevent it from being written out when we're done. Allowing it
656 * might overwrite data in the free blocks if they are reallocated 635 * to be written again might overwrite data in the free blocks if they are
657 * to a file. 636 * reallocated to a file.
658 * 637 *
659 * We prevent the buffer from being written out by clearing the 638 * We prevent the buffer from being written out by marking it stale. We can't
660 * B_DELWRI flag. We can't always 639 * get rid of the buf log item at this point because the buffer may still be
661 * get rid of the buf log item at this point, though, because 640 * pinned by another transaction. If that is the case, then we'll wait until
662 * the buffer may still be pinned by another transaction. If that 641 * the buffer is committed to disk for the last time (we can tell by the ref
663 * is the case, then we'll wait until the buffer is committed to 642 * count) and free it in xfs_buf_item_unpin(). Until that happens we will
664 * disk for the last time (we can tell by the ref count) and 643 * keep the buffer locked so that the buffer and buf log item are not reused.
665 * free it in xfs_buf_item_unpin(). Until it is cleaned up we 644 *
666 * will keep the buffer locked so that the buffer and buf log item 645 * We also set the XFS_BLF_CANCEL flag in the buf log format structure and log
667 * are not reused. 646 * the buf item. This will be used at recovery time to determine that copies
647 * of the buffer in the log before this should not be replayed.
648 *
649 * We mark the item descriptor and the transaction dirty so that we'll hold
650 * the buffer until after the commit.
651 *
652 * Since we're invalidating the buffer, we also clear the state about which
653 * parts of the buffer have been logged. We also clear the flag indicating
654 * that this is an inode buffer since the data in the buffer will no longer
655 * be valid.
656 *
657 * We set the stale bit in the buffer as well since we're getting rid of it.
668 */ 658 */
669void 659void
670xfs_trans_binval( 660xfs_trans_binval(
@@ -684,7 +674,6 @@ xfs_trans_binval(
684 * If the buffer is already invalidated, then 674 * If the buffer is already invalidated, then
685 * just return. 675 * just return.
686 */ 676 */
687 ASSERT(!(XFS_BUF_ISDELAYWRITE(bp)));
688 ASSERT(XFS_BUF_ISSTALE(bp)); 677 ASSERT(XFS_BUF_ISSTALE(bp));
689 ASSERT(!(bip->bli_flags & (XFS_BLI_LOGGED | XFS_BLI_DIRTY))); 678 ASSERT(!(bip->bli_flags & (XFS_BLI_LOGGED | XFS_BLI_DIRTY)));
690 ASSERT(!(bip->bli_format.blf_flags & XFS_BLF_INODE_BUF)); 679 ASSERT(!(bip->bli_format.blf_flags & XFS_BLF_INODE_BUF));
@@ -694,27 +683,8 @@ xfs_trans_binval(
694 return; 683 return;
695 } 684 }
696 685
697 /*
698 * Clear the dirty bit in the buffer and set the STALE flag
699 * in the buf log item. The STALE flag will be used in
700 * xfs_buf_item_unpin() to determine if it should clean up
701 * when the last reference to the buf item is given up.
702 * We set the XFS_BLF_CANCEL flag in the buf log format structure
703 * and log the buf item. This will be used at recovery time
704 * to determine that copies of the buffer in the log before
705 * this should not be replayed.
706 * We mark the item descriptor and the transaction dirty so
707 * that we'll hold the buffer until after the commit.
708 *
709 * Since we're invalidating the buffer, we also clear the state
710 * about which parts of the buffer have been logged. We also
711 * clear the flag indicating that this is an inode buffer since
712 * the data in the buffer will no longer be valid.
713 *
714 * We set the stale bit in the buffer as well since we're getting
715 * rid of it.
716 */
717 xfs_buf_stale(bp); 686 xfs_buf_stale(bp);
687
718 bip->bli_flags |= XFS_BLI_STALE; 688 bip->bli_flags |= XFS_BLI_STALE;
719 bip->bli_flags &= ~(XFS_BLI_INODE_BUF | XFS_BLI_LOGGED | XFS_BLI_DIRTY); 689 bip->bli_flags &= ~(XFS_BLI_INODE_BUF | XFS_BLI_LOGGED | XFS_BLI_DIRTY);
720 bip->bli_format.blf_flags &= ~XFS_BLF_INODE_BUF; 690 bip->bli_format.blf_flags &= ~XFS_BLF_INODE_BUF;