diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-24 17:14:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-24 17:14:46 -0400 |
commit | 9978306e31a8f89bd81fbc4c49fd9aefb1d30d10 (patch) | |
tree | 85bbd03336a82d20a00761ed35eb05536936b881 /fs/xfs/xfs_trans_buf.c | |
parent | abe81e25f08abbac493754a043f7a91a1b3e0f93 (diff) | |
parent | 14c26c6a05de138a4fd9a0c05ff8e7435a618324 (diff) |
Merge branch 'for-linus' of git://oss.sgi.com/xfs/xfs
Pull XFS update from Ben Myers:
- Removal of xfsbufd
- Background CIL flushes have been moved to a workqueue.
- Fix to xfs_check_page_type applicable to filesystems where
blocksize < page size
- Fix for stale data exposure when extsize hints are used.
- A series of xfs_buf cache cleanups.
- Fix for XFS_IOC_ALLOCSP
- Cleanups for includes and removal of xfs_lrw.[ch].
- Moved all busy extent handling to it's own file so that it is easier
to merge with userspace.
- Fix for log mount failure.
- Fix to enable inode reclaim during quotacheck at mount time.
- Fix for delalloc quota accounting.
- Fix for memory reclaim deadlock on agi buffer.
- Fixes for failed writes and to clean up stale delalloc blocks.
- Fix to use GFP_NOFS in blkdev_issue_flush
- SEEK_DATA/SEEK_HOLE support
* 'for-linus' of git://oss.sgi.com/xfs/xfs: (57 commits)
xfs: add trace points for log forces
xfs: fix memory reclaim deadlock on agi buffer
xfs: fix delalloc quota accounting on failure
xfs: protect xfs_sync_worker with s_umount semaphore
xfs: introduce SEEK_DATA/SEEK_HOLE support
xfs: make xfs_extent_busy_trim not static
xfs: make XBF_MAPPED the default behaviour
xfs: flush outstanding buffers on log mount failure
xfs: Properly exclude IO type flags from buffer flags
xfs: clean up xfs_bit.h includes
xfs: move xfs_do_force_shutdown() and kill xfs_rw.c
xfs: move xfs_get_extsz_hint() and kill xfs_rw.h
xfs: move xfs_fsb_to_db to xfs_bmap.h
xfs: clean up busy extent naming
xfs: move busy extent handling to it's own file
xfs: move xfsagino_t to xfs_types.h
xfs: use iolock on XFS_IOC_ALLOCSP calls
xfs: kill XBF_DONTBLOCK
xfs: kill xfs_read_buf()
xfs: kill XBF_LOCK
...
Diffstat (limited to 'fs/xfs/xfs_trans_buf.c')
-rw-r--r-- | fs/xfs/xfs_trans_buf.c | 126 |
1 files changed, 36 insertions, 90 deletions
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c index 1302d1d95a58..21c5a5e3700d 100644 --- a/fs/xfs/xfs_trans_buf.c +++ b/fs/xfs/xfs_trans_buf.c | |||
@@ -18,9 +18,7 @@ | |||
18 | #include "xfs.h" | 18 | #include "xfs.h" |
19 | #include "xfs_fs.h" | 19 | #include "xfs_fs.h" |
20 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
21 | #include "xfs_bit.h" | ||
22 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
24 | #include "xfs_trans.h" | 22 | #include "xfs_trans.h" |
25 | #include "xfs_sb.h" | 23 | #include "xfs_sb.h" |
26 | #include "xfs_ag.h" | 24 | #include "xfs_ag.h" |
@@ -33,7 +31,6 @@ | |||
33 | #include "xfs_buf_item.h" | 31 | #include "xfs_buf_item.h" |
34 | #include "xfs_trans_priv.h" | 32 | #include "xfs_trans_priv.h" |
35 | #include "xfs_error.h" | 33 | #include "xfs_error.h" |
36 | #include "xfs_rw.h" | ||
37 | #include "xfs_trace.h" | 34 | #include "xfs_trace.h" |
38 | 35 | ||
39 | /* | 36 | /* |
@@ -56,7 +53,7 @@ xfs_trans_buf_item_match( | |||
56 | if (blip->bli_item.li_type == XFS_LI_BUF && | 53 | if (blip->bli_item.li_type == XFS_LI_BUF && |
57 | blip->bli_buf->b_target == target && | 54 | blip->bli_buf->b_target == target && |
58 | XFS_BUF_ADDR(blip->bli_buf) == blkno && | 55 | XFS_BUF_ADDR(blip->bli_buf) == blkno && |
59 | XFS_BUF_COUNT(blip->bli_buf) == len) | 56 | BBTOB(blip->bli_buf->b_length) == len) |
60 | return blip->bli_buf; | 57 | return blip->bli_buf; |
61 | } | 58 | } |
62 | 59 | ||
@@ -141,15 +138,11 @@ xfs_trans_get_buf(xfs_trans_t *tp, | |||
141 | xfs_buf_t *bp; | 138 | xfs_buf_t *bp; |
142 | xfs_buf_log_item_t *bip; | 139 | xfs_buf_log_item_t *bip; |
143 | 140 | ||
144 | if (flags == 0) | ||
145 | flags = XBF_LOCK | XBF_MAPPED; | ||
146 | |||
147 | /* | 141 | /* |
148 | * Default to a normal get_buf() call if the tp is NULL. | 142 | * Default to a normal get_buf() call if the tp is NULL. |
149 | */ | 143 | */ |
150 | if (tp == NULL) | 144 | if (tp == NULL) |
151 | return xfs_buf_get(target_dev, blkno, len, | 145 | return xfs_buf_get(target_dev, blkno, len, flags); |
152 | flags | XBF_DONT_BLOCK); | ||
153 | 146 | ||
154 | /* | 147 | /* |
155 | * If we find the buffer in the cache with this transaction | 148 | * If we find the buffer in the cache with this transaction |
@@ -165,14 +158,6 @@ xfs_trans_get_buf(xfs_trans_t *tp, | |||
165 | XFS_BUF_DONE(bp); | 158 | XFS_BUF_DONE(bp); |
166 | } | 159 | } |
167 | 160 | ||
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); | 161 | ASSERT(bp->b_transp == tp); |
177 | bip = bp->b_fspriv; | 162 | bip = bp->b_fspriv; |
178 | ASSERT(bip != NULL); | 163 | ASSERT(bip != NULL); |
@@ -182,15 +167,7 @@ xfs_trans_get_buf(xfs_trans_t *tp, | |||
182 | return (bp); | 167 | return (bp); |
183 | } | 168 | } |
184 | 169 | ||
185 | /* | 170 | bp = xfs_buf_get(target_dev, blkno, len, flags); |
186 | * We always specify the XBF_DONT_BLOCK flag within a transaction | ||
187 | * so that get_buf does not try to push out a delayed write buffer | ||
188 | * which might cause another transaction to take place (if the | ||
189 | * buffer was delayed alloc). Such recursive transactions can | ||
190 | * easily deadlock with our current transaction as well as cause | ||
191 | * us to run out of stack space. | ||
192 | */ | ||
193 | bp = xfs_buf_get(target_dev, blkno, len, flags | XBF_DONT_BLOCK); | ||
194 | if (bp == NULL) { | 171 | if (bp == NULL) { |
195 | return NULL; | 172 | return NULL; |
196 | } | 173 | } |
@@ -282,14 +259,13 @@ xfs_trans_read_buf( | |||
282 | xfs_buf_log_item_t *bip; | 259 | xfs_buf_log_item_t *bip; |
283 | int error; | 260 | int error; |
284 | 261 | ||
285 | if (flags == 0) | 262 | *bpp = NULL; |
286 | flags = XBF_LOCK | XBF_MAPPED; | ||
287 | 263 | ||
288 | /* | 264 | /* |
289 | * Default to a normal get_buf() call if the tp is NULL. | 265 | * Default to a normal get_buf() call if the tp is NULL. |
290 | */ | 266 | */ |
291 | if (tp == NULL) { | 267 | if (tp == NULL) { |
292 | bp = xfs_buf_read(target, blkno, len, flags | XBF_DONT_BLOCK); | 268 | bp = xfs_buf_read(target, blkno, len, flags); |
293 | if (!bp) | 269 | if (!bp) |
294 | return (flags & XBF_TRYLOCK) ? | 270 | return (flags & XBF_TRYLOCK) ? |
295 | EAGAIN : XFS_ERROR(ENOMEM); | 271 | EAGAIN : XFS_ERROR(ENOMEM); |
@@ -297,6 +273,8 @@ xfs_trans_read_buf( | |||
297 | if (bp->b_error) { | 273 | if (bp->b_error) { |
298 | error = bp->b_error; | 274 | error = bp->b_error; |
299 | xfs_buf_ioerror_alert(bp, __func__); | 275 | xfs_buf_ioerror_alert(bp, __func__); |
276 | XFS_BUF_UNDONE(bp); | ||
277 | xfs_buf_stale(bp); | ||
300 | xfs_buf_relse(bp); | 278 | xfs_buf_relse(bp); |
301 | return error; | 279 | return error; |
302 | } | 280 | } |
@@ -371,15 +349,7 @@ xfs_trans_read_buf( | |||
371 | return 0; | 349 | return 0; |
372 | } | 350 | } |
373 | 351 | ||
374 | /* | 352 | bp = xfs_buf_read(target, blkno, len, flags); |
375 | * We always specify the XBF_DONT_BLOCK flag within a transaction | ||
376 | * so that get_buf does not try to push out a delayed write buffer | ||
377 | * which might cause another transaction to take place (if the | ||
378 | * buffer was delayed alloc). Such recursive transactions can | ||
379 | * easily deadlock with our current transaction as well as cause | ||
380 | * us to run out of stack space. | ||
381 | */ | ||
382 | bp = xfs_buf_read(target, blkno, len, flags | XBF_DONT_BLOCK); | ||
383 | if (bp == NULL) { | 353 | if (bp == NULL) { |
384 | *bpp = NULL; | 354 | *bpp = NULL; |
385 | return (flags & XBF_TRYLOCK) ? | 355 | return (flags & XBF_TRYLOCK) ? |
@@ -418,19 +388,6 @@ xfs_trans_read_buf( | |||
418 | return 0; | 388 | return 0; |
419 | 389 | ||
420 | shutdown_abort: | 390 | shutdown_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_); | 391 | trace_xfs_trans_read_buf_shut(bp, _RET_IP_); |
435 | xfs_buf_relse(bp); | 392 | xfs_buf_relse(bp); |
436 | *bpp = NULL; | 393 | *bpp = NULL; |
@@ -606,7 +563,7 @@ xfs_trans_log_buf(xfs_trans_t *tp, | |||
606 | 563 | ||
607 | ASSERT(bp->b_transp == tp); | 564 | ASSERT(bp->b_transp == tp); |
608 | ASSERT(bip != NULL); | 565 | ASSERT(bip != NULL); |
609 | ASSERT((first <= last) && (last < XFS_BUF_COUNT(bp))); | 566 | ASSERT(first <= last && last < BBTOB(bp->b_length)); |
610 | ASSERT(bp->b_iodone == NULL || | 567 | ASSERT(bp->b_iodone == NULL || |
611 | bp->b_iodone == xfs_buf_iodone_callbacks); | 568 | bp->b_iodone == xfs_buf_iodone_callbacks); |
612 | 569 | ||
@@ -626,8 +583,6 @@ xfs_trans_log_buf(xfs_trans_t *tp, | |||
626 | bp->b_iodone = xfs_buf_iodone_callbacks; | 583 | bp->b_iodone = xfs_buf_iodone_callbacks; |
627 | bip->bli_item.li_cb = xfs_buf_iodone; | 584 | bip->bli_item.li_cb = xfs_buf_iodone; |
628 | 585 | ||
629 | xfs_buf_delwri_queue(bp); | ||
630 | |||
631 | trace_xfs_trans_log_buf(bip); | 586 | trace_xfs_trans_log_buf(bip); |
632 | 587 | ||
633 | /* | 588 | /* |
@@ -651,22 +606,33 @@ xfs_trans_log_buf(xfs_trans_t *tp, | |||
651 | 606 | ||
652 | 607 | ||
653 | /* | 608 | /* |
654 | * This called to invalidate a buffer that is being used within | 609 | * Invalidate a buffer that is being used within a transaction. |
655 | * a transaction. Typically this is because the blocks in the | 610 | * |
656 | * buffer are being freed, so we need to prevent it from being | 611 | * Typically this is because the blocks in the buffer are being freed, so we |
657 | * written out when we're done. Allowing it to be written again | 612 | * need to prevent it from being written out when we're done. Allowing it |
658 | * might overwrite data in the free blocks if they are reallocated | 613 | * to be written again might overwrite data in the free blocks if they are |
659 | * to a file. | 614 | * reallocated to a file. |
615 | * | ||
616 | * We prevent the buffer from being written out by marking it stale. We can't | ||
617 | * get rid of the buf log item at this point because the buffer may still be | ||
618 | * pinned by another transaction. If that is the case, then we'll wait until | ||
619 | * the buffer is committed to disk for the last time (we can tell by the ref | ||
620 | * count) and free it in xfs_buf_item_unpin(). Until that happens we will | ||
621 | * keep the buffer locked so that the buffer and buf log item are not reused. | ||
622 | * | ||
623 | * We also set the XFS_BLF_CANCEL flag in the buf log format structure and log | ||
624 | * the buf item. This will be used at recovery time to determine that copies | ||
625 | * of the buffer in the log before this should not be replayed. | ||
660 | * | 626 | * |
661 | * We prevent the buffer from being written out by clearing the | 627 | * We mark the item descriptor and the transaction dirty so that we'll hold |
662 | * B_DELWRI flag. We can't always | 628 | * the buffer until after the commit. |
663 | * get rid of the buf log item at this point, though, because | 629 | * |
664 | * the buffer may still be pinned by another transaction. If that | 630 | * Since we're invalidating the buffer, we also clear the state about which |
665 | * is the case, then we'll wait until the buffer is committed to | 631 | * parts of the buffer have been logged. We also clear the flag indicating |
666 | * disk for the last time (we can tell by the ref count) and | 632 | * that this is an inode buffer since the data in the buffer will no longer |
667 | * free it in xfs_buf_item_unpin(). Until it is cleaned up we | 633 | * be valid. |
668 | * will keep the buffer locked so that the buffer and buf log item | 634 | * |
669 | * are not reused. | 635 | * We set the stale bit in the buffer as well since we're getting rid of it. |
670 | */ | 636 | */ |
671 | void | 637 | void |
672 | xfs_trans_binval( | 638 | xfs_trans_binval( |
@@ -686,7 +652,6 @@ xfs_trans_binval( | |||
686 | * If the buffer is already invalidated, then | 652 | * If the buffer is already invalidated, then |
687 | * just return. | 653 | * just return. |
688 | */ | 654 | */ |
689 | ASSERT(!(XFS_BUF_ISDELAYWRITE(bp))); | ||
690 | ASSERT(XFS_BUF_ISSTALE(bp)); | 655 | ASSERT(XFS_BUF_ISSTALE(bp)); |
691 | ASSERT(!(bip->bli_flags & (XFS_BLI_LOGGED | XFS_BLI_DIRTY))); | 656 | ASSERT(!(bip->bli_flags & (XFS_BLI_LOGGED | XFS_BLI_DIRTY))); |
692 | ASSERT(!(bip->bli_format.blf_flags & XFS_BLF_INODE_BUF)); | 657 | ASSERT(!(bip->bli_format.blf_flags & XFS_BLF_INODE_BUF)); |
@@ -696,27 +661,8 @@ xfs_trans_binval( | |||
696 | return; | 661 | return; |
697 | } | 662 | } |
698 | 663 | ||
699 | /* | ||
700 | * Clear the dirty bit in the buffer and set the STALE flag | ||
701 | * in the buf log item. The STALE flag will be used in | ||
702 | * xfs_buf_item_unpin() to determine if it should clean up | ||
703 | * when the last reference to the buf item is given up. | ||
704 | * We set the XFS_BLF_CANCEL flag in the buf log format structure | ||
705 | * and log the buf item. This will be used at recovery time | ||
706 | * to determine that copies of the buffer in the log before | ||
707 | * this should not be replayed. | ||
708 | * We mark the item descriptor and the transaction dirty so | ||
709 | * that we'll hold the buffer until after the commit. | ||
710 | * | ||
711 | * Since we're invalidating the buffer, we also clear the state | ||
712 | * about which parts of the buffer have been logged. We also | ||
713 | * clear the flag indicating that this is an inode buffer since | ||
714 | * the data in the buffer will no longer be valid. | ||
715 | * | ||
716 | * We set the stale bit in the buffer as well since we're getting | ||
717 | * rid of it. | ||
718 | */ | ||
719 | xfs_buf_stale(bp); | 664 | xfs_buf_stale(bp); |
665 | |||
720 | bip->bli_flags |= XFS_BLI_STALE; | 666 | bip->bli_flags |= XFS_BLI_STALE; |
721 | bip->bli_flags &= ~(XFS_BLI_INODE_BUF | XFS_BLI_LOGGED | XFS_BLI_DIRTY); | 667 | bip->bli_flags &= ~(XFS_BLI_INODE_BUF | XFS_BLI_LOGGED | XFS_BLI_DIRTY); |
722 | bip->bli_format.blf_flags &= ~XFS_BLF_INODE_BUF; | 668 | bip->bli_format.blf_flags &= ~XFS_BLF_INODE_BUF; |