aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_buf_item.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_buf_item.c')
-rw-r--r--fs/xfs/xfs_buf_item.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 88492916c3dc..ef43fce519a1 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -124,9 +124,9 @@ xfs_buf_item_log_check(
124 124
125 bp = bip->bli_buf; 125 bp = bip->bli_buf;
126 ASSERT(XFS_BUF_COUNT(bp) > 0); 126 ASSERT(XFS_BUF_COUNT(bp) > 0);
127 ASSERT(XFS_BUF_PTR(bp) != NULL); 127 ASSERT(bp->b_addr != NULL);
128 orig = bip->bli_orig; 128 orig = bip->bli_orig;
129 buffer = XFS_BUF_PTR(bp); 129 buffer = bp->b_addr;
130 for (x = 0; x < XFS_BUF_COUNT(bp); x++) { 130 for (x = 0; x < XFS_BUF_COUNT(bp); x++) {
131 if (orig[x] != buffer[x] && !btst(bip->bli_logged, x)) { 131 if (orig[x] != buffer[x] && !btst(bip->bli_logged, x)) {
132 xfs_emerg(bp->b_mount, 132 xfs_emerg(bp->b_mount,
@@ -371,7 +371,6 @@ xfs_buf_item_pin(
371{ 371{
372 struct xfs_buf_log_item *bip = BUF_ITEM(lip); 372 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
373 373
374 ASSERT(XFS_BUF_ISBUSY(bip->bli_buf));
375 ASSERT(atomic_read(&bip->bli_refcount) > 0); 374 ASSERT(atomic_read(&bip->bli_refcount) > 0);
376 ASSERT((bip->bli_flags & XFS_BLI_LOGGED) || 375 ASSERT((bip->bli_flags & XFS_BLI_LOGGED) ||
377 (bip->bli_flags & XFS_BLI_STALE)); 376 (bip->bli_flags & XFS_BLI_STALE));
@@ -479,13 +478,13 @@ xfs_buf_item_trylock(
479 struct xfs_buf_log_item *bip = BUF_ITEM(lip); 478 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
480 struct xfs_buf *bp = bip->bli_buf; 479 struct xfs_buf *bp = bip->bli_buf;
481 480
482 if (XFS_BUF_ISPINNED(bp)) 481 if (xfs_buf_ispinned(bp))
483 return XFS_ITEM_PINNED; 482 return XFS_ITEM_PINNED;
484 if (!xfs_buf_trylock(bp)) 483 if (!xfs_buf_trylock(bp))
485 return XFS_ITEM_LOCKED; 484 return XFS_ITEM_LOCKED;
486 485
487 /* take a reference to the buffer. */ 486 /* take a reference to the buffer. */
488 XFS_BUF_HOLD(bp); 487 xfs_buf_hold(bp);
489 488
490 ASSERT(!(bip->bli_flags & XFS_BLI_STALE)); 489 ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
491 trace_xfs_buf_item_trylock(bip); 490 trace_xfs_buf_item_trylock(bip);
@@ -630,7 +629,7 @@ xfs_buf_item_push(
630 * the xfsbufd to get this buffer written. We have to unlock the buffer 629 * the xfsbufd to get this buffer written. We have to unlock the buffer
631 * to allow the xfsbufd to write it, too. 630 * to allow the xfsbufd to write it, too.
632 */ 631 */
633STATIC void 632STATIC bool
634xfs_buf_item_pushbuf( 633xfs_buf_item_pushbuf(
635 struct xfs_log_item *lip) 634 struct xfs_log_item *lip)
636{ 635{
@@ -644,6 +643,7 @@ xfs_buf_item_pushbuf(
644 643
645 xfs_buf_delwri_promote(bp); 644 xfs_buf_delwri_promote(bp);
646 xfs_buf_relse(bp); 645 xfs_buf_relse(bp);
646 return true;
647} 647}
648 648
649STATIC void 649STATIC void
@@ -726,7 +726,7 @@ xfs_buf_item_init(
726 * to have logged. 726 * to have logged.
727 */ 727 */
728 bip->bli_orig = (char *)kmem_alloc(XFS_BUF_COUNT(bp), KM_SLEEP); 728 bip->bli_orig = (char *)kmem_alloc(XFS_BUF_COUNT(bp), KM_SLEEP);
729 memcpy(bip->bli_orig, XFS_BUF_PTR(bp), XFS_BUF_COUNT(bp)); 729 memcpy(bip->bli_orig, bp->b_addr, XFS_BUF_COUNT(bp));
730 bip->bli_logged = (char *)kmem_zalloc(XFS_BUF_COUNT(bp) / NBBY, KM_SLEEP); 730 bip->bli_logged = (char *)kmem_zalloc(XFS_BUF_COUNT(bp) / NBBY, KM_SLEEP);
731#endif 731#endif
732 732
@@ -895,7 +895,6 @@ xfs_buf_attach_iodone(
895{ 895{
896 xfs_log_item_t *head_lip; 896 xfs_log_item_t *head_lip;
897 897
898 ASSERT(XFS_BUF_ISBUSY(bp));
899 ASSERT(xfs_buf_islocked(bp)); 898 ASSERT(xfs_buf_islocked(bp));
900 899
901 lip->li_cb = cb; 900 lip->li_cb = cb;
@@ -960,7 +959,7 @@ xfs_buf_iodone_callbacks(
960 static ulong lasttime; 959 static ulong lasttime;
961 static xfs_buftarg_t *lasttarg; 960 static xfs_buftarg_t *lasttarg;
962 961
963 if (likely(!XFS_BUF_GETERROR(bp))) 962 if (likely(!xfs_buf_geterror(bp)))
964 goto do_callbacks; 963 goto do_callbacks;
965 964
966 /* 965 /*
@@ -973,14 +972,14 @@ xfs_buf_iodone_callbacks(
973 goto do_callbacks; 972 goto do_callbacks;
974 } 973 }
975 974
976 if (XFS_BUF_TARGET(bp) != lasttarg || 975 if (bp->b_target != lasttarg ||
977 time_after(jiffies, (lasttime + 5*HZ))) { 976 time_after(jiffies, (lasttime + 5*HZ))) {
978 lasttime = jiffies; 977 lasttime = jiffies;
979 xfs_alert(mp, "Device %s: metadata write error block 0x%llx", 978 xfs_alert(mp, "Device %s: metadata write error block 0x%llx",
980 XFS_BUFTARG_NAME(XFS_BUF_TARGET(bp)), 979 xfs_buf_target_name(bp->b_target),
981 (__uint64_t)XFS_BUF_ADDR(bp)); 980 (__uint64_t)XFS_BUF_ADDR(bp));
982 } 981 }
983 lasttarg = XFS_BUF_TARGET(bp); 982 lasttarg = bp->b_target;
984 983
985 /* 984 /*
986 * If the write was asynchronous then no one will be looking for the 985 * If the write was asynchronous then no one will be looking for the
@@ -991,12 +990,11 @@ xfs_buf_iodone_callbacks(
991 * around. 990 * around.
992 */ 991 */
993 if (XFS_BUF_ISASYNC(bp)) { 992 if (XFS_BUF_ISASYNC(bp)) {
994 XFS_BUF_ERROR(bp, 0); /* errno of 0 unsets the flag */ 993 xfs_buf_ioerror(bp, 0); /* errno of 0 unsets the flag */
995 994
996 if (!XFS_BUF_ISSTALE(bp)) { 995 if (!XFS_BUF_ISSTALE(bp)) {
997 XFS_BUF_DELAYWRITE(bp); 996 XFS_BUF_DELAYWRITE(bp);
998 XFS_BUF_DONE(bp); 997 XFS_BUF_DONE(bp);
999 XFS_BUF_SET_START(bp);
1000 } 998 }
1001 ASSERT(bp->b_iodone != NULL); 999 ASSERT(bp->b_iodone != NULL);
1002 trace_xfs_buf_item_iodone_async(bp, _RET_IP_); 1000 trace_xfs_buf_item_iodone_async(bp, _RET_IP_);
@@ -1013,7 +1011,6 @@ xfs_buf_iodone_callbacks(
1013 XFS_BUF_UNDELAYWRITE(bp); 1011 XFS_BUF_UNDELAYWRITE(bp);
1014 1012
1015 trace_xfs_buf_error_relse(bp, _RET_IP_); 1013 trace_xfs_buf_error_relse(bp, _RET_IP_);
1016 xfs_force_shutdown(mp, SHUTDOWN_META_IO_ERROR);
1017 1014
1018do_callbacks: 1015do_callbacks:
1019 xfs_buf_do_callbacks(bp); 1016 xfs_buf_do_callbacks(bp);