aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_trans_buf.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_trans_buf.c')
-rw-r--r--fs/xfs/xfs_trans_buf.c75
1 files changed, 31 insertions, 44 deletions
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c
index 218829e6a152..49130628d5ef 100644
--- a/fs/xfs/xfs_trans_buf.c
+++ b/fs/xfs/xfs_trans_buf.c
@@ -38,6 +38,7 @@
38#include "xfs_trans_priv.h" 38#include "xfs_trans_priv.h"
39#include "xfs_error.h" 39#include "xfs_error.h"
40#include "xfs_rw.h" 40#include "xfs_rw.h"
41#include "xfs_trace.h"
41 42
42 43
43STATIC xfs_buf_t *xfs_trans_buf_item_match(xfs_trans_t *, xfs_buftarg_t *, 44STATIC xfs_buf_t *xfs_trans_buf_item_match(xfs_trans_t *, xfs_buftarg_t *,
@@ -79,11 +80,8 @@ xfs_trans_get_buf(xfs_trans_t *tp,
79 /* 80 /*
80 * Default to a normal get_buf() call if the tp is NULL. 81 * Default to a normal get_buf() call if the tp is NULL.
81 */ 82 */
82 if (tp == NULL) { 83 if (tp == NULL)
83 bp = xfs_buf_get_flags(target_dev, blkno, len, 84 return xfs_buf_get(target_dev, blkno, len, flags | BUF_BUSY);
84 flags | BUF_BUSY);
85 return(bp);
86 }
87 85
88 /* 86 /*
89 * If we find the buffer in the cache with this transaction 87 * If we find the buffer in the cache with this transaction
@@ -98,26 +96,23 @@ xfs_trans_get_buf(xfs_trans_t *tp,
98 } 96 }
99 if (bp != NULL) { 97 if (bp != NULL) {
100 ASSERT(XFS_BUF_VALUSEMA(bp) <= 0); 98 ASSERT(XFS_BUF_VALUSEMA(bp) <= 0);
101 if (XFS_FORCED_SHUTDOWN(tp->t_mountp)) { 99 if (XFS_FORCED_SHUTDOWN(tp->t_mountp))
102 xfs_buftrace("TRANS GET RECUR SHUT", bp);
103 XFS_BUF_SUPER_STALE(bp); 100 XFS_BUF_SUPER_STALE(bp);
104 } 101
105 /* 102 /*
106 * If the buffer is stale then it was binval'ed 103 * If the buffer is stale then it was binval'ed
107 * since last read. This doesn't matter since the 104 * since last read. This doesn't matter since the
108 * caller isn't allowed to use the data anyway. 105 * caller isn't allowed to use the data anyway.
109 */ 106 */
110 else if (XFS_BUF_ISSTALE(bp)) { 107 else if (XFS_BUF_ISSTALE(bp))
111 xfs_buftrace("TRANS GET RECUR STALE", bp);
112 ASSERT(!XFS_BUF_ISDELAYWRITE(bp)); 108 ASSERT(!XFS_BUF_ISDELAYWRITE(bp));
113 } 109
114 ASSERT(XFS_BUF_FSPRIVATE2(bp, xfs_trans_t *) == tp); 110 ASSERT(XFS_BUF_FSPRIVATE2(bp, xfs_trans_t *) == tp);
115 bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *); 111 bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *);
116 ASSERT(bip != NULL); 112 ASSERT(bip != NULL);
117 ASSERT(atomic_read(&bip->bli_refcount) > 0); 113 ASSERT(atomic_read(&bip->bli_refcount) > 0);
118 bip->bli_recur++; 114 bip->bli_recur++;
119 xfs_buftrace("TRANS GET RECUR", bp); 115 trace_xfs_trans_get_buf_recur(bip);
120 xfs_buf_item_trace("GET RECUR", bip);
121 return (bp); 116 return (bp);
122 } 117 }
123 118
@@ -129,7 +124,7 @@ xfs_trans_get_buf(xfs_trans_t *tp,
129 * easily deadlock with our current transaction as well as cause 124 * easily deadlock with our current transaction as well as cause
130 * us to run out of stack space. 125 * us to run out of stack space.
131 */ 126 */
132 bp = xfs_buf_get_flags(target_dev, blkno, len, flags | BUF_BUSY); 127 bp = xfs_buf_get(target_dev, blkno, len, flags | BUF_BUSY);
133 if (bp == NULL) { 128 if (bp == NULL) {
134 return NULL; 129 return NULL;
135 } 130 }
@@ -169,8 +164,7 @@ xfs_trans_get_buf(xfs_trans_t *tp,
169 */ 164 */
170 XFS_BUF_SET_FSPRIVATE2(bp, tp); 165 XFS_BUF_SET_FSPRIVATE2(bp, tp);
171 166
172 xfs_buftrace("TRANS GET", bp); 167 trace_xfs_trans_get_buf(bip);
173 xfs_buf_item_trace("GET", bip);
174 return (bp); 168 return (bp);
175} 169}
176 170
@@ -210,7 +204,7 @@ xfs_trans_getsb(xfs_trans_t *tp,
210 ASSERT(bip != NULL); 204 ASSERT(bip != NULL);
211 ASSERT(atomic_read(&bip->bli_refcount) > 0); 205 ASSERT(atomic_read(&bip->bli_refcount) > 0);
212 bip->bli_recur++; 206 bip->bli_recur++;
213 xfs_buf_item_trace("GETSB RECUR", bip); 207 trace_xfs_trans_getsb_recur(bip);
214 return (bp); 208 return (bp);
215 } 209 }
216 210
@@ -252,7 +246,7 @@ xfs_trans_getsb(xfs_trans_t *tp,
252 */ 246 */
253 XFS_BUF_SET_FSPRIVATE2(bp, tp); 247 XFS_BUF_SET_FSPRIVATE2(bp, tp);
254 248
255 xfs_buf_item_trace("GETSB", bip); 249 trace_xfs_trans_getsb(bip);
256 return (bp); 250 return (bp);
257} 251}
258 252
@@ -302,7 +296,7 @@ xfs_trans_read_buf(
302 * Default to a normal get_buf() call if the tp is NULL. 296 * Default to a normal get_buf() call if the tp is NULL.
303 */ 297 */
304 if (tp == NULL) { 298 if (tp == NULL) {
305 bp = xfs_buf_read_flags(target, blkno, len, flags | BUF_BUSY); 299 bp = xfs_buf_read(target, blkno, len, flags | BUF_BUSY);
306 if (!bp) 300 if (!bp)
307 return (flags & XFS_BUF_TRYLOCK) ? 301 return (flags & XFS_BUF_TRYLOCK) ?
308 EAGAIN : XFS_ERROR(ENOMEM); 302 EAGAIN : XFS_ERROR(ENOMEM);
@@ -350,7 +344,7 @@ xfs_trans_read_buf(
350 ASSERT(XFS_BUF_FSPRIVATE(bp, void *) != NULL); 344 ASSERT(XFS_BUF_FSPRIVATE(bp, void *) != NULL);
351 ASSERT((XFS_BUF_ISERROR(bp)) == 0); 345 ASSERT((XFS_BUF_ISERROR(bp)) == 0);
352 if (!(XFS_BUF_ISDONE(bp))) { 346 if (!(XFS_BUF_ISDONE(bp))) {
353 xfs_buftrace("READ_BUF_INCORE !DONE", bp); 347 trace_xfs_trans_read_buf_io(bp, _RET_IP_);
354 ASSERT(!XFS_BUF_ISASYNC(bp)); 348 ASSERT(!XFS_BUF_ISASYNC(bp));
355 XFS_BUF_READ(bp); 349 XFS_BUF_READ(bp);
356 xfsbdstrat(tp->t_mountp, bp); 350 xfsbdstrat(tp->t_mountp, bp);
@@ -375,7 +369,7 @@ xfs_trans_read_buf(
375 * brelse it either. Just get out. 369 * brelse it either. Just get out.
376 */ 370 */
377 if (XFS_FORCED_SHUTDOWN(mp)) { 371 if (XFS_FORCED_SHUTDOWN(mp)) {
378 xfs_buftrace("READ_BUF_INCORE XFSSHUTDN", bp); 372 trace_xfs_trans_read_buf_shut(bp, _RET_IP_);
379 *bpp = NULL; 373 *bpp = NULL;
380 return XFS_ERROR(EIO); 374 return XFS_ERROR(EIO);
381 } 375 }
@@ -385,7 +379,7 @@ xfs_trans_read_buf(
385 bip->bli_recur++; 379 bip->bli_recur++;
386 380
387 ASSERT(atomic_read(&bip->bli_refcount) > 0); 381 ASSERT(atomic_read(&bip->bli_refcount) > 0);
388 xfs_buf_item_trace("READ RECUR", bip); 382 trace_xfs_trans_read_buf_recur(bip);
389 *bpp = bp; 383 *bpp = bp;
390 return 0; 384 return 0;
391 } 385 }
@@ -398,14 +392,13 @@ xfs_trans_read_buf(
398 * easily deadlock with our current transaction as well as cause 392 * easily deadlock with our current transaction as well as cause
399 * us to run out of stack space. 393 * us to run out of stack space.
400 */ 394 */
401 bp = xfs_buf_read_flags(target, blkno, len, flags | BUF_BUSY); 395 bp = xfs_buf_read(target, blkno, len, flags | BUF_BUSY);
402 if (bp == NULL) { 396 if (bp == NULL) {
403 *bpp = NULL; 397 *bpp = NULL;
404 return 0; 398 return 0;
405 } 399 }
406 if (XFS_BUF_GETERROR(bp) != 0) { 400 if (XFS_BUF_GETERROR(bp) != 0) {
407 XFS_BUF_SUPER_STALE(bp); 401 XFS_BUF_SUPER_STALE(bp);
408 xfs_buftrace("READ ERROR", bp);
409 error = XFS_BUF_GETERROR(bp); 402 error = XFS_BUF_GETERROR(bp);
410 403
411 xfs_ioerror_alert("xfs_trans_read_buf", mp, 404 xfs_ioerror_alert("xfs_trans_read_buf", mp,
@@ -464,8 +457,7 @@ xfs_trans_read_buf(
464 */ 457 */
465 XFS_BUF_SET_FSPRIVATE2(bp, tp); 458 XFS_BUF_SET_FSPRIVATE2(bp, tp);
466 459
467 xfs_buftrace("TRANS READ", bp); 460 trace_xfs_trans_read_buf(bip);
468 xfs_buf_item_trace("READ", bip);
469 *bpp = bp; 461 *bpp = bp;
470 return 0; 462 return 0;
471 463
@@ -483,7 +475,7 @@ shutdown_abort:
483 ASSERT((XFS_BUF_BFLAGS(bp) & (XFS_B_STALE|XFS_B_DELWRI)) != 475 ASSERT((XFS_BUF_BFLAGS(bp) & (XFS_B_STALE|XFS_B_DELWRI)) !=
484 (XFS_B_STALE|XFS_B_DELWRI)); 476 (XFS_B_STALE|XFS_B_DELWRI));
485 477
486 xfs_buftrace("READ_BUF XFSSHUTDN", bp); 478 trace_xfs_trans_read_buf_shut(bp, _RET_IP_);
487 xfs_buf_relse(bp); 479 xfs_buf_relse(bp);
488 *bpp = NULL; 480 *bpp = NULL;
489 return XFS_ERROR(EIO); 481 return XFS_ERROR(EIO);
@@ -549,13 +541,14 @@ xfs_trans_brelse(xfs_trans_t *tp,
549 lidp = xfs_trans_find_item(tp, (xfs_log_item_t*)bip); 541 lidp = xfs_trans_find_item(tp, (xfs_log_item_t*)bip);
550 ASSERT(lidp != NULL); 542 ASSERT(lidp != NULL);
551 543
544 trace_xfs_trans_brelse(bip);
545
552 /* 546 /*
553 * If the release is just for a recursive lock, 547 * If the release is just for a recursive lock,
554 * then decrement the count and return. 548 * then decrement the count and return.
555 */ 549 */
556 if (bip->bli_recur > 0) { 550 if (bip->bli_recur > 0) {
557 bip->bli_recur--; 551 bip->bli_recur--;
558 xfs_buf_item_trace("RELSE RECUR", bip);
559 return; 552 return;
560 } 553 }
561 554
@@ -563,10 +556,8 @@ xfs_trans_brelse(xfs_trans_t *tp,
563 * If the buffer is dirty within this transaction, we can't 556 * If the buffer is dirty within this transaction, we can't
564 * release it until we commit. 557 * release it until we commit.
565 */ 558 */
566 if (lidp->lid_flags & XFS_LID_DIRTY) { 559 if (lidp->lid_flags & XFS_LID_DIRTY)
567 xfs_buf_item_trace("RELSE DIRTY", bip);
568 return; 560 return;
569 }
570 561
571 /* 562 /*
572 * If the buffer has been invalidated, then we can't release 563 * If the buffer has been invalidated, then we can't release
@@ -574,13 +565,10 @@ xfs_trans_brelse(xfs_trans_t *tp,
574 * as part of this transaction. This prevents us from pulling 565 * as part of this transaction. This prevents us from pulling
575 * the item from the AIL before we should. 566 * the item from the AIL before we should.
576 */ 567 */
577 if (bip->bli_flags & XFS_BLI_STALE) { 568 if (bip->bli_flags & XFS_BLI_STALE)
578 xfs_buf_item_trace("RELSE STALE", bip);
579 return; 569 return;
580 }
581 570
582 ASSERT(!(bip->bli_flags & XFS_BLI_LOGGED)); 571 ASSERT(!(bip->bli_flags & XFS_BLI_LOGGED));
583 xfs_buf_item_trace("RELSE", bip);
584 572
585 /* 573 /*
586 * Free up the log item descriptor tracking the released item. 574 * Free up the log item descriptor tracking the released item.
@@ -677,7 +665,7 @@ xfs_trans_bjoin(xfs_trans_t *tp,
677 */ 665 */
678 XFS_BUF_SET_FSPRIVATE2(bp, tp); 666 XFS_BUF_SET_FSPRIVATE2(bp, tp);
679 667
680 xfs_buf_item_trace("BJOIN", bip); 668 trace_xfs_trans_bjoin(bip);
681} 669}
682 670
683/* 671/*
@@ -701,7 +689,7 @@ xfs_trans_bhold(xfs_trans_t *tp,
701 ASSERT(!(bip->bli_format.blf_flags & XFS_BLI_CANCEL)); 689 ASSERT(!(bip->bli_format.blf_flags & XFS_BLI_CANCEL));
702 ASSERT(atomic_read(&bip->bli_refcount) > 0); 690 ASSERT(atomic_read(&bip->bli_refcount) > 0);
703 bip->bli_flags |= XFS_BLI_HOLD; 691 bip->bli_flags |= XFS_BLI_HOLD;
704 xfs_buf_item_trace("BHOLD", bip); 692 trace_xfs_trans_bhold(bip);
705} 693}
706 694
707/* 695/*
@@ -724,7 +712,8 @@ xfs_trans_bhold_release(xfs_trans_t *tp,
724 ASSERT(atomic_read(&bip->bli_refcount) > 0); 712 ASSERT(atomic_read(&bip->bli_refcount) > 0);
725 ASSERT(bip->bli_flags & XFS_BLI_HOLD); 713 ASSERT(bip->bli_flags & XFS_BLI_HOLD);
726 bip->bli_flags &= ~XFS_BLI_HOLD; 714 bip->bli_flags &= ~XFS_BLI_HOLD;
727 xfs_buf_item_trace("BHOLD RELEASE", bip); 715
716 trace_xfs_trans_bhold_release(bip);
728} 717}
729 718
730/* 719/*
@@ -770,6 +759,8 @@ xfs_trans_log_buf(xfs_trans_t *tp,
770 XFS_BUF_SET_IODONE_FUNC(bp, xfs_buf_iodone_callbacks); 759 XFS_BUF_SET_IODONE_FUNC(bp, xfs_buf_iodone_callbacks);
771 bip->bli_item.li_cb = (void(*)(xfs_buf_t*,xfs_log_item_t*))xfs_buf_iodone; 760 bip->bli_item.li_cb = (void(*)(xfs_buf_t*,xfs_log_item_t*))xfs_buf_iodone;
772 761
762 trace_xfs_trans_log_buf(bip);
763
773 /* 764 /*
774 * If we invalidated the buffer within this transaction, then 765 * If we invalidated the buffer within this transaction, then
775 * cancel the invalidation now that we're dirtying the buffer 766 * cancel the invalidation now that we're dirtying the buffer
@@ -777,7 +768,6 @@ xfs_trans_log_buf(xfs_trans_t *tp,
777 * because we have a reference to the buffer this entire time. 768 * because we have a reference to the buffer this entire time.
778 */ 769 */
779 if (bip->bli_flags & XFS_BLI_STALE) { 770 if (bip->bli_flags & XFS_BLI_STALE) {
780 xfs_buf_item_trace("BLOG UNSTALE", bip);
781 bip->bli_flags &= ~XFS_BLI_STALE; 771 bip->bli_flags &= ~XFS_BLI_STALE;
782 ASSERT(XFS_BUF_ISSTALE(bp)); 772 ASSERT(XFS_BUF_ISSTALE(bp));
783 XFS_BUF_UNSTALE(bp); 773 XFS_BUF_UNSTALE(bp);
@@ -792,7 +782,6 @@ xfs_trans_log_buf(xfs_trans_t *tp,
792 lidp->lid_flags &= ~XFS_LID_BUF_STALE; 782 lidp->lid_flags &= ~XFS_LID_BUF_STALE;
793 bip->bli_flags |= XFS_BLI_LOGGED; 783 bip->bli_flags |= XFS_BLI_LOGGED;
794 xfs_buf_item_log(bip, first, last); 784 xfs_buf_item_log(bip, first, last);
795 xfs_buf_item_trace("BLOG", bip);
796} 785}
797 786
798 787
@@ -831,6 +820,8 @@ xfs_trans_binval(
831 ASSERT(lidp != NULL); 820 ASSERT(lidp != NULL);
832 ASSERT(atomic_read(&bip->bli_refcount) > 0); 821 ASSERT(atomic_read(&bip->bli_refcount) > 0);
833 822
823 trace_xfs_trans_binval(bip);
824
834 if (bip->bli_flags & XFS_BLI_STALE) { 825 if (bip->bli_flags & XFS_BLI_STALE) {
835 /* 826 /*
836 * If the buffer is already invalidated, then 827 * If the buffer is already invalidated, then
@@ -843,8 +834,6 @@ xfs_trans_binval(
843 ASSERT(bip->bli_format.blf_flags & XFS_BLI_CANCEL); 834 ASSERT(bip->bli_format.blf_flags & XFS_BLI_CANCEL);
844 ASSERT(lidp->lid_flags & XFS_LID_DIRTY); 835 ASSERT(lidp->lid_flags & XFS_LID_DIRTY);
845 ASSERT(tp->t_flags & XFS_TRANS_DIRTY); 836 ASSERT(tp->t_flags & XFS_TRANS_DIRTY);
846 xfs_buftrace("XFS_BINVAL RECUR", bp);
847 xfs_buf_item_trace("BINVAL RECUR", bip);
848 return; 837 return;
849 } 838 }
850 839
@@ -878,8 +867,6 @@ xfs_trans_binval(
878 (bip->bli_format.blf_map_size * sizeof(uint))); 867 (bip->bli_format.blf_map_size * sizeof(uint)));
879 lidp->lid_flags |= XFS_LID_DIRTY|XFS_LID_BUF_STALE; 868 lidp->lid_flags |= XFS_LID_DIRTY|XFS_LID_BUF_STALE;
880 tp->t_flags |= XFS_TRANS_DIRTY; 869 tp->t_flags |= XFS_TRANS_DIRTY;
881 xfs_buftrace("XFS_BINVAL", bp);
882 xfs_buf_item_trace("BINVAL", bip);
883} 870}
884 871
885/* 872/*