aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-08-12 23:43:01 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-08-12 23:43:01 -0400
commite68ff9cd15552e46e0f993eace25af0947b1222d (patch)
tree28873106aa1c88963a13b34a4bc209875763a4e4 /fs
parentc44efbaa0ef3cf53fbf6bb57c33d4f199b15f2da (diff)
parente570280521290c27621d60cffea2400bdf1f2c88 (diff)
Merge branch 'for-linus' of git://oss.sgi.com/xfs/xfs
* 'for-linus' of git://oss.sgi.com/xfs/xfs: xfs: replace xfs_buf_geterror() with bp->b_error xfs: Check the return value of xfs_buf_read() for NULL "xfs: fix error handling for synchronous writes" revisited xfs: set cursor in xfs_ail_splice() even when AIL was empty xfs: Remove the macro XFS_BUFTARG_NAME xfs: Remove the macro XFS_BUF_TARGET xfs: Remove the macro XFS_BUF_SET_TARGET Replace the macro XFS_BUF_ISPINNED with helper xfs_buf_ispinned xfs: Remove the macro XFS_BUF_SET_PTR xfs: Remove the macro XFS_BUF_PTR xfs: Remove macro XFS_BUF_SET_START xfs: Remove macro XFS_BUF_HOLD xfs: Remove macro XFS_BUF_BUSY and family xfs: Remove the macro XFS_BUF_ERROR and family xfs: Remove the macro XFS_BUF_BFLAGS
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c15
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.h32
-rw-r--r--fs/xfs/linux-2.6/xfs_sync.c2
-rw-r--r--fs/xfs/quota/xfs_dquot.c16
-rw-r--r--fs/xfs/quota/xfs_qm.c2
-rw-r--r--fs/xfs/xfs_ag.h6
-rw-r--r--fs/xfs/xfs_alloc.c7
-rw-r--r--fs/xfs/xfs_attr.c3
-rw-r--r--fs/xfs/xfs_bmap.c3
-rw-r--r--fs/xfs/xfs_btree.c17
-rw-r--r--fs/xfs/xfs_btree.h2
-rw-r--r--fs/xfs/xfs_buf_item.c24
-rw-r--r--fs/xfs/xfs_da_btree.c12
-rw-r--r--fs/xfs/xfs_dinode.h2
-rw-r--r--fs/xfs/xfs_ialloc.c5
-rw-r--r--fs/xfs/xfs_inode.c4
-rw-r--r--fs/xfs/xfs_log.c14
-rw-r--r--fs/xfs/xfs_log_recover.c38
-rw-r--r--fs/xfs/xfs_mount.c4
-rw-r--r--fs/xfs/xfs_rtalloc.c32
-rw-r--r--fs/xfs/xfs_rtalloc.h2
-rw-r--r--fs/xfs/xfs_rw.c8
-rw-r--r--fs/xfs/xfs_sb.h2
-rw-r--r--fs/xfs/xfs_trans_ail.c67
-rw-r--r--fs/xfs/xfs_trans_buf.c28
-rw-r--r--fs/xfs/xfs_vnodeops.c12
26 files changed, 155 insertions, 204 deletions
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index d1fe74506c4c..c57836dc778f 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -596,7 +596,7 @@ _xfs_buf_read(
596 bp->b_flags |= flags & (XBF_READ | XBF_ASYNC | XBF_READ_AHEAD); 596 bp->b_flags |= flags & (XBF_READ | XBF_ASYNC | XBF_READ_AHEAD);
597 597
598 status = xfs_buf_iorequest(bp); 598 status = xfs_buf_iorequest(bp);
599 if (status || XFS_BUF_ISERROR(bp) || (flags & XBF_ASYNC)) 599 if (status || bp->b_error || (flags & XBF_ASYNC))
600 return status; 600 return status;
601 return xfs_buf_iowait(bp); 601 return xfs_buf_iowait(bp);
602} 602}
@@ -679,7 +679,6 @@ xfs_buf_read_uncached(
679 /* set up the buffer for a read IO */ 679 /* set up the buffer for a read IO */
680 XFS_BUF_SET_ADDR(bp, daddr); 680 XFS_BUF_SET_ADDR(bp, daddr);
681 XFS_BUF_READ(bp); 681 XFS_BUF_READ(bp);
682 XFS_BUF_BUSY(bp);
683 682
684 xfsbdstrat(mp, bp); 683 xfsbdstrat(mp, bp);
685 error = xfs_buf_iowait(bp); 684 error = xfs_buf_iowait(bp);
@@ -1069,7 +1068,7 @@ xfs_bioerror(
1069 /* 1068 /*
1070 * No need to wait until the buffer is unpinned, we aren't flushing it. 1069 * No need to wait until the buffer is unpinned, we aren't flushing it.
1071 */ 1070 */
1072 XFS_BUF_ERROR(bp, EIO); 1071 xfs_buf_ioerror(bp, EIO);
1073 1072
1074 /* 1073 /*
1075 * We're calling xfs_buf_ioend, so delete XBF_DONE flag. 1074 * We're calling xfs_buf_ioend, so delete XBF_DONE flag.
@@ -1094,7 +1093,7 @@ STATIC int
1094xfs_bioerror_relse( 1093xfs_bioerror_relse(
1095 struct xfs_buf *bp) 1094 struct xfs_buf *bp)
1096{ 1095{
1097 int64_t fl = XFS_BUF_BFLAGS(bp); 1096 int64_t fl = bp->b_flags;
1098 /* 1097 /*
1099 * No need to wait until the buffer is unpinned. 1098 * No need to wait until the buffer is unpinned.
1100 * We aren't flushing it. 1099 * We aren't flushing it.
@@ -1115,7 +1114,7 @@ xfs_bioerror_relse(
1115 * There's no reason to mark error for 1114 * There's no reason to mark error for
1116 * ASYNC buffers. 1115 * ASYNC buffers.
1117 */ 1116 */
1118 XFS_BUF_ERROR(bp, EIO); 1117 xfs_buf_ioerror(bp, EIO);
1119 XFS_BUF_FINISH_IOWAIT(bp); 1118 XFS_BUF_FINISH_IOWAIT(bp);
1120 } else { 1119 } else {
1121 xfs_buf_relse(bp); 1120 xfs_buf_relse(bp);
@@ -1324,7 +1323,7 @@ xfs_buf_offset(
1324 struct page *page; 1323 struct page *page;
1325 1324
1326 if (bp->b_flags & XBF_MAPPED) 1325 if (bp->b_flags & XBF_MAPPED)
1327 return XFS_BUF_PTR(bp) + offset; 1326 return bp->b_addr + offset;
1328 1327
1329 offset += bp->b_offset; 1328 offset += bp->b_offset;
1330 page = bp->b_pages[offset >> PAGE_SHIFT]; 1329 page = bp->b_pages[offset >> PAGE_SHIFT];
@@ -1484,7 +1483,7 @@ xfs_setsize_buftarg_flags(
1484 if (set_blocksize(btp->bt_bdev, sectorsize)) { 1483 if (set_blocksize(btp->bt_bdev, sectorsize)) {
1485 xfs_warn(btp->bt_mount, 1484 xfs_warn(btp->bt_mount,
1486 "Cannot set_blocksize to %u on device %s\n", 1485 "Cannot set_blocksize to %u on device %s\n",
1487 sectorsize, XFS_BUFTARG_NAME(btp)); 1486 sectorsize, xfs_buf_target_name(btp));
1488 return EINVAL; 1487 return EINVAL;
1489 } 1488 }
1490 1489
@@ -1681,7 +1680,7 @@ xfs_buf_delwri_split(
1681 list_for_each_entry_safe(bp, n, dwq, b_list) { 1680 list_for_each_entry_safe(bp, n, dwq, b_list) {
1682 ASSERT(bp->b_flags & XBF_DELWRI); 1681 ASSERT(bp->b_flags & XBF_DELWRI);
1683 1682
1684 if (!XFS_BUF_ISPINNED(bp) && xfs_buf_trylock(bp)) { 1683 if (!xfs_buf_ispinned(bp) && xfs_buf_trylock(bp)) {
1685 if (!force && 1684 if (!force &&
1686 time_before(jiffies, bp->b_queuetime + age)) { 1685 time_before(jiffies, bp->b_queuetime + age)) {
1687 xfs_buf_unlock(bp); 1686 xfs_buf_unlock(bp);
diff --git a/fs/xfs/linux-2.6/xfs_buf.h b/fs/xfs/linux-2.6/xfs_buf.h
index 6a83b46b4bcf..620972b8094d 100644
--- a/fs/xfs/linux-2.6/xfs_buf.h
+++ b/fs/xfs/linux-2.6/xfs_buf.h
@@ -228,11 +228,15 @@ extern void xfs_buf_delwri_promote(xfs_buf_t *);
228extern int xfs_buf_init(void); 228extern int xfs_buf_init(void);
229extern void xfs_buf_terminate(void); 229extern void xfs_buf_terminate(void);
230 230
231#define xfs_buf_target_name(target) \ 231static inline const char *
232 ({ char __b[BDEVNAME_SIZE]; bdevname((target)->bt_bdev, __b); __b; }) 232xfs_buf_target_name(struct xfs_buftarg *target)
233{
234 static char __b[BDEVNAME_SIZE];
235
236 return bdevname(target->bt_bdev, __b);
237}
233 238
234 239
235#define XFS_BUF_BFLAGS(bp) ((bp)->b_flags)
236#define XFS_BUF_ZEROFLAGS(bp) \ 240#define XFS_BUF_ZEROFLAGS(bp) \
237 ((bp)->b_flags &= ~(XBF_READ|XBF_WRITE|XBF_ASYNC|XBF_DELWRI| \ 241 ((bp)->b_flags &= ~(XBF_READ|XBF_WRITE|XBF_ASYNC|XBF_DELWRI| \
238 XBF_SYNCIO|XBF_FUA|XBF_FLUSH)) 242 XBF_SYNCIO|XBF_FUA|XBF_FLUSH))
@@ -251,23 +255,14 @@ void xfs_buf_stale(struct xfs_buf *bp);
251#define XFS_BUF_UNDELAYWRITE(bp) xfs_buf_delwri_dequeue(bp) 255#define XFS_BUF_UNDELAYWRITE(bp) xfs_buf_delwri_dequeue(bp)
252#define XFS_BUF_ISDELAYWRITE(bp) ((bp)->b_flags & XBF_DELWRI) 256#define XFS_BUF_ISDELAYWRITE(bp) ((bp)->b_flags & XBF_DELWRI)
253 257
254#define XFS_BUF_ERROR(bp,no) xfs_buf_ioerror(bp,no)
255#define XFS_BUF_GETERROR(bp) xfs_buf_geterror(bp)
256#define XFS_BUF_ISERROR(bp) (xfs_buf_geterror(bp) ? 1 : 0)
257
258#define XFS_BUF_DONE(bp) ((bp)->b_flags |= XBF_DONE) 258#define XFS_BUF_DONE(bp) ((bp)->b_flags |= XBF_DONE)
259#define XFS_BUF_UNDONE(bp) ((bp)->b_flags &= ~XBF_DONE) 259#define XFS_BUF_UNDONE(bp) ((bp)->b_flags &= ~XBF_DONE)
260#define XFS_BUF_ISDONE(bp) ((bp)->b_flags & XBF_DONE) 260#define XFS_BUF_ISDONE(bp) ((bp)->b_flags & XBF_DONE)
261 261
262#define XFS_BUF_BUSY(bp) do { } while (0)
263#define XFS_BUF_UNBUSY(bp) do { } while (0)
264#define XFS_BUF_ISBUSY(bp) (1)
265
266#define XFS_BUF_ASYNC(bp) ((bp)->b_flags |= XBF_ASYNC) 262#define XFS_BUF_ASYNC(bp) ((bp)->b_flags |= XBF_ASYNC)
267#define XFS_BUF_UNASYNC(bp) ((bp)->b_flags &= ~XBF_ASYNC) 263#define XFS_BUF_UNASYNC(bp) ((bp)->b_flags &= ~XBF_ASYNC)
268#define XFS_BUF_ISASYNC(bp) ((bp)->b_flags & XBF_ASYNC) 264#define XFS_BUF_ISASYNC(bp) ((bp)->b_flags & XBF_ASYNC)
269 265
270#define XFS_BUF_HOLD(bp) xfs_buf_hold(bp)
271#define XFS_BUF_READ(bp) ((bp)->b_flags |= XBF_READ) 266#define XFS_BUF_READ(bp) ((bp)->b_flags |= XBF_READ)
272#define XFS_BUF_UNREAD(bp) ((bp)->b_flags &= ~XBF_READ) 267#define XFS_BUF_UNREAD(bp) ((bp)->b_flags &= ~XBF_READ)
273#define XFS_BUF_ISREAD(bp) ((bp)->b_flags & XBF_READ) 268#define XFS_BUF_ISREAD(bp) ((bp)->b_flags & XBF_READ)
@@ -276,10 +271,6 @@ void xfs_buf_stale(struct xfs_buf *bp);
276#define XFS_BUF_UNWRITE(bp) ((bp)->b_flags &= ~XBF_WRITE) 271#define XFS_BUF_UNWRITE(bp) ((bp)->b_flags &= ~XBF_WRITE)
277#define XFS_BUF_ISWRITE(bp) ((bp)->b_flags & XBF_WRITE) 272#define XFS_BUF_ISWRITE(bp) ((bp)->b_flags & XBF_WRITE)
278 273
279#define XFS_BUF_SET_START(bp) do { } while (0)
280
281#define XFS_BUF_PTR(bp) (xfs_caddr_t)((bp)->b_addr)
282#define XFS_BUF_SET_PTR(bp, val, cnt) xfs_buf_associate_memory(bp, val, cnt)
283#define XFS_BUF_ADDR(bp) ((bp)->b_bn) 274#define XFS_BUF_ADDR(bp) ((bp)->b_bn)
284#define XFS_BUF_SET_ADDR(bp, bno) ((bp)->b_bn = (xfs_daddr_t)(bno)) 275#define XFS_BUF_SET_ADDR(bp, bno) ((bp)->b_bn = (xfs_daddr_t)(bno))
285#define XFS_BUF_OFFSET(bp) ((bp)->b_file_offset) 276#define XFS_BUF_OFFSET(bp) ((bp)->b_file_offset)
@@ -299,14 +290,13 @@ xfs_buf_set_ref(
299#define XFS_BUF_SET_VTYPE_REF(bp, type, ref) xfs_buf_set_ref(bp, ref) 290#define XFS_BUF_SET_VTYPE_REF(bp, type, ref) xfs_buf_set_ref(bp, ref)
300#define XFS_BUF_SET_VTYPE(bp, type) do { } while (0) 291#define XFS_BUF_SET_VTYPE(bp, type) do { } while (0)
301 292
302#define XFS_BUF_ISPINNED(bp) atomic_read(&((bp)->b_pin_count)) 293static inline int xfs_buf_ispinned(struct xfs_buf *bp)
294{
295 return atomic_read(&bp->b_pin_count);
296}
303 297
304#define XFS_BUF_FINISH_IOWAIT(bp) complete(&bp->b_iowait); 298#define XFS_BUF_FINISH_IOWAIT(bp) complete(&bp->b_iowait);
305 299
306#define XFS_BUF_SET_TARGET(bp, target) ((bp)->b_target = (target))
307#define XFS_BUF_TARGET(bp) ((bp)->b_target)
308#define XFS_BUFTARG_NAME(target) xfs_buf_target_name(target)
309
310static inline void xfs_buf_relse(xfs_buf_t *bp) 300static inline void xfs_buf_relse(xfs_buf_t *bp)
311{ 301{
312 xfs_buf_unlock(bp); 302 xfs_buf_unlock(bp);
diff --git a/fs/xfs/linux-2.6/xfs_sync.c b/fs/xfs/linux-2.6/xfs_sync.c
index e4c938afb910..4604f90f86a3 100644
--- a/fs/xfs/linux-2.6/xfs_sync.c
+++ b/fs/xfs/linux-2.6/xfs_sync.c
@@ -332,7 +332,7 @@ xfs_sync_fsdata(
332 * between there and here. 332 * between there and here.
333 */ 333 */
334 bp = xfs_getsb(mp, 0); 334 bp = xfs_getsb(mp, 0);
335 if (XFS_BUF_ISPINNED(bp)) 335 if (xfs_buf_ispinned(bp))
336 xfs_log_force(mp, 0); 336 xfs_log_force(mp, 0);
337 337
338 return xfs_bwrite(mp, bp); 338 return xfs_bwrite(mp, bp);
diff --git a/fs/xfs/quota/xfs_dquot.c b/fs/xfs/quota/xfs_dquot.c
index 837f31158d43..db62959bed13 100644
--- a/fs/xfs/quota/xfs_dquot.c
+++ b/fs/xfs/quota/xfs_dquot.c
@@ -318,10 +318,9 @@ xfs_qm_init_dquot_blk(
318 int curid, i; 318 int curid, i;
319 319
320 ASSERT(tp); 320 ASSERT(tp);
321 ASSERT(XFS_BUF_ISBUSY(bp));
322 ASSERT(xfs_buf_islocked(bp)); 321 ASSERT(xfs_buf_islocked(bp));
323 322
324 d = (xfs_dqblk_t *)XFS_BUF_PTR(bp); 323 d = bp->b_addr;
325 324
326 /* 325 /*
327 * ID of the first dquot in the block - id's are zero based. 326 * ID of the first dquot in the block - id's are zero based.
@@ -403,7 +402,7 @@ xfs_qm_dqalloc(
403 dqp->q_blkno, 402 dqp->q_blkno,
404 mp->m_quotainfo->qi_dqchunklen, 403 mp->m_quotainfo->qi_dqchunklen,
405 0); 404 0);
406 if (!bp || (error = XFS_BUF_GETERROR(bp))) 405 if (!bp || (error = xfs_buf_geterror(bp)))
407 goto error1; 406 goto error1;
408 /* 407 /*
409 * Make a chunk of dquots out of this buffer and log 408 * Make a chunk of dquots out of this buffer and log
@@ -534,13 +533,12 @@ xfs_qm_dqtobp(
534 return XFS_ERROR(error); 533 return XFS_ERROR(error);
535 } 534 }
536 535
537 ASSERT(XFS_BUF_ISBUSY(bp));
538 ASSERT(xfs_buf_islocked(bp)); 536 ASSERT(xfs_buf_islocked(bp));
539 537
540 /* 538 /*
541 * calculate the location of the dquot inside the buffer. 539 * calculate the location of the dquot inside the buffer.
542 */ 540 */
543 ddq = (struct xfs_disk_dquot *)(XFS_BUF_PTR(bp) + dqp->q_bufoffset); 541 ddq = bp->b_addr + dqp->q_bufoffset;
544 542
545 /* 543 /*
546 * A simple sanity check in case we got a corrupted dquot... 544 * A simple sanity check in case we got a corrupted dquot...
@@ -553,7 +551,6 @@ xfs_qm_dqtobp(
553 xfs_trans_brelse(tp, bp); 551 xfs_trans_brelse(tp, bp);
554 return XFS_ERROR(EIO); 552 return XFS_ERROR(EIO);
555 } 553 }
556 XFS_BUF_BUSY(bp); /* We dirtied this */
557 } 554 }
558 555
559 *O_bpp = bp; 556 *O_bpp = bp;
@@ -622,7 +619,6 @@ xfs_qm_dqread(
622 * this particular dquot was repaired. We still aren't afraid to 619 * this particular dquot was repaired. We still aren't afraid to
623 * brelse it because we have the changes incore. 620 * brelse it because we have the changes incore.
624 */ 621 */
625 ASSERT(XFS_BUF_ISBUSY(bp));
626 ASSERT(xfs_buf_islocked(bp)); 622 ASSERT(xfs_buf_islocked(bp));
627 xfs_trans_brelse(tp, bp); 623 xfs_trans_brelse(tp, bp);
628 624
@@ -1204,7 +1200,7 @@ xfs_qm_dqflush(
1204 /* 1200 /*
1205 * Calculate the location of the dquot inside the buffer. 1201 * Calculate the location of the dquot inside the buffer.
1206 */ 1202 */
1207 ddqp = (struct xfs_disk_dquot *)(XFS_BUF_PTR(bp) + dqp->q_bufoffset); 1203 ddqp = bp->b_addr + dqp->q_bufoffset;
1208 1204
1209 /* 1205 /*
1210 * A simple sanity check in case we got a corrupted dquot.. 1206 * A simple sanity check in case we got a corrupted dquot..
@@ -1240,7 +1236,7 @@ xfs_qm_dqflush(
1240 * If the buffer is pinned then push on the log so we won't 1236 * If the buffer is pinned then push on the log so we won't
1241 * get stuck waiting in the write for too long. 1237 * get stuck waiting in the write for too long.
1242 */ 1238 */
1243 if (XFS_BUF_ISPINNED(bp)) { 1239 if (xfs_buf_ispinned(bp)) {
1244 trace_xfs_dqflush_force(dqp); 1240 trace_xfs_dqflush_force(dqp);
1245 xfs_log_force(mp, 0); 1241 xfs_log_force(mp, 0);
1246 } 1242 }
@@ -1447,7 +1443,7 @@ xfs_qm_dqflock_pushbuf_wait(
1447 goto out_lock; 1443 goto out_lock;
1448 1444
1449 if (XFS_BUF_ISDELAYWRITE(bp)) { 1445 if (XFS_BUF_ISDELAYWRITE(bp)) {
1450 if (XFS_BUF_ISPINNED(bp)) 1446 if (xfs_buf_ispinned(bp))
1451 xfs_log_force(mp, 0); 1447 xfs_log_force(mp, 0);
1452 xfs_buf_delwri_promote(bp); 1448 xfs_buf_delwri_promote(bp);
1453 wake_up_process(bp->b_target->bt_task); 1449 wake_up_process(bp->b_target->bt_task);
diff --git a/fs/xfs/quota/xfs_qm.c b/fs/xfs/quota/xfs_qm.c
index 46e54ad9a2dc..9a0aa76facdf 100644
--- a/fs/xfs/quota/xfs_qm.c
+++ b/fs/xfs/quota/xfs_qm.c
@@ -1240,7 +1240,7 @@ xfs_qm_reset_dqcounts(
1240 do_div(j, sizeof(xfs_dqblk_t)); 1240 do_div(j, sizeof(xfs_dqblk_t));
1241 ASSERT(mp->m_quotainfo->qi_dqperchunk == j); 1241 ASSERT(mp->m_quotainfo->qi_dqperchunk == j);
1242#endif 1242#endif
1243 ddq = (xfs_disk_dquot_t *)XFS_BUF_PTR(bp); 1243 ddq = bp->b_addr;
1244 for (j = 0; j < mp->m_quotainfo->qi_dqperchunk; j++) { 1244 for (j = 0; j < mp->m_quotainfo->qi_dqperchunk; j++) {
1245 /* 1245 /*
1246 * Do a sanity check, and if needed, repair the dqblk. Don't 1246 * Do a sanity check, and if needed, repair the dqblk. Don't
diff --git a/fs/xfs/xfs_ag.h b/fs/xfs/xfs_ag.h
index 6530769a999b..4805f009f923 100644
--- a/fs/xfs/xfs_ag.h
+++ b/fs/xfs/xfs_ag.h
@@ -103,7 +103,7 @@ typedef struct xfs_agf {
103/* disk block (xfs_daddr_t) in the AG */ 103/* disk block (xfs_daddr_t) in the AG */
104#define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log)) 104#define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log))
105#define XFS_AGF_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGF_DADDR(mp)) 105#define XFS_AGF_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGF_DADDR(mp))
106#define XFS_BUF_TO_AGF(bp) ((xfs_agf_t *)XFS_BUF_PTR(bp)) 106#define XFS_BUF_TO_AGF(bp) ((xfs_agf_t *)((bp)->b_addr))
107 107
108extern int xfs_read_agf(struct xfs_mount *mp, struct xfs_trans *tp, 108extern int xfs_read_agf(struct xfs_mount *mp, struct xfs_trans *tp,
109 xfs_agnumber_t agno, int flags, struct xfs_buf **bpp); 109 xfs_agnumber_t agno, int flags, struct xfs_buf **bpp);
@@ -156,7 +156,7 @@ typedef struct xfs_agi {
156/* disk block (xfs_daddr_t) in the AG */ 156/* disk block (xfs_daddr_t) in the AG */
157#define XFS_AGI_DADDR(mp) ((xfs_daddr_t)(2 << (mp)->m_sectbb_log)) 157#define XFS_AGI_DADDR(mp) ((xfs_daddr_t)(2 << (mp)->m_sectbb_log))
158#define XFS_AGI_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGI_DADDR(mp)) 158#define XFS_AGI_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGI_DADDR(mp))
159#define XFS_BUF_TO_AGI(bp) ((xfs_agi_t *)XFS_BUF_PTR(bp)) 159#define XFS_BUF_TO_AGI(bp) ((xfs_agi_t *)((bp)->b_addr))
160 160
161extern int xfs_read_agi(struct xfs_mount *mp, struct xfs_trans *tp, 161extern int xfs_read_agi(struct xfs_mount *mp, struct xfs_trans *tp,
162 xfs_agnumber_t agno, struct xfs_buf **bpp); 162 xfs_agnumber_t agno, struct xfs_buf **bpp);
@@ -168,7 +168,7 @@ extern int xfs_read_agi(struct xfs_mount *mp, struct xfs_trans *tp,
168#define XFS_AGFL_DADDR(mp) ((xfs_daddr_t)(3 << (mp)->m_sectbb_log)) 168#define XFS_AGFL_DADDR(mp) ((xfs_daddr_t)(3 << (mp)->m_sectbb_log))
169#define XFS_AGFL_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGFL_DADDR(mp)) 169#define XFS_AGFL_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGFL_DADDR(mp))
170#define XFS_AGFL_SIZE(mp) ((mp)->m_sb.sb_sectsize / sizeof(xfs_agblock_t)) 170#define XFS_AGFL_SIZE(mp) ((mp)->m_sb.sb_sectsize / sizeof(xfs_agblock_t))
171#define XFS_BUF_TO_AGFL(bp) ((xfs_agfl_t *)XFS_BUF_PTR(bp)) 171#define XFS_BUF_TO_AGFL(bp) ((xfs_agfl_t *)((bp)->b_addr))
172 172
173typedef struct xfs_agfl { 173typedef struct xfs_agfl {
174 __be32 agfl_bno[1]; /* actually XFS_AGFL_SIZE(mp) */ 174 __be32 agfl_bno[1]; /* actually XFS_AGFL_SIZE(mp) */
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c
index 1e00b3ef6274..bdd9cb54d63b 100644
--- a/fs/xfs/xfs_alloc.c
+++ b/fs/xfs/xfs_alloc.c
@@ -451,8 +451,7 @@ xfs_alloc_read_agfl(
451 XFS_FSS_TO_BB(mp, 1), 0, &bp); 451 XFS_FSS_TO_BB(mp, 1), 0, &bp);
452 if (error) 452 if (error)
453 return error; 453 return error;
454 ASSERT(bp); 454 ASSERT(!xfs_buf_geterror(bp));
455 ASSERT(!XFS_BUF_GETERROR(bp));
456 XFS_BUF_SET_VTYPE_REF(bp, B_FS_AGFL, XFS_AGFL_REF); 455 XFS_BUF_SET_VTYPE_REF(bp, B_FS_AGFL, XFS_AGFL_REF);
457 *bpp = bp; 456 *bpp = bp;
458 return 0; 457 return 0;
@@ -2116,7 +2115,7 @@ xfs_read_agf(
2116 if (!*bpp) 2115 if (!*bpp)
2117 return 0; 2116 return 0;
2118 2117
2119 ASSERT(!XFS_BUF_GETERROR(*bpp)); 2118 ASSERT(!(*bpp)->b_error);
2120 agf = XFS_BUF_TO_AGF(*bpp); 2119 agf = XFS_BUF_TO_AGF(*bpp);
2121 2120
2122 /* 2121 /*
@@ -2168,7 +2167,7 @@ xfs_alloc_read_agf(
2168 return error; 2167 return error;
2169 if (!*bpp) 2168 if (!*bpp)
2170 return 0; 2169 return 0;
2171 ASSERT(!XFS_BUF_GETERROR(*bpp)); 2170 ASSERT(!(*bpp)->b_error);
2172 2171
2173 agf = XFS_BUF_TO_AGF(*bpp); 2172 agf = XFS_BUF_TO_AGF(*bpp);
2174 pag = xfs_perag_get(mp, agno); 2173 pag = xfs_perag_get(mp, agno);
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index cbae424fe1ba..160bcdc34a6e 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -2121,8 +2121,7 @@ xfs_attr_rmtval_set(xfs_da_args_t *args)
2121 2121
2122 bp = xfs_buf_get(mp->m_ddev_targp, dblkno, blkcnt, 2122 bp = xfs_buf_get(mp->m_ddev_targp, dblkno, blkcnt,
2123 XBF_LOCK | XBF_DONT_BLOCK); 2123 XBF_LOCK | XBF_DONT_BLOCK);
2124 ASSERT(bp); 2124 ASSERT(!xfs_buf_geterror(bp));
2125 ASSERT(!XFS_BUF_GETERROR(bp));
2126 2125
2127 tmp = (valuelen < XFS_BUF_SIZE(bp)) ? valuelen : 2126 tmp = (valuelen < XFS_BUF_SIZE(bp)) ? valuelen :
2128 XFS_BUF_SIZE(bp); 2127 XFS_BUF_SIZE(bp);
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index ab3e5c6c4642..452a291383ab 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -3383,8 +3383,7 @@ xfs_bmap_local_to_extents(
3383 ASSERT(args.len == 1); 3383 ASSERT(args.len == 1);
3384 *firstblock = args.fsbno; 3384 *firstblock = args.fsbno;
3385 bp = xfs_btree_get_bufl(args.mp, tp, args.fsbno, 0); 3385 bp = xfs_btree_get_bufl(args.mp, tp, args.fsbno, 0);
3386 memcpy((char *)XFS_BUF_PTR(bp), ifp->if_u1.if_data, 3386 memcpy(bp->b_addr, ifp->if_u1.if_data, ifp->if_bytes);
3387 ifp->if_bytes);
3388 xfs_trans_log_buf(tp, bp, 0, ifp->if_bytes - 1); 3387 xfs_trans_log_buf(tp, bp, 0, ifp->if_bytes - 1);
3389 xfs_bmap_forkoff_reset(args.mp, ip, whichfork); 3388 xfs_bmap_forkoff_reset(args.mp, ip, whichfork);
3390 xfs_idata_realloc(ip, -ifp->if_bytes, whichfork); 3389 xfs_idata_realloc(ip, -ifp->if_bytes, whichfork);
diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/xfs_btree.c
index cabf4b5604aa..2b9fd385e27d 100644
--- a/fs/xfs/xfs_btree.c
+++ b/fs/xfs/xfs_btree.c
@@ -275,8 +275,7 @@ xfs_btree_dup_cursor(
275 return error; 275 return error;
276 } 276 }
277 new->bc_bufs[i] = bp; 277 new->bc_bufs[i] = bp;
278 ASSERT(bp); 278 ASSERT(!xfs_buf_geterror(bp));
279 ASSERT(!XFS_BUF_GETERROR(bp));
280 } else 279 } else
281 new->bc_bufs[i] = NULL; 280 new->bc_bufs[i] = NULL;
282 } 281 }
@@ -467,8 +466,7 @@ xfs_btree_get_bufl(
467 ASSERT(fsbno != NULLFSBLOCK); 466 ASSERT(fsbno != NULLFSBLOCK);
468 d = XFS_FSB_TO_DADDR(mp, fsbno); 467 d = XFS_FSB_TO_DADDR(mp, fsbno);
469 bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, lock); 468 bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, lock);
470 ASSERT(bp); 469 ASSERT(!xfs_buf_geterror(bp));
471 ASSERT(!XFS_BUF_GETERROR(bp));
472 return bp; 470 return bp;
473} 471}
474 472
@@ -491,8 +489,7 @@ xfs_btree_get_bufs(
491 ASSERT(agbno != NULLAGBLOCK); 489 ASSERT(agbno != NULLAGBLOCK);
492 d = XFS_AGB_TO_DADDR(mp, agno, agbno); 490 d = XFS_AGB_TO_DADDR(mp, agno, agbno);
493 bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, lock); 491 bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, lock);
494 ASSERT(bp); 492 ASSERT(!xfs_buf_geterror(bp));
495 ASSERT(!XFS_BUF_GETERROR(bp));
496 return bp; 493 return bp;
497} 494}
498 495
@@ -632,7 +629,7 @@ xfs_btree_read_bufl(
632 mp->m_bsize, lock, &bp))) { 629 mp->m_bsize, lock, &bp))) {
633 return error; 630 return error;
634 } 631 }
635 ASSERT(!bp || !XFS_BUF_GETERROR(bp)); 632 ASSERT(!xfs_buf_geterror(bp));
636 if (bp) 633 if (bp)
637 XFS_BUF_SET_VTYPE_REF(bp, B_FS_MAP, refval); 634 XFS_BUF_SET_VTYPE_REF(bp, B_FS_MAP, refval);
638 *bpp = bp; 635 *bpp = bp;
@@ -973,8 +970,7 @@ xfs_btree_get_buf_block(
973 *bpp = xfs_trans_get_buf(cur->bc_tp, mp->m_ddev_targp, d, 970 *bpp = xfs_trans_get_buf(cur->bc_tp, mp->m_ddev_targp, d,
974 mp->m_bsize, flags); 971 mp->m_bsize, flags);
975 972
976 ASSERT(*bpp); 973 ASSERT(!xfs_buf_geterror(*bpp));
977 ASSERT(!XFS_BUF_GETERROR(*bpp));
978 974
979 *block = XFS_BUF_TO_BLOCK(*bpp); 975 *block = XFS_BUF_TO_BLOCK(*bpp);
980 return 0; 976 return 0;
@@ -1006,8 +1002,7 @@ xfs_btree_read_buf_block(
1006 if (error) 1002 if (error)
1007 return error; 1003 return error;
1008 1004
1009 ASSERT(*bpp != NULL); 1005 ASSERT(!xfs_buf_geterror(*bpp));
1010 ASSERT(!XFS_BUF_GETERROR(*bpp));
1011 1006
1012 xfs_btree_set_refs(cur, *bpp); 1007 xfs_btree_set_refs(cur, *bpp);
1013 *block = XFS_BUF_TO_BLOCK(*bpp); 1008 *block = XFS_BUF_TO_BLOCK(*bpp);
diff --git a/fs/xfs/xfs_btree.h b/fs/xfs/xfs_btree.h
index 8d05a6a46ce3..5b240de104c0 100644
--- a/fs/xfs/xfs_btree.h
+++ b/fs/xfs/xfs_btree.h
@@ -262,7 +262,7 @@ typedef struct xfs_btree_cur
262/* 262/*
263 * Convert from buffer to btree block header. 263 * Convert from buffer to btree block header.
264 */ 264 */
265#define XFS_BUF_TO_BLOCK(bp) ((struct xfs_btree_block *)XFS_BUF_PTR(bp)) 265#define XFS_BUF_TO_BLOCK(bp) ((struct xfs_btree_block *)((bp)->b_addr))
266 266
267 267
268/* 268/*
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 88492916c3dc..cac2ecfa6746 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);
@@ -726,7 +725,7 @@ xfs_buf_item_init(
726 * to have logged. 725 * to have logged.
727 */ 726 */
728 bip->bli_orig = (char *)kmem_alloc(XFS_BUF_COUNT(bp), KM_SLEEP); 727 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)); 728 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); 729 bip->bli_logged = (char *)kmem_zalloc(XFS_BUF_COUNT(bp) / NBBY, KM_SLEEP);
731#endif 730#endif
732 731
@@ -895,7 +894,6 @@ xfs_buf_attach_iodone(
895{ 894{
896 xfs_log_item_t *head_lip; 895 xfs_log_item_t *head_lip;
897 896
898 ASSERT(XFS_BUF_ISBUSY(bp));
899 ASSERT(xfs_buf_islocked(bp)); 897 ASSERT(xfs_buf_islocked(bp));
900 898
901 lip->li_cb = cb; 899 lip->li_cb = cb;
@@ -960,7 +958,7 @@ xfs_buf_iodone_callbacks(
960 static ulong lasttime; 958 static ulong lasttime;
961 static xfs_buftarg_t *lasttarg; 959 static xfs_buftarg_t *lasttarg;
962 960
963 if (likely(!XFS_BUF_GETERROR(bp))) 961 if (likely(!xfs_buf_geterror(bp)))
964 goto do_callbacks; 962 goto do_callbacks;
965 963
966 /* 964 /*
@@ -973,14 +971,14 @@ xfs_buf_iodone_callbacks(
973 goto do_callbacks; 971 goto do_callbacks;
974 } 972 }
975 973
976 if (XFS_BUF_TARGET(bp) != lasttarg || 974 if (bp->b_target != lasttarg ||
977 time_after(jiffies, (lasttime + 5*HZ))) { 975 time_after(jiffies, (lasttime + 5*HZ))) {
978 lasttime = jiffies; 976 lasttime = jiffies;
979 xfs_alert(mp, "Device %s: metadata write error block 0x%llx", 977 xfs_alert(mp, "Device %s: metadata write error block 0x%llx",
980 XFS_BUFTARG_NAME(XFS_BUF_TARGET(bp)), 978 xfs_buf_target_name(bp->b_target),
981 (__uint64_t)XFS_BUF_ADDR(bp)); 979 (__uint64_t)XFS_BUF_ADDR(bp));
982 } 980 }
983 lasttarg = XFS_BUF_TARGET(bp); 981 lasttarg = bp->b_target;
984 982
985 /* 983 /*
986 * If the write was asynchronous then no one will be looking for the 984 * If the write was asynchronous then no one will be looking for the
@@ -991,12 +989,11 @@ xfs_buf_iodone_callbacks(
991 * around. 989 * around.
992 */ 990 */
993 if (XFS_BUF_ISASYNC(bp)) { 991 if (XFS_BUF_ISASYNC(bp)) {
994 XFS_BUF_ERROR(bp, 0); /* errno of 0 unsets the flag */ 992 xfs_buf_ioerror(bp, 0); /* errno of 0 unsets the flag */
995 993
996 if (!XFS_BUF_ISSTALE(bp)) { 994 if (!XFS_BUF_ISSTALE(bp)) {
997 XFS_BUF_DELAYWRITE(bp); 995 XFS_BUF_DELAYWRITE(bp);
998 XFS_BUF_DONE(bp); 996 XFS_BUF_DONE(bp);
999 XFS_BUF_SET_START(bp);
1000 } 997 }
1001 ASSERT(bp->b_iodone != NULL); 998 ASSERT(bp->b_iodone != NULL);
1002 trace_xfs_buf_item_iodone_async(bp, _RET_IP_); 999 trace_xfs_buf_item_iodone_async(bp, _RET_IP_);
@@ -1013,7 +1010,6 @@ xfs_buf_iodone_callbacks(
1013 XFS_BUF_UNDELAYWRITE(bp); 1010 XFS_BUF_UNDELAYWRITE(bp);
1014 1011
1015 trace_xfs_buf_error_relse(bp, _RET_IP_); 1012 trace_xfs_buf_error_relse(bp, _RET_IP_);
1016 xfs_force_shutdown(mp, SHUTDOWN_META_IO_ERROR);
1017 1013
1018do_callbacks: 1014do_callbacks:
1019 xfs_buf_do_callbacks(bp); 1015 xfs_buf_do_callbacks(bp);
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
index 5bfcb8779f9f..ee9d5427fcd4 100644
--- a/fs/xfs/xfs_da_btree.c
+++ b/fs/xfs/xfs_da_btree.c
@@ -2050,7 +2050,7 @@ xfs_da_do_buf(
2050 case 0: 2050 case 0:
2051 bp = xfs_trans_get_buf(trans, mp->m_ddev_targp, 2051 bp = xfs_trans_get_buf(trans, mp->m_ddev_targp,
2052 mappedbno, nmapped, 0); 2052 mappedbno, nmapped, 0);
2053 error = bp ? XFS_BUF_GETERROR(bp) : XFS_ERROR(EIO); 2053 error = bp ? bp->b_error : XFS_ERROR(EIO);
2054 break; 2054 break;
2055 case 1: 2055 case 1:
2056 case 2: 2056 case 2:
@@ -2268,7 +2268,7 @@ xfs_da_buf_make(int nbuf, xfs_buf_t **bps)
2268 dabuf->nbuf = 1; 2268 dabuf->nbuf = 1;
2269 bp = bps[0]; 2269 bp = bps[0];
2270 dabuf->bbcount = (short)BTOBB(XFS_BUF_COUNT(bp)); 2270 dabuf->bbcount = (short)BTOBB(XFS_BUF_COUNT(bp));
2271 dabuf->data = XFS_BUF_PTR(bp); 2271 dabuf->data = bp->b_addr;
2272 dabuf->bps[0] = bp; 2272 dabuf->bps[0] = bp;
2273 } else { 2273 } else {
2274 dabuf->nbuf = nbuf; 2274 dabuf->nbuf = nbuf;
@@ -2279,7 +2279,7 @@ xfs_da_buf_make(int nbuf, xfs_buf_t **bps)
2279 dabuf->data = kmem_alloc(BBTOB(dabuf->bbcount), KM_SLEEP); 2279 dabuf->data = kmem_alloc(BBTOB(dabuf->bbcount), KM_SLEEP);
2280 for (i = off = 0; i < nbuf; i++, off += XFS_BUF_COUNT(bp)) { 2280 for (i = off = 0; i < nbuf; i++, off += XFS_BUF_COUNT(bp)) {
2281 bp = bps[i]; 2281 bp = bps[i];
2282 memcpy((char *)dabuf->data + off, XFS_BUF_PTR(bp), 2282 memcpy((char *)dabuf->data + off, bp->b_addr,
2283 XFS_BUF_COUNT(bp)); 2283 XFS_BUF_COUNT(bp));
2284 } 2284 }
2285 } 2285 }
@@ -2302,8 +2302,8 @@ xfs_da_buf_clean(xfs_dabuf_t *dabuf)
2302 for (i = off = 0; i < dabuf->nbuf; 2302 for (i = off = 0; i < dabuf->nbuf;
2303 i++, off += XFS_BUF_COUNT(bp)) { 2303 i++, off += XFS_BUF_COUNT(bp)) {
2304 bp = dabuf->bps[i]; 2304 bp = dabuf->bps[i];
2305 memcpy(XFS_BUF_PTR(bp), (char *)dabuf->data + off, 2305 memcpy(bp->b_addr, dabuf->data + off,
2306 XFS_BUF_COUNT(bp)); 2306 XFS_BUF_COUNT(bp));
2307 } 2307 }
2308 } 2308 }
2309} 2309}
@@ -2340,7 +2340,7 @@ xfs_da_log_buf(xfs_trans_t *tp, xfs_dabuf_t *dabuf, uint first, uint last)
2340 2340
2341 ASSERT(dabuf->nbuf && dabuf->data && dabuf->bbcount && dabuf->bps[0]); 2341 ASSERT(dabuf->nbuf && dabuf->data && dabuf->bbcount && dabuf->bps[0]);
2342 if (dabuf->nbuf == 1) { 2342 if (dabuf->nbuf == 1) {
2343 ASSERT(dabuf->data == (void *)XFS_BUF_PTR(dabuf->bps[0])); 2343 ASSERT(dabuf->data == dabuf->bps[0]->b_addr);
2344 xfs_trans_log_buf(tp, dabuf->bps[0], first, last); 2344 xfs_trans_log_buf(tp, dabuf->bps[0], first, last);
2345 return; 2345 return;
2346 } 2346 }
diff --git a/fs/xfs/xfs_dinode.h b/fs/xfs/xfs_dinode.h
index dffba9ba0db6..a3721633abc8 100644
--- a/fs/xfs/xfs_dinode.h
+++ b/fs/xfs/xfs_dinode.h
@@ -148,7 +148,7 @@ typedef enum xfs_dinode_fmt {
148 be32_to_cpu((dip)->di_nextents) : \ 148 be32_to_cpu((dip)->di_nextents) : \
149 be16_to_cpu((dip)->di_anextents)) 149 be16_to_cpu((dip)->di_anextents))
150 150
151#define XFS_BUF_TO_DINODE(bp) ((xfs_dinode_t *)XFS_BUF_PTR(bp)) 151#define XFS_BUF_TO_DINODE(bp) ((xfs_dinode_t *)((bp)->b_addr))
152 152
153/* 153/*
154 * For block and character special files the 32bit dev_t is stored at the 154 * For block and character special files the 32bit dev_t is stored at the
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
index dd5628bd8d0b..9f24ec28283b 100644
--- a/fs/xfs/xfs_ialloc.c
+++ b/fs/xfs/xfs_ialloc.c
@@ -202,8 +202,7 @@ xfs_ialloc_inode_init(
202 fbuf = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, 202 fbuf = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
203 mp->m_bsize * blks_per_cluster, 203 mp->m_bsize * blks_per_cluster,
204 XBF_LOCK); 204 XBF_LOCK);
205 ASSERT(fbuf); 205 ASSERT(!xfs_buf_geterror(fbuf));
206 ASSERT(!XFS_BUF_GETERROR(fbuf));
207 206
208 /* 207 /*
209 * Initialize all inodes in this buffer and then log them. 208 * Initialize all inodes in this buffer and then log them.
@@ -1486,7 +1485,7 @@ xfs_read_agi(
1486 if (error) 1485 if (error)
1487 return error; 1486 return error;
1488 1487
1489 ASSERT(*bpp && !XFS_BUF_GETERROR(*bpp)); 1488 ASSERT(!xfs_buf_geterror(*bpp));
1490 agi = XFS_BUF_TO_AGI(*bpp); 1489 agi = XFS_BUF_TO_AGI(*bpp);
1491 1490
1492 /* 1491 /*
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 2fcca4b03ed3..0239a7c7c886 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -2473,7 +2473,7 @@ cluster_corrupt_out:
2473 if (bp->b_iodone) { 2473 if (bp->b_iodone) {
2474 XFS_BUF_UNDONE(bp); 2474 XFS_BUF_UNDONE(bp);
2475 XFS_BUF_STALE(bp); 2475 XFS_BUF_STALE(bp);
2476 XFS_BUF_ERROR(bp,EIO); 2476 xfs_buf_ioerror(bp, EIO);
2477 xfs_buf_ioend(bp, 0); 2477 xfs_buf_ioend(bp, 0);
2478 } else { 2478 } else {
2479 XFS_BUF_STALE(bp); 2479 XFS_BUF_STALE(bp);
@@ -2585,7 +2585,7 @@ xfs_iflush(
2585 * If the buffer is pinned then push on the log now so we won't 2585 * If the buffer is pinned then push on the log now so we won't
2586 * get stuck waiting in the write for too long. 2586 * get stuck waiting in the write for too long.
2587 */ 2587 */
2588 if (XFS_BUF_ISPINNED(bp)) 2588 if (xfs_buf_ispinned(bp))
2589 xfs_log_force(mp, 0); 2589 xfs_log_force(mp, 0);
2590 2590
2591 /* 2591 /*
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 06ff8437ed8e..3a8d4f66d702 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -878,7 +878,7 @@ xlog_iodone(xfs_buf_t *bp)
878 /* 878 /*
879 * Race to shutdown the filesystem if we see an error. 879 * Race to shutdown the filesystem if we see an error.
880 */ 880 */
881 if (XFS_TEST_ERROR((XFS_BUF_GETERROR(bp)), l->l_mp, 881 if (XFS_TEST_ERROR((xfs_buf_geterror(bp)), l->l_mp,
882 XFS_ERRTAG_IODONE_IOERR, XFS_RANDOM_IODONE_IOERR)) { 882 XFS_ERRTAG_IODONE_IOERR, XFS_RANDOM_IODONE_IOERR)) {
883 xfs_ioerror_alert("xlog_iodone", l->l_mp, bp, XFS_BUF_ADDR(bp)); 883 xfs_ioerror_alert("xlog_iodone", l->l_mp, bp, XFS_BUF_ADDR(bp));
884 XFS_BUF_STALE(bp); 884 XFS_BUF_STALE(bp);
@@ -1051,7 +1051,6 @@ xlog_alloc_log(xfs_mount_t *mp,
1051 if (!bp) 1051 if (!bp)
1052 goto out_free_log; 1052 goto out_free_log;
1053 bp->b_iodone = xlog_iodone; 1053 bp->b_iodone = xlog_iodone;
1054 ASSERT(XFS_BUF_ISBUSY(bp));
1055 ASSERT(xfs_buf_islocked(bp)); 1054 ASSERT(xfs_buf_islocked(bp));
1056 log->l_xbuf = bp; 1055 log->l_xbuf = bp;
1057 1056
@@ -1108,7 +1107,6 @@ xlog_alloc_log(xfs_mount_t *mp,
1108 iclog->ic_callback_tail = &(iclog->ic_callback); 1107 iclog->ic_callback_tail = &(iclog->ic_callback);
1109 iclog->ic_datap = (char *)iclog->ic_data + log->l_iclog_hsize; 1108 iclog->ic_datap = (char *)iclog->ic_data + log->l_iclog_hsize;
1110 1109
1111 ASSERT(XFS_BUF_ISBUSY(iclog->ic_bp));
1112 ASSERT(xfs_buf_islocked(iclog->ic_bp)); 1110 ASSERT(xfs_buf_islocked(iclog->ic_bp));
1113 init_waitqueue_head(&iclog->ic_force_wait); 1111 init_waitqueue_head(&iclog->ic_force_wait);
1114 init_waitqueue_head(&iclog->ic_write_wait); 1112 init_waitqueue_head(&iclog->ic_write_wait);
@@ -1248,7 +1246,7 @@ xlog_bdstrat(
1248 struct xlog_in_core *iclog = bp->b_fspriv; 1246 struct xlog_in_core *iclog = bp->b_fspriv;
1249 1247
1250 if (iclog->ic_state & XLOG_STATE_IOERROR) { 1248 if (iclog->ic_state & XLOG_STATE_IOERROR) {
1251 XFS_BUF_ERROR(bp, EIO); 1249 xfs_buf_ioerror(bp, EIO);
1252 XFS_BUF_STALE(bp); 1250 XFS_BUF_STALE(bp);
1253 xfs_buf_ioend(bp, 0); 1251 xfs_buf_ioend(bp, 0);
1254 /* 1252 /*
@@ -1355,7 +1353,6 @@ xlog_sync(xlog_t *log,
1355 XFS_BUF_SET_COUNT(bp, count); 1353 XFS_BUF_SET_COUNT(bp, count);
1356 bp->b_fspriv = iclog; 1354 bp->b_fspriv = iclog;
1357 XFS_BUF_ZEROFLAGS(bp); 1355 XFS_BUF_ZEROFLAGS(bp);
1358 XFS_BUF_BUSY(bp);
1359 XFS_BUF_ASYNC(bp); 1356 XFS_BUF_ASYNC(bp);
1360 bp->b_flags |= XBF_SYNCIO; 1357 bp->b_flags |= XBF_SYNCIO;
1361 1358
@@ -1398,16 +1395,15 @@ xlog_sync(xlog_t *log,
1398 if (split) { 1395 if (split) {
1399 bp = iclog->ic_log->l_xbuf; 1396 bp = iclog->ic_log->l_xbuf;
1400 XFS_BUF_SET_ADDR(bp, 0); /* logical 0 */ 1397 XFS_BUF_SET_ADDR(bp, 0); /* logical 0 */
1401 XFS_BUF_SET_PTR(bp, (xfs_caddr_t)((__psint_t)&(iclog->ic_header)+ 1398 xfs_buf_associate_memory(bp,
1402 (__psint_t)count), split); 1399 (char *)&iclog->ic_header + count, split);
1403 bp->b_fspriv = iclog; 1400 bp->b_fspriv = iclog;
1404 XFS_BUF_ZEROFLAGS(bp); 1401 XFS_BUF_ZEROFLAGS(bp);
1405 XFS_BUF_BUSY(bp);
1406 XFS_BUF_ASYNC(bp); 1402 XFS_BUF_ASYNC(bp);
1407 bp->b_flags |= XBF_SYNCIO; 1403 bp->b_flags |= XBF_SYNCIO;
1408 if (log->l_mp->m_flags & XFS_MOUNT_BARRIER) 1404 if (log->l_mp->m_flags & XFS_MOUNT_BARRIER)
1409 bp->b_flags |= XBF_FUA; 1405 bp->b_flags |= XBF_FUA;
1410 dptr = XFS_BUF_PTR(bp); 1406 dptr = bp->b_addr;
1411 /* 1407 /*
1412 * Bump the cycle numbers at the start of each block 1408 * Bump the cycle numbers at the start of each block
1413 * since this part of the buffer is at the start of 1409 * since this part of the buffer is at the start of
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 052a2c0ec5fb..a199dbcee7d8 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -147,7 +147,7 @@ xlog_align(
147 xfs_daddr_t offset = blk_no & ((xfs_daddr_t)log->l_sectBBsize - 1); 147 xfs_daddr_t offset = blk_no & ((xfs_daddr_t)log->l_sectBBsize - 1);
148 148
149 ASSERT(BBTOB(offset + nbblks) <= XFS_BUF_SIZE(bp)); 149 ASSERT(BBTOB(offset + nbblks) <= XFS_BUF_SIZE(bp));
150 return XFS_BUF_PTR(bp) + BBTOB(offset); 150 return bp->b_addr + BBTOB(offset);
151} 151}
152 152
153 153
@@ -178,9 +178,7 @@ xlog_bread_noalign(
178 178
179 XFS_BUF_SET_ADDR(bp, log->l_logBBstart + blk_no); 179 XFS_BUF_SET_ADDR(bp, log->l_logBBstart + blk_no);
180 XFS_BUF_READ(bp); 180 XFS_BUF_READ(bp);
181 XFS_BUF_BUSY(bp);
182 XFS_BUF_SET_COUNT(bp, BBTOB(nbblks)); 181 XFS_BUF_SET_COUNT(bp, BBTOB(nbblks));
183 XFS_BUF_SET_TARGET(bp, log->l_mp->m_logdev_targp);
184 182
185 xfsbdstrat(log->l_mp, bp); 183 xfsbdstrat(log->l_mp, bp);
186 error = xfs_buf_iowait(bp); 184 error = xfs_buf_iowait(bp);
@@ -220,18 +218,18 @@ xlog_bread_offset(
220 xfs_buf_t *bp, 218 xfs_buf_t *bp,
221 xfs_caddr_t offset) 219 xfs_caddr_t offset)
222{ 220{
223 xfs_caddr_t orig_offset = XFS_BUF_PTR(bp); 221 xfs_caddr_t orig_offset = bp->b_addr;
224 int orig_len = bp->b_buffer_length; 222 int orig_len = bp->b_buffer_length;
225 int error, error2; 223 int error, error2;
226 224
227 error = XFS_BUF_SET_PTR(bp, offset, BBTOB(nbblks)); 225 error = xfs_buf_associate_memory(bp, offset, BBTOB(nbblks));
228 if (error) 226 if (error)
229 return error; 227 return error;
230 228
231 error = xlog_bread_noalign(log, blk_no, nbblks, bp); 229 error = xlog_bread_noalign(log, blk_no, nbblks, bp);
232 230
233 /* must reset buffer pointer even on error */ 231 /* must reset buffer pointer even on error */
234 error2 = XFS_BUF_SET_PTR(bp, orig_offset, orig_len); 232 error2 = xfs_buf_associate_memory(bp, orig_offset, orig_len);
235 if (error) 233 if (error)
236 return error; 234 return error;
237 return error2; 235 return error2;
@@ -266,11 +264,9 @@ xlog_bwrite(
266 264
267 XFS_BUF_SET_ADDR(bp, log->l_logBBstart + blk_no); 265 XFS_BUF_SET_ADDR(bp, log->l_logBBstart + blk_no);
268 XFS_BUF_ZEROFLAGS(bp); 266 XFS_BUF_ZEROFLAGS(bp);
269 XFS_BUF_BUSY(bp); 267 xfs_buf_hold(bp);
270 XFS_BUF_HOLD(bp);
271 xfs_buf_lock(bp); 268 xfs_buf_lock(bp);
272 XFS_BUF_SET_COUNT(bp, BBTOB(nbblks)); 269 XFS_BUF_SET_COUNT(bp, BBTOB(nbblks));
273 XFS_BUF_SET_TARGET(bp, log->l_mp->m_logdev_targp);
274 270
275 if ((error = xfs_bwrite(log->l_mp, bp))) 271 if ((error = xfs_bwrite(log->l_mp, bp)))
276 xfs_ioerror_alert("xlog_bwrite", log->l_mp, 272 xfs_ioerror_alert("xlog_bwrite", log->l_mp,
@@ -360,7 +356,7 @@ STATIC void
360xlog_recover_iodone( 356xlog_recover_iodone(
361 struct xfs_buf *bp) 357 struct xfs_buf *bp)
362{ 358{
363 if (XFS_BUF_GETERROR(bp)) { 359 if (bp->b_error) {
364 /* 360 /*
365 * We're not going to bother about retrying 361 * We're not going to bother about retrying
366 * this during recovery. One strike! 362 * this during recovery. One strike!
@@ -1262,7 +1258,7 @@ xlog_write_log_records(
1262 */ 1258 */
1263 ealign = round_down(end_block, sectbb); 1259 ealign = round_down(end_block, sectbb);
1264 if (j == 0 && (start_block + endcount > ealign)) { 1260 if (j == 0 && (start_block + endcount > ealign)) {
1265 offset = XFS_BUF_PTR(bp) + BBTOB(ealign - start_block); 1261 offset = bp->b_addr + BBTOB(ealign - start_block);
1266 error = xlog_bread_offset(log, ealign, sectbb, 1262 error = xlog_bread_offset(log, ealign, sectbb,
1267 bp, offset); 1263 bp, offset);
1268 if (error) 1264 if (error)
@@ -2135,15 +2131,16 @@ xlog_recover_buffer_pass2(
2135 2131
2136 bp = xfs_buf_read(mp->m_ddev_targp, buf_f->blf_blkno, buf_f->blf_len, 2132 bp = xfs_buf_read(mp->m_ddev_targp, buf_f->blf_blkno, buf_f->blf_len,
2137 buf_flags); 2133 buf_flags);
2138 if (XFS_BUF_ISERROR(bp)) { 2134 if (!bp)
2135 return XFS_ERROR(ENOMEM);
2136 error = bp->b_error;
2137 if (error) {
2139 xfs_ioerror_alert("xlog_recover_do..(read#1)", mp, 2138 xfs_ioerror_alert("xlog_recover_do..(read#1)", mp,
2140 bp, buf_f->blf_blkno); 2139 bp, buf_f->blf_blkno);
2141 error = XFS_BUF_GETERROR(bp);
2142 xfs_buf_relse(bp); 2140 xfs_buf_relse(bp);
2143 return error; 2141 return error;
2144 } 2142 }
2145 2143
2146 error = 0;
2147 if (buf_f->blf_flags & XFS_BLF_INODE_BUF) { 2144 if (buf_f->blf_flags & XFS_BLF_INODE_BUF) {
2148 error = xlog_recover_do_inode_buffer(mp, item, bp, buf_f); 2145 error = xlog_recover_do_inode_buffer(mp, item, bp, buf_f);
2149 } else if (buf_f->blf_flags & 2146 } else if (buf_f->blf_flags &
@@ -2227,14 +2224,17 @@ xlog_recover_inode_pass2(
2227 2224
2228 bp = xfs_buf_read(mp->m_ddev_targp, in_f->ilf_blkno, in_f->ilf_len, 2225 bp = xfs_buf_read(mp->m_ddev_targp, in_f->ilf_blkno, in_f->ilf_len,
2229 XBF_LOCK); 2226 XBF_LOCK);
2230 if (XFS_BUF_ISERROR(bp)) { 2227 if (!bp) {
2228 error = ENOMEM;
2229 goto error;
2230 }
2231 error = bp->b_error;
2232 if (error) {
2231 xfs_ioerror_alert("xlog_recover_do..(read#2)", mp, 2233 xfs_ioerror_alert("xlog_recover_do..(read#2)", mp,
2232 bp, in_f->ilf_blkno); 2234 bp, in_f->ilf_blkno);
2233 error = XFS_BUF_GETERROR(bp);
2234 xfs_buf_relse(bp); 2235 xfs_buf_relse(bp);
2235 goto error; 2236 goto error;
2236 } 2237 }
2237 error = 0;
2238 ASSERT(in_f->ilf_fields & XFS_ILOG_CORE); 2238 ASSERT(in_f->ilf_fields & XFS_ILOG_CORE);
2239 dip = (xfs_dinode_t *)xfs_buf_offset(bp, in_f->ilf_boffset); 2239 dip = (xfs_dinode_t *)xfs_buf_offset(bp, in_f->ilf_boffset);
2240 2240
@@ -3437,7 +3437,7 @@ xlog_do_recovery_pass(
3437 /* 3437 /*
3438 * Check for header wrapping around physical end-of-log 3438 * Check for header wrapping around physical end-of-log
3439 */ 3439 */
3440 offset = XFS_BUF_PTR(hbp); 3440 offset = hbp->b_addr;
3441 split_hblks = 0; 3441 split_hblks = 0;
3442 wrapped_hblks = 0; 3442 wrapped_hblks = 0;
3443 if (blk_no + hblks <= log->l_logBBsize) { 3443 if (blk_no + hblks <= log->l_logBBsize) {
@@ -3497,7 +3497,7 @@ xlog_do_recovery_pass(
3497 } else { 3497 } else {
3498 /* This log record is split across the 3498 /* This log record is split across the
3499 * physical end of log */ 3499 * physical end of log */
3500 offset = XFS_BUF_PTR(dbp); 3500 offset = dbp->b_addr;
3501 split_bblks = 0; 3501 split_bblks = 0;
3502 if (blk_no != log->l_logBBsize) { 3502 if (blk_no != log->l_logBBsize) {
3503 /* some data is before the physical 3503 /* some data is before the physical
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 092e16ae4d9d..0081657ad985 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -1615,7 +1615,7 @@ xfs_unmountfs_writesb(xfs_mount_t *mp)
1615 XFS_BUF_UNDELAYWRITE(sbp); 1615 XFS_BUF_UNDELAYWRITE(sbp);
1616 XFS_BUF_WRITE(sbp); 1616 XFS_BUF_WRITE(sbp);
1617 XFS_BUF_UNASYNC(sbp); 1617 XFS_BUF_UNASYNC(sbp);
1618 ASSERT(XFS_BUF_TARGET(sbp) == mp->m_ddev_targp); 1618 ASSERT(sbp->b_target == mp->m_ddev_targp);
1619 xfsbdstrat(mp, sbp); 1619 xfsbdstrat(mp, sbp);
1620 error = xfs_buf_iowait(sbp); 1620 error = xfs_buf_iowait(sbp);
1621 if (error) 1621 if (error)
@@ -1938,7 +1938,7 @@ xfs_getsb(
1938 xfs_buf_lock(bp); 1938 xfs_buf_lock(bp);
1939 } 1939 }
1940 1940
1941 XFS_BUF_HOLD(bp); 1941 xfs_buf_hold(bp);
1942 ASSERT(XFS_BUF_ISDONE(bp)); 1942 ASSERT(XFS_BUF_ISDONE(bp));
1943 return bp; 1943 return bp;
1944} 1944}
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index 8f76fdff4f46..35561a511b57 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -168,7 +168,7 @@ error_cancel:
168 xfs_trans_cancel(tp, cancelflags); 168 xfs_trans_cancel(tp, cancelflags);
169 goto error; 169 goto error;
170 } 170 }
171 memset(XFS_BUF_PTR(bp), 0, mp->m_sb.sb_blocksize); 171 memset(bp->b_addr, 0, mp->m_sb.sb_blocksize);
172 xfs_trans_log_buf(tp, bp, 0, mp->m_sb.sb_blocksize - 1); 172 xfs_trans_log_buf(tp, bp, 0, mp->m_sb.sb_blocksize - 1);
173 /* 173 /*
174 * Commit the transaction. 174 * Commit the transaction.
@@ -883,7 +883,7 @@ xfs_rtbuf_get(
883 if (error) { 883 if (error) {
884 return error; 884 return error;
885 } 885 }
886 ASSERT(bp && !XFS_BUF_GETERROR(bp)); 886 ASSERT(!xfs_buf_geterror(bp));
887 *bpp = bp; 887 *bpp = bp;
888 return 0; 888 return 0;
889} 889}
@@ -943,7 +943,7 @@ xfs_rtcheck_range(
943 if (error) { 943 if (error) {
944 return error; 944 return error;
945 } 945 }
946 bufp = (xfs_rtword_t *)XFS_BUF_PTR(bp); 946 bufp = bp->b_addr;
947 /* 947 /*
948 * Compute the starting word's address, and starting bit. 948 * Compute the starting word's address, and starting bit.
949 */ 949 */
@@ -994,7 +994,7 @@ xfs_rtcheck_range(
994 if (error) { 994 if (error) {
995 return error; 995 return error;
996 } 996 }
997 b = bufp = (xfs_rtword_t *)XFS_BUF_PTR(bp); 997 b = bufp = bp->b_addr;
998 word = 0; 998 word = 0;
999 } else { 999 } else {
1000 /* 1000 /*
@@ -1040,7 +1040,7 @@ xfs_rtcheck_range(
1040 if (error) { 1040 if (error) {
1041 return error; 1041 return error;
1042 } 1042 }
1043 b = bufp = (xfs_rtword_t *)XFS_BUF_PTR(bp); 1043 b = bufp = bp->b_addr;
1044 word = 0; 1044 word = 0;
1045 } else { 1045 } else {
1046 /* 1046 /*
@@ -1158,7 +1158,7 @@ xfs_rtfind_back(
1158 if (error) { 1158 if (error) {
1159 return error; 1159 return error;
1160 } 1160 }
1161 bufp = (xfs_rtword_t *)XFS_BUF_PTR(bp); 1161 bufp = bp->b_addr;
1162 /* 1162 /*
1163 * Get the first word's index & point to it. 1163 * Get the first word's index & point to it.
1164 */ 1164 */
@@ -1210,7 +1210,7 @@ xfs_rtfind_back(
1210 if (error) { 1210 if (error) {
1211 return error; 1211 return error;
1212 } 1212 }
1213 bufp = (xfs_rtword_t *)XFS_BUF_PTR(bp); 1213 bufp = bp->b_addr;
1214 word = XFS_BLOCKWMASK(mp); 1214 word = XFS_BLOCKWMASK(mp);
1215 b = &bufp[word]; 1215 b = &bufp[word];
1216 } else { 1216 } else {
@@ -1256,7 +1256,7 @@ xfs_rtfind_back(
1256 if (error) { 1256 if (error) {
1257 return error; 1257 return error;
1258 } 1258 }
1259 bufp = (xfs_rtword_t *)XFS_BUF_PTR(bp); 1259 bufp = bp->b_addr;
1260 word = XFS_BLOCKWMASK(mp); 1260 word = XFS_BLOCKWMASK(mp);
1261 b = &bufp[word]; 1261 b = &bufp[word];
1262 } else { 1262 } else {
@@ -1333,7 +1333,7 @@ xfs_rtfind_forw(
1333 if (error) { 1333 if (error) {
1334 return error; 1334 return error;
1335 } 1335 }
1336 bufp = (xfs_rtword_t *)XFS_BUF_PTR(bp); 1336 bufp = bp->b_addr;
1337 /* 1337 /*
1338 * Get the first word's index & point to it. 1338 * Get the first word's index & point to it.
1339 */ 1339 */
@@ -1384,7 +1384,7 @@ xfs_rtfind_forw(
1384 if (error) { 1384 if (error) {
1385 return error; 1385 return error;
1386 } 1386 }
1387 b = bufp = (xfs_rtword_t *)XFS_BUF_PTR(bp); 1387 b = bufp = bp->b_addr;
1388 word = 0; 1388 word = 0;
1389 } else { 1389 } else {
1390 /* 1390 /*
@@ -1429,7 +1429,7 @@ xfs_rtfind_forw(
1429 if (error) { 1429 if (error) {
1430 return error; 1430 return error;
1431 } 1431 }
1432 b = bufp = (xfs_rtword_t *)XFS_BUF_PTR(bp); 1432 b = bufp = bp->b_addr;
1433 word = 0; 1433 word = 0;
1434 } else { 1434 } else {
1435 /* 1435 /*
@@ -1649,7 +1649,7 @@ xfs_rtmodify_range(
1649 if (error) { 1649 if (error) {
1650 return error; 1650 return error;
1651 } 1651 }
1652 bufp = (xfs_rtword_t *)XFS_BUF_PTR(bp); 1652 bufp = bp->b_addr;
1653 /* 1653 /*
1654 * Compute the starting word's address, and starting bit. 1654 * Compute the starting word's address, and starting bit.
1655 */ 1655 */
@@ -1694,7 +1694,7 @@ xfs_rtmodify_range(
1694 if (error) { 1694 if (error) {
1695 return error; 1695 return error;
1696 } 1696 }
1697 first = b = bufp = (xfs_rtword_t *)XFS_BUF_PTR(bp); 1697 first = b = bufp = bp->b_addr;
1698 word = 0; 1698 word = 0;
1699 } else { 1699 } else {
1700 /* 1700 /*
@@ -1734,7 +1734,7 @@ xfs_rtmodify_range(
1734 if (error) { 1734 if (error) {
1735 return error; 1735 return error;
1736 } 1736 }
1737 first = b = bufp = (xfs_rtword_t *)XFS_BUF_PTR(bp); 1737 first = b = bufp = bp->b_addr;
1738 word = 0; 1738 word = 0;
1739 } else { 1739 } else {
1740 /* 1740 /*
@@ -1832,8 +1832,8 @@ xfs_rtmodify_summary(
1832 */ 1832 */
1833 sp = XFS_SUMPTR(mp, bp, so); 1833 sp = XFS_SUMPTR(mp, bp, so);
1834 *sp += delta; 1834 *sp += delta;
1835 xfs_trans_log_buf(tp, bp, (uint)((char *)sp - (char *)XFS_BUF_PTR(bp)), 1835 xfs_trans_log_buf(tp, bp, (uint)((char *)sp - (char *)bp->b_addr),
1836 (uint)((char *)sp - (char *)XFS_BUF_PTR(bp) + sizeof(*sp) - 1)); 1836 (uint)((char *)sp - (char *)bp->b_addr + sizeof(*sp) - 1));
1837 return 0; 1837 return 0;
1838} 1838}
1839 1839
diff --git a/fs/xfs/xfs_rtalloc.h b/fs/xfs/xfs_rtalloc.h
index 09e1f4f35e97..f7f3a359c1c5 100644
--- a/fs/xfs/xfs_rtalloc.h
+++ b/fs/xfs/xfs_rtalloc.h
@@ -47,7 +47,7 @@ struct xfs_trans;
47#define XFS_SUMOFFSTOBLOCK(mp,s) \ 47#define XFS_SUMOFFSTOBLOCK(mp,s) \
48 (((s) * (uint)sizeof(xfs_suminfo_t)) >> (mp)->m_sb.sb_blocklog) 48 (((s) * (uint)sizeof(xfs_suminfo_t)) >> (mp)->m_sb.sb_blocklog)
49#define XFS_SUMPTR(mp,bp,so) \ 49#define XFS_SUMPTR(mp,bp,so) \
50 ((xfs_suminfo_t *)((char *)XFS_BUF_PTR(bp) + \ 50 ((xfs_suminfo_t *)((bp)->b_addr + \
51 (((so) * (uint)sizeof(xfs_suminfo_t)) & XFS_BLOCKMASK(mp)))) 51 (((so) * (uint)sizeof(xfs_suminfo_t)) & XFS_BLOCKMASK(mp))))
52 52
53#define XFS_BITTOBLOCK(mp,bi) ((bi) >> (mp)->m_blkbit_log) 53#define XFS_BITTOBLOCK(mp,bi) ((bi) >> (mp)->m_blkbit_log)
diff --git a/fs/xfs/xfs_rw.c b/fs/xfs/xfs_rw.c
index d6d6fdfe9422..c96a8a05ac03 100644
--- a/fs/xfs/xfs_rw.c
+++ b/fs/xfs/xfs_rw.c
@@ -104,9 +104,9 @@ xfs_ioerror_alert(
104 xfs_alert(mp, 104 xfs_alert(mp,
105 "I/O error occurred: meta-data dev %s block 0x%llx" 105 "I/O error occurred: meta-data dev %s block 0x%llx"
106 " (\"%s\") error %d buf count %zd", 106 " (\"%s\") error %d buf count %zd",
107 XFS_BUFTARG_NAME(XFS_BUF_TARGET(bp)), 107 xfs_buf_target_name(bp->b_target),
108 (__uint64_t)blkno, func, 108 (__uint64_t)blkno, func,
109 XFS_BUF_GETERROR(bp), XFS_BUF_COUNT(bp)); 109 bp->b_error, XFS_BUF_COUNT(bp));
110} 110}
111 111
112/* 112/*
@@ -137,8 +137,8 @@ xfs_read_buf(
137 bp = xfs_buf_read(target, blkno, len, flags); 137 bp = xfs_buf_read(target, blkno, len, flags);
138 if (!bp) 138 if (!bp)
139 return XFS_ERROR(EIO); 139 return XFS_ERROR(EIO);
140 error = XFS_BUF_GETERROR(bp); 140 error = bp->b_error;
141 if (bp && !error && !XFS_FORCED_SHUTDOWN(mp)) { 141 if (!error && !XFS_FORCED_SHUTDOWN(mp)) {
142 *bpp = bp; 142 *bpp = bp;
143 } else { 143 } else {
144 *bpp = NULL; 144 *bpp = NULL;
diff --git a/fs/xfs/xfs_sb.h b/fs/xfs/xfs_sb.h
index 1eb2ba586814..cb6ae715814a 100644
--- a/fs/xfs/xfs_sb.h
+++ b/fs/xfs/xfs_sb.h
@@ -509,7 +509,7 @@ static inline int xfs_sb_version_hasprojid32bit(xfs_sb_t *sbp)
509 509
510#define XFS_SB_DADDR ((xfs_daddr_t)0) /* daddr in filesystem/ag */ 510#define XFS_SB_DADDR ((xfs_daddr_t)0) /* daddr in filesystem/ag */
511#define XFS_SB_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_SB_DADDR) 511#define XFS_SB_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_SB_DADDR)
512#define XFS_BUF_TO_SBP(bp) ((xfs_dsb_t *)XFS_BUF_PTR(bp)) 512#define XFS_BUF_TO_SBP(bp) ((xfs_dsb_t *)((bp)->b_addr))
513 513
514#define XFS_HDR_BLOCK(mp,d) ((xfs_agblock_t)XFS_BB_TO_FSBT(mp,d)) 514#define XFS_HDR_BLOCK(mp,d) ((xfs_agblock_t)XFS_BB_TO_FSBT(mp,d))
515#define XFS_DADDR_TO_FSB(mp,d) XFS_AGB_TO_FSB(mp, \ 515#define XFS_DADDR_TO_FSB(mp,d) XFS_AGB_TO_FSB(mp, \
diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c
index 43233e92f0f6..c15aa29fa169 100644
--- a/fs/xfs/xfs_trans_ail.c
+++ b/fs/xfs/xfs_trans_ail.c
@@ -299,7 +299,7 @@ xfs_trans_ail_cursor_last(
299 * Splice the log item list into the AIL at the given LSN. We splice to the 299 * Splice the log item list into the AIL at the given LSN. We splice to the
300 * tail of the given LSN to maintain insert order for push traversals. The 300 * tail of the given LSN to maintain insert order for push traversals. The
301 * cursor is optional, allowing repeated updates to the same LSN to avoid 301 * cursor is optional, allowing repeated updates to the same LSN to avoid
302 * repeated traversals. 302 * repeated traversals. This should not be called with an empty list.
303 */ 303 */
304static void 304static void
305xfs_ail_splice( 305xfs_ail_splice(
@@ -308,50 +308,39 @@ xfs_ail_splice(
308 struct list_head *list, 308 struct list_head *list,
309 xfs_lsn_t lsn) 309 xfs_lsn_t lsn)
310{ 310{
311 struct xfs_log_item *lip = cur ? cur->item : NULL; 311 struct xfs_log_item *lip;
312 struct xfs_log_item *next_lip; 312
313 ASSERT(!list_empty(list));
313 314
314 /* 315 /*
315 * Get a new cursor if we don't have a placeholder or the existing one 316 * Use the cursor to determine the insertion point if one is
316 * has been invalidated. 317 * provided. If not, or if the one we got is not valid,
318 * find the place in the AIL where the items belong.
317 */ 319 */
318 if (!lip || (__psint_t)lip & 1) { 320 lip = cur ? cur->item : NULL;
321 if (!lip || (__psint_t) lip & 1)
319 lip = __xfs_trans_ail_cursor_last(ailp, lsn); 322 lip = __xfs_trans_ail_cursor_last(ailp, lsn);
320 323
321 if (!lip) { 324 /*
322 /* The list is empty, so just splice and return. */ 325 * If a cursor is provided, we know we're processing the AIL
323 if (cur) 326 * in lsn order, and future items to be spliced in will
324 cur->item = NULL; 327 * follow the last one being inserted now. Update the
325 list_splice(list, &ailp->xa_ail); 328 * cursor to point to that last item, now while we have a
326 return; 329 * reliable pointer to it.
327 } 330 */
328 } 331 if (cur)
332 cur->item = list_entry(list->prev, struct xfs_log_item, li_ail);
329 333
330 /* 334 /*
331 * Our cursor points to the item we want to insert _after_, so we have 335 * Finally perform the splice. Unless the AIL was empty,
332 * to update the cursor to point to the end of the list we are splicing 336 * lip points to the item in the AIL _after_ which the new
333 * in so that it points to the correct location for the next splice. 337 * items should go. If lip is null the AIL was empty, so
334 * i.e. before the splice 338 * the new items go at the head of the AIL.
335 *
336 * lsn -> lsn -> lsn + x -> lsn + x ...
337 * ^
338 * | cursor points here
339 *
340 * After the splice we have:
341 *
342 * lsn -> lsn -> lsn -> lsn -> .... -> lsn -> lsn + x -> lsn + x ...
343 * ^ ^
344 * | cursor points here | needs to move here
345 *
346 * So we set the cursor to the last item in the list to be spliced
347 * before we execute the splice, resulting in the cursor pointing to
348 * the correct item after the splice occurs.
349 */ 339 */
350 if (cur) { 340 if (lip)
351 next_lip = list_entry(list->prev, struct xfs_log_item, li_ail); 341 list_splice(list, &lip->li_ail);
352 cur->item = next_lip; 342 else
353 } 343 list_splice(list, &ailp->xa_ail);
354 list_splice(list, &lip->li_ail);
355} 344}
356 345
357/* 346/*
@@ -682,6 +671,7 @@ xfs_trans_ail_update_bulk(
682 int i; 671 int i;
683 LIST_HEAD(tmp); 672 LIST_HEAD(tmp);
684 673
674 ASSERT(nr_items > 0); /* Not required, but true. */
685 mlip = xfs_ail_min(ailp); 675 mlip = xfs_ail_min(ailp);
686 676
687 for (i = 0; i < nr_items; i++) { 677 for (i = 0; i < nr_items; i++) {
@@ -701,7 +691,8 @@ xfs_trans_ail_update_bulk(
701 list_add(&lip->li_ail, &tmp); 691 list_add(&lip->li_ail, &tmp);
702 } 692 }
703 693
704 xfs_ail_splice(ailp, cur, &tmp, lsn); 694 if (!list_empty(&tmp))
695 xfs_ail_splice(ailp, cur, &tmp, lsn);
705 696
706 if (!mlip_changed) { 697 if (!mlip_changed) {
707 spin_unlock(&ailp->xa_lock); 698 spin_unlock(&ailp->xa_lock);
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c
index 15584fc3ed7d..137e2b9e2948 100644
--- a/fs/xfs/xfs_trans_buf.c
+++ b/fs/xfs/xfs_trans_buf.c
@@ -54,7 +54,7 @@ xfs_trans_buf_item_match(
54 list_for_each_entry(lidp, &tp->t_items, lid_trans) { 54 list_for_each_entry(lidp, &tp->t_items, lid_trans) {
55 blip = (struct xfs_buf_log_item *)lidp->lid_item; 55 blip = (struct xfs_buf_log_item *)lidp->lid_item;
56 if (blip->bli_item.li_type == XFS_LI_BUF && 56 if (blip->bli_item.li_type == XFS_LI_BUF &&
57 XFS_BUF_TARGET(blip->bli_buf) == target && 57 blip->bli_buf->b_target == target &&
58 XFS_BUF_ADDR(blip->bli_buf) == blkno && 58 XFS_BUF_ADDR(blip->bli_buf) == blkno &&
59 XFS_BUF_COUNT(blip->bli_buf) == len) 59 XFS_BUF_COUNT(blip->bli_buf) == len)
60 return blip->bli_buf; 60 return blip->bli_buf;
@@ -80,7 +80,6 @@ _xfs_trans_bjoin(
80{ 80{
81 struct xfs_buf_log_item *bip; 81 struct xfs_buf_log_item *bip;
82 82
83 ASSERT(XFS_BUF_ISBUSY(bp));
84 ASSERT(bp->b_transp == NULL); 83 ASSERT(bp->b_transp == NULL);
85 84
86 /* 85 /*
@@ -194,7 +193,7 @@ xfs_trans_get_buf(xfs_trans_t *tp,
194 return NULL; 193 return NULL;
195 } 194 }
196 195
197 ASSERT(!XFS_BUF_GETERROR(bp)); 196 ASSERT(!bp->b_error);
198 197
199 _xfs_trans_bjoin(tp, bp, 1); 198 _xfs_trans_bjoin(tp, bp, 1);
200 trace_xfs_trans_get_buf(bp->b_fspriv); 199 trace_xfs_trans_get_buf(bp->b_fspriv);
@@ -293,10 +292,10 @@ xfs_trans_read_buf(
293 return (flags & XBF_TRYLOCK) ? 292 return (flags & XBF_TRYLOCK) ?
294 EAGAIN : XFS_ERROR(ENOMEM); 293 EAGAIN : XFS_ERROR(ENOMEM);
295 294
296 if (XFS_BUF_GETERROR(bp) != 0) { 295 if (bp->b_error) {
296 error = bp->b_error;
297 xfs_ioerror_alert("xfs_trans_read_buf", mp, 297 xfs_ioerror_alert("xfs_trans_read_buf", mp,
298 bp, blkno); 298 bp, blkno);
299 error = XFS_BUF_GETERROR(bp);
300 xfs_buf_relse(bp); 299 xfs_buf_relse(bp);
301 return error; 300 return error;
302 } 301 }
@@ -330,7 +329,7 @@ xfs_trans_read_buf(
330 ASSERT(xfs_buf_islocked(bp)); 329 ASSERT(xfs_buf_islocked(bp));
331 ASSERT(bp->b_transp == tp); 330 ASSERT(bp->b_transp == tp);
332 ASSERT(bp->b_fspriv != NULL); 331 ASSERT(bp->b_fspriv != NULL);
333 ASSERT((XFS_BUF_ISERROR(bp)) == 0); 332 ASSERT(!bp->b_error);
334 if (!(XFS_BUF_ISDONE(bp))) { 333 if (!(XFS_BUF_ISDONE(bp))) {
335 trace_xfs_trans_read_buf_io(bp, _RET_IP_); 334 trace_xfs_trans_read_buf_io(bp, _RET_IP_);
336 ASSERT(!XFS_BUF_ISASYNC(bp)); 335 ASSERT(!XFS_BUF_ISASYNC(bp));
@@ -386,10 +385,9 @@ xfs_trans_read_buf(
386 return (flags & XBF_TRYLOCK) ? 385 return (flags & XBF_TRYLOCK) ?
387 0 : XFS_ERROR(ENOMEM); 386 0 : XFS_ERROR(ENOMEM);
388 } 387 }
389 if (XFS_BUF_GETERROR(bp) != 0) { 388 if (bp->b_error) {
390 XFS_BUF_SUPER_STALE(bp); 389 error = bp->b_error;
391 error = XFS_BUF_GETERROR(bp); 390 XFS_BUF_SUPER_STALE(bp);
392
393 xfs_ioerror_alert("xfs_trans_read_buf", mp, 391 xfs_ioerror_alert("xfs_trans_read_buf", mp,
394 bp, blkno); 392 bp, blkno);
395 if (tp->t_flags & XFS_TRANS_DIRTY) 393 if (tp->t_flags & XFS_TRANS_DIRTY)
@@ -430,7 +428,7 @@ shutdown_abort:
430 if (XFS_BUF_ISSTALE(bp) && XFS_BUF_ISDELAYWRITE(bp)) 428 if (XFS_BUF_ISSTALE(bp) && XFS_BUF_ISDELAYWRITE(bp))
431 xfs_notice(mp, "about to pop assert, bp == 0x%p", bp); 429 xfs_notice(mp, "about to pop assert, bp == 0x%p", bp);
432#endif 430#endif
433 ASSERT((XFS_BUF_BFLAGS(bp) & (XBF_STALE|XBF_DELWRI)) != 431 ASSERT((bp->b_flags & (XBF_STALE|XBF_DELWRI)) !=
434 (XBF_STALE|XBF_DELWRI)); 432 (XBF_STALE|XBF_DELWRI));
435 433
436 trace_xfs_trans_read_buf_shut(bp, _RET_IP_); 434 trace_xfs_trans_read_buf_shut(bp, _RET_IP_);
@@ -581,7 +579,6 @@ xfs_trans_bhold(xfs_trans_t *tp,
581{ 579{
582 xfs_buf_log_item_t *bip = bp->b_fspriv; 580 xfs_buf_log_item_t *bip = bp->b_fspriv;
583 581
584 ASSERT(XFS_BUF_ISBUSY(bp));
585 ASSERT(bp->b_transp == tp); 582 ASSERT(bp->b_transp == tp);
586 ASSERT(bip != NULL); 583 ASSERT(bip != NULL);
587 ASSERT(!(bip->bli_flags & XFS_BLI_STALE)); 584 ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
@@ -602,7 +599,6 @@ xfs_trans_bhold_release(xfs_trans_t *tp,
602{ 599{
603 xfs_buf_log_item_t *bip = bp->b_fspriv; 600 xfs_buf_log_item_t *bip = bp->b_fspriv;
604 601
605 ASSERT(XFS_BUF_ISBUSY(bp));
606 ASSERT(bp->b_transp == tp); 602 ASSERT(bp->b_transp == tp);
607 ASSERT(bip != NULL); 603 ASSERT(bip != NULL);
608 ASSERT(!(bip->bli_flags & XFS_BLI_STALE)); 604 ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
@@ -631,7 +627,6 @@ xfs_trans_log_buf(xfs_trans_t *tp,
631{ 627{
632 xfs_buf_log_item_t *bip = bp->b_fspriv; 628 xfs_buf_log_item_t *bip = bp->b_fspriv;
633 629
634 ASSERT(XFS_BUF_ISBUSY(bp));
635 ASSERT(bp->b_transp == tp); 630 ASSERT(bp->b_transp == tp);
636 ASSERT(bip != NULL); 631 ASSERT(bip != NULL);
637 ASSERT((first <= last) && (last < XFS_BUF_COUNT(bp))); 632 ASSERT((first <= last) && (last < XFS_BUF_COUNT(bp)));
@@ -702,7 +697,6 @@ xfs_trans_binval(
702{ 697{
703 xfs_buf_log_item_t *bip = bp->b_fspriv; 698 xfs_buf_log_item_t *bip = bp->b_fspriv;
704 699
705 ASSERT(XFS_BUF_ISBUSY(bp));
706 ASSERT(bp->b_transp == tp); 700 ASSERT(bp->b_transp == tp);
707 ASSERT(bip != NULL); 701 ASSERT(bip != NULL);
708 ASSERT(atomic_read(&bip->bli_refcount) > 0); 702 ASSERT(atomic_read(&bip->bli_refcount) > 0);
@@ -774,7 +768,6 @@ xfs_trans_inode_buf(
774{ 768{
775 xfs_buf_log_item_t *bip = bp->b_fspriv; 769 xfs_buf_log_item_t *bip = bp->b_fspriv;
776 770
777 ASSERT(XFS_BUF_ISBUSY(bp));
778 ASSERT(bp->b_transp == tp); 771 ASSERT(bp->b_transp == tp);
779 ASSERT(bip != NULL); 772 ASSERT(bip != NULL);
780 ASSERT(atomic_read(&bip->bli_refcount) > 0); 773 ASSERT(atomic_read(&bip->bli_refcount) > 0);
@@ -798,7 +791,6 @@ xfs_trans_stale_inode_buf(
798{ 791{
799 xfs_buf_log_item_t *bip = bp->b_fspriv; 792 xfs_buf_log_item_t *bip = bp->b_fspriv;
800 793
801 ASSERT(XFS_BUF_ISBUSY(bp));
802 ASSERT(bp->b_transp == tp); 794 ASSERT(bp->b_transp == tp);
803 ASSERT(bip != NULL); 795 ASSERT(bip != NULL);
804 ASSERT(atomic_read(&bip->bli_refcount) > 0); 796 ASSERT(atomic_read(&bip->bli_refcount) > 0);
@@ -823,7 +815,6 @@ xfs_trans_inode_alloc_buf(
823{ 815{
824 xfs_buf_log_item_t *bip = bp->b_fspriv; 816 xfs_buf_log_item_t *bip = bp->b_fspriv;
825 817
826 ASSERT(XFS_BUF_ISBUSY(bp));
827 ASSERT(bp->b_transp == tp); 818 ASSERT(bp->b_transp == tp);
828 ASSERT(bip != NULL); 819 ASSERT(bip != NULL);
829 ASSERT(atomic_read(&bip->bli_refcount) > 0); 820 ASSERT(atomic_read(&bip->bli_refcount) > 0);
@@ -851,7 +842,6 @@ xfs_trans_dquot_buf(
851{ 842{
852 xfs_buf_log_item_t *bip = bp->b_fspriv; 843 xfs_buf_log_item_t *bip = bp->b_fspriv;
853 844
854 ASSERT(XFS_BUF_ISBUSY(bp));
855 ASSERT(bp->b_transp == tp); 845 ASSERT(bp->b_transp == tp);
856 ASSERT(bip != NULL); 846 ASSERT(bip != NULL);
857 ASSERT(type == XFS_BLF_UDQUOT_BUF || 847 ASSERT(type == XFS_BLF_UDQUOT_BUF ||
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index 9322e13f0c63..51fc429527bc 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -83,7 +83,9 @@ xfs_readlink_bmap(
83 83
84 bp = xfs_buf_read(mp->m_ddev_targp, d, BTOBB(byte_cnt), 84 bp = xfs_buf_read(mp->m_ddev_targp, d, BTOBB(byte_cnt),
85 XBF_LOCK | XBF_MAPPED | XBF_DONT_BLOCK); 85 XBF_LOCK | XBF_MAPPED | XBF_DONT_BLOCK);
86 error = XFS_BUF_GETERROR(bp); 86 if (!bp)
87 return XFS_ERROR(ENOMEM);
88 error = bp->b_error;
87 if (error) { 89 if (error) {
88 xfs_ioerror_alert("xfs_readlink", 90 xfs_ioerror_alert("xfs_readlink",
89 ip->i_mount, bp, XFS_BUF_ADDR(bp)); 91 ip->i_mount, bp, XFS_BUF_ADDR(bp));
@@ -94,7 +96,7 @@ xfs_readlink_bmap(
94 byte_cnt = pathlen; 96 byte_cnt = pathlen;
95 pathlen -= byte_cnt; 97 pathlen -= byte_cnt;
96 98
97 memcpy(link, XFS_BUF_PTR(bp), byte_cnt); 99 memcpy(link, bp->b_addr, byte_cnt);
98 xfs_buf_relse(bp); 100 xfs_buf_relse(bp);
99 } 101 }
100 102
@@ -1648,13 +1650,13 @@ xfs_symlink(
1648 byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount); 1650 byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount);
1649 bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, 1651 bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
1650 BTOBB(byte_cnt), 0); 1652 BTOBB(byte_cnt), 0);
1651 ASSERT(bp && !XFS_BUF_GETERROR(bp)); 1653 ASSERT(!xfs_buf_geterror(bp));
1652 if (pathlen < byte_cnt) { 1654 if (pathlen < byte_cnt) {
1653 byte_cnt = pathlen; 1655 byte_cnt = pathlen;
1654 } 1656 }
1655 pathlen -= byte_cnt; 1657 pathlen -= byte_cnt;
1656 1658
1657 memcpy(XFS_BUF_PTR(bp), cur_chunk, byte_cnt); 1659 memcpy(bp->b_addr, cur_chunk, byte_cnt);
1658 cur_chunk += byte_cnt; 1660 cur_chunk += byte_cnt;
1659 1661
1660 xfs_trans_log_buf(tp, bp, 0, byte_cnt - 1); 1662 xfs_trans_log_buf(tp, bp, 0, byte_cnt - 1);
@@ -1999,7 +2001,7 @@ xfs_zero_remaining_bytes(
1999 mp, bp, XFS_BUF_ADDR(bp)); 2001 mp, bp, XFS_BUF_ADDR(bp));
2000 break; 2002 break;
2001 } 2003 }
2002 memset(XFS_BUF_PTR(bp) + 2004 memset(bp->b_addr +
2003 (offset - XFS_FSB_TO_B(mp, imap.br_startoff)), 2005 (offset - XFS_FSB_TO_B(mp, imap.br_startoff)),
2004 0, lastoffset - offset + 1); 2006 0, lastoffset - offset + 1);
2005 XFS_BUF_UNDONE(bp); 2007 XFS_BUF_UNDONE(bp);