aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Chinner <david@fromorbit.com>2012-04-23 01:58:52 -0400
committerBen Myers <bpm@sgi.com>2012-05-14 17:20:48 -0400
commitaa0e8833b05cbd9d34d6a1ddaf23a74a58d76a03 (patch)
tree72592f1fec3df30dea526f793416b56b8d133234
parent4e94b71b7068b4bd9c615301197e09dbf0c3b770 (diff)
xfs: use blocks for storing the desired IO size
Now that we pass block counts everywhere, and index buffers by block number and length in units of blocks, convert the desired IO size into block counts rather than bytes. Convert the code to use block counts, and those that need byte counts get converted at the time of use. Rename the b_desired_count variable to something closer to it's purpose - b_io_length - as it is only used to specify the length of an IO for a subset of the buffer. The only time this is used is for log IO - both writing iclogs and during log recovery. In all other cases, the b_io_length matches b_length, and hence a lot of code confuses the two. e.g. the buf item code uses the io count exclusively when it should be using the buffer length. Fix these apprpriately as they are found. Also, remove the XFS_BUF_{SET_}COUNT() macros that are just wrappers around the desired IO length. They only serve to make the code shouty loud, don't actually add any real value, and are often used incorrectly. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Mark Tinguely <tinguely@sgi.com> Signed-off-by: Ben Myers <bpm@sgi.com>
-rw-r--r--fs/xfs/xfs_buf.c26
-rw-r--r--fs/xfs/xfs_buf.h4
-rw-r--r--fs/xfs/xfs_buf_item.c15
-rw-r--r--fs/xfs/xfs_da_btree.c16
-rw-r--r--fs/xfs/xfs_log.c2
-rw-r--r--fs/xfs/xfs_log_recover.c15
-rw-r--r--fs/xfs/xfs_trans_buf.c4
7 files changed, 41 insertions, 41 deletions
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 382c49a42ac2..ab3c4491777b 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -198,12 +198,12 @@ xfs_buf_alloc(
198 bp->b_target = target; 198 bp->b_target = target;
199 199
200 /* 200 /*
201 * Set length and count_desired to the same value initially. 201 * Set length and io_length to the same value initially.
202 * I/O routines should use count_desired, which will be the same in 202 * I/O routines should use io_length, which will be the same in
203 * most cases but may be reset (e.g. XFS recovery). 203 * most cases but may be reset (e.g. XFS recovery).
204 */ 204 */
205 bp->b_length = numblks; 205 bp->b_length = numblks;
206 bp->b_count_desired = numblks << BBSHIFT; 206 bp->b_io_length = numblks;
207 bp->b_flags = flags; 207 bp->b_flags = flags;
208 208
209 /* 209 /*
@@ -302,7 +302,7 @@ xfs_buf_allocate_memory(
302 xfs_buf_t *bp, 302 xfs_buf_t *bp,
303 uint flags) 303 uint flags)
304{ 304{
305 size_t size = bp->b_count_desired; 305 size_t size;
306 size_t nbytes, offset; 306 size_t nbytes, offset;
307 gfp_t gfp_mask = xb_to_gfp(flags); 307 gfp_t gfp_mask = xb_to_gfp(flags);
308 unsigned short page_count, i; 308 unsigned short page_count, i;
@@ -345,6 +345,7 @@ use_alloc_page:
345 return error; 345 return error;
346 346
347 offset = bp->b_offset; 347 offset = bp->b_offset;
348 size = BBTOB(bp->b_length);
348 bp->b_flags |= _XBF_PAGES; 349 bp->b_flags |= _XBF_PAGES;
349 350
350 for (i = 0; i < bp->b_page_count; i++) { 351 for (i = 0; i < bp->b_page_count; i++) {
@@ -575,7 +576,7 @@ xfs_buf_get(
575 * that we can do IO on it. 576 * that we can do IO on it.
576 */ 577 */
577 bp->b_bn = blkno; 578 bp->b_bn = blkno;
578 bp->b_count_desired = BBTOB(bp->b_length); 579 bp->b_io_length = bp->b_length;
579 580
580found: 581found:
581 if (!(bp->b_flags & XBF_MAPPED)) { 582 if (!(bp->b_flags & XBF_MAPPED)) {
@@ -718,7 +719,7 @@ xfs_buf_set_empty(
718 bp->b_page_count = 0; 719 bp->b_page_count = 0;
719 bp->b_addr = NULL; 720 bp->b_addr = NULL;
720 bp->b_length = numblks; 721 bp->b_length = numblks;
721 bp->b_count_desired = numblks << BBSHIFT; 722 bp->b_io_length = numblks;
722 bp->b_bn = XFS_BUF_DADDR_NULL; 723 bp->b_bn = XFS_BUF_DADDR_NULL;
723 bp->b_flags &= ~XBF_MAPPED; 724 bp->b_flags &= ~XBF_MAPPED;
724} 725}
@@ -770,7 +771,7 @@ xfs_buf_associate_memory(
770 pageaddr += PAGE_SIZE; 771 pageaddr += PAGE_SIZE;
771 } 772 }
772 773
773 bp->b_count_desired = len; 774 bp->b_io_length = BTOBB(len);
774 bp->b_length = BTOBB(buflen); 775 bp->b_length = BTOBB(buflen);
775 bp->b_flags |= XBF_MAPPED; 776 bp->b_flags |= XBF_MAPPED;
776 777
@@ -1012,9 +1013,8 @@ xfs_buf_ioerror_alert(
1012 const char *func) 1013 const char *func)
1013{ 1014{
1014 xfs_alert(bp->b_target->bt_mount, 1015 xfs_alert(bp->b_target->bt_mount,
1015"metadata I/O error: block 0x%llx (\"%s\") error %d buf count %zd", 1016"metadata I/O error: block 0x%llx (\"%s\") error %d numblks %d",
1016 (__uint64_t)XFS_BUF_ADDR(bp), func, 1017 (__uint64_t)XFS_BUF_ADDR(bp), func, bp->b_error, bp->b_length);
1017 bp->b_error, XFS_BUF_COUNT(bp));
1018} 1018}
1019 1019
1020int 1020int
@@ -1186,7 +1186,7 @@ _xfs_buf_ioapply(
1186 int rw, map_i, total_nr_pages, nr_pages; 1186 int rw, map_i, total_nr_pages, nr_pages;
1187 struct bio *bio; 1187 struct bio *bio;
1188 int offset = bp->b_offset; 1188 int offset = bp->b_offset;
1189 int size = bp->b_count_desired; 1189 int size = BBTOB(bp->b_io_length);
1190 sector_t sector = bp->b_bn; 1190 sector_t sector = bp->b_bn;
1191 1191
1192 total_nr_pages = bp->b_page_count; 1192 total_nr_pages = bp->b_page_count;
@@ -1234,7 +1234,7 @@ next_chunk:
1234 break; 1234 break;
1235 1235
1236 offset = 0; 1236 offset = 0;
1237 sector += nbytes >> BBSHIFT; 1237 sector += BTOBB(nbytes);
1238 size -= nbytes; 1238 size -= nbytes;
1239 total_nr_pages--; 1239 total_nr_pages--;
1240 } 1240 }
@@ -1328,7 +1328,7 @@ xfs_buf_iomove(
1328 page = bp->b_pages[xfs_buf_btoct(boff + bp->b_offset)]; 1328 page = bp->b_pages[xfs_buf_btoct(boff + bp->b_offset)];
1329 cpoff = xfs_buf_poff(boff + bp->b_offset); 1329 cpoff = xfs_buf_poff(boff + bp->b_offset);
1330 csize = min_t(size_t, 1330 csize = min_t(size_t,
1331 PAGE_SIZE-cpoff, bp->b_count_desired-boff); 1331 PAGE_SIZE - cpoff, BBTOB(bp->b_io_length) - boff);
1332 1332
1333 ASSERT(((csize + cpoff) <= PAGE_SIZE)); 1333 ASSERT(((csize + cpoff) <= PAGE_SIZE));
1334 1334
diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
index 3dab208686a4..9787645fa54c 100644
--- a/fs/xfs/xfs_buf.h
+++ b/fs/xfs/xfs_buf.h
@@ -128,7 +128,6 @@ typedef struct xfs_buf {
128 struct list_head b_list; 128 struct list_head b_list;
129 struct xfs_perag *b_pag; /* contains rbtree root */ 129 struct xfs_perag *b_pag; /* contains rbtree root */
130 xfs_buftarg_t *b_target; /* buffer target (device) */ 130 xfs_buftarg_t *b_target; /* buffer target (device) */
131 size_t b_count_desired;/* desired transfer size */
132 void *b_addr; /* virtual address of buffer */ 131 void *b_addr; /* virtual address of buffer */
133 struct work_struct b_iodone_work; 132 struct work_struct b_iodone_work;
134 xfs_buf_iodone_t b_iodone; /* I/O completion function */ 133 xfs_buf_iodone_t b_iodone; /* I/O completion function */
@@ -137,6 +136,7 @@ typedef struct xfs_buf {
137 struct xfs_trans *b_transp; 136 struct xfs_trans *b_transp;
138 struct page **b_pages; /* array of page pointers */ 137 struct page **b_pages; /* array of page pointers */
139 struct page *b_page_array[XB_PAGES]; /* inline pages */ 138 struct page *b_page_array[XB_PAGES]; /* inline pages */
139 int b_io_length; /* IO size in BBs */
140 atomic_t b_pin_count; /* pin count */ 140 atomic_t b_pin_count; /* pin count */
141 atomic_t b_io_remaining; /* #outstanding I/O requests */ 141 atomic_t b_io_remaining; /* #outstanding I/O requests */
142 unsigned int b_page_count; /* size of page array */ 142 unsigned int b_page_count; /* size of page array */
@@ -244,8 +244,6 @@ void xfs_buf_stale(struct xfs_buf *bp);
244 244
245#define XFS_BUF_ADDR(bp) ((bp)->b_bn) 245#define XFS_BUF_ADDR(bp) ((bp)->b_bn)
246#define XFS_BUF_SET_ADDR(bp, bno) ((bp)->b_bn = (xfs_daddr_t)(bno)) 246#define XFS_BUF_SET_ADDR(bp, bno) ((bp)->b_bn = (xfs_daddr_t)(bno))
247#define XFS_BUF_COUNT(bp) ((bp)->b_count_desired)
248#define XFS_BUF_SET_COUNT(bp, cnt) ((bp)->b_count_desired = (cnt))
249 247
250static inline void xfs_buf_set_ref(struct xfs_buf *bp, int lru_ref) 248static inline void xfs_buf_set_ref(struct xfs_buf *bp, int lru_ref)
251{ 249{
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 7f0abeaf919c..a25206c84cf9 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -123,11 +123,11 @@ xfs_buf_item_log_check(
123 ASSERT(bip->bli_logged != NULL); 123 ASSERT(bip->bli_logged != NULL);
124 124
125 bp = bip->bli_buf; 125 bp = bip->bli_buf;
126 ASSERT(XFS_BUF_COUNT(bp) > 0); 126 ASSERT(bp->b_length > 0);
127 ASSERT(bp->b_addr != NULL); 127 ASSERT(bp->b_addr != NULL);
128 orig = bip->bli_orig; 128 orig = bip->bli_orig;
129 buffer = bp->b_addr; 129 buffer = bp->b_addr;
130 for (x = 0; x < XFS_BUF_COUNT(bp); x++) { 130 for (x = 0; x < BBTOB(bp->b_length); 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,
133 "%s: bip %x buffer %x orig %x index %d", 133 "%s: bip %x buffer %x orig %x index %d",
@@ -657,7 +657,8 @@ xfs_buf_item_init(
657 * truncate any pieces. map_size is the size of the 657 * truncate any pieces. map_size is the size of the
658 * bitmap needed to describe the chunks of the buffer. 658 * bitmap needed to describe the chunks of the buffer.
659 */ 659 */
660 chunks = (int)((XFS_BUF_COUNT(bp) + (XFS_BLF_CHUNK - 1)) >> XFS_BLF_SHIFT); 660 chunks = (int)((BBTOB(bp->b_length) + (XFS_BLF_CHUNK - 1)) >>
661 XFS_BLF_SHIFT);
661 map_size = (int)((chunks + NBWORD) >> BIT_TO_WORD_SHIFT); 662 map_size = (int)((chunks + NBWORD) >> BIT_TO_WORD_SHIFT);
662 663
663 bip = (xfs_buf_log_item_t*)kmem_zone_zalloc(xfs_buf_item_zone, 664 bip = (xfs_buf_log_item_t*)kmem_zone_zalloc(xfs_buf_item_zone,
@@ -667,7 +668,7 @@ xfs_buf_item_init(
667 xfs_buf_hold(bp); 668 xfs_buf_hold(bp);
668 bip->bli_format.blf_type = XFS_LI_BUF; 669 bip->bli_format.blf_type = XFS_LI_BUF;
669 bip->bli_format.blf_blkno = (__int64_t)XFS_BUF_ADDR(bp); 670 bip->bli_format.blf_blkno = (__int64_t)XFS_BUF_ADDR(bp);
670 bip->bli_format.blf_len = (ushort)BTOBB(XFS_BUF_COUNT(bp)); 671 bip->bli_format.blf_len = (ushort)bp->b_length;
671 bip->bli_format.blf_map_size = map_size; 672 bip->bli_format.blf_map_size = map_size;
672 673
673#ifdef XFS_TRANS_DEBUG 674#ifdef XFS_TRANS_DEBUG
@@ -679,9 +680,9 @@ xfs_buf_item_init(
679 * the buffer to indicate which bytes the callers have asked 680 * the buffer to indicate which bytes the callers have asked
680 * to have logged. 681 * to have logged.
681 */ 682 */
682 bip->bli_orig = (char *)kmem_alloc(XFS_BUF_COUNT(bp), KM_SLEEP); 683 bip->bli_orig = kmem_alloc(BBTOB(bp->b_length), KM_SLEEP);
683 memcpy(bip->bli_orig, bp->b_addr, XFS_BUF_COUNT(bp)); 684 memcpy(bip->bli_orig, bp->b_addr, BBTOB(bp->b_length));
684 bip->bli_logged = (char *)kmem_zalloc(XFS_BUF_COUNT(bp) / NBBY, KM_SLEEP); 685 bip->bli_logged = kmem_zalloc(BBTOB(bp->b_length) / NBBY, KM_SLEEP);
685#endif 686#endif
686 687
687 /* 688 /*
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
index 7f1a6f5b05a6..b8adc79f0d88 100644
--- a/fs/xfs/xfs_da_btree.c
+++ b/fs/xfs/xfs_da_btree.c
@@ -2277,20 +2277,20 @@ xfs_da_buf_make(int nbuf, xfs_buf_t **bps)
2277 if (nbuf == 1) { 2277 if (nbuf == 1) {
2278 dabuf->nbuf = 1; 2278 dabuf->nbuf = 1;
2279 bp = bps[0]; 2279 bp = bps[0];
2280 dabuf->bbcount = (short)BTOBB(XFS_BUF_COUNT(bp)); 2280 dabuf->bbcount = bp->b_length;
2281 dabuf->data = bp->b_addr; 2281 dabuf->data = bp->b_addr;
2282 dabuf->bps[0] = bp; 2282 dabuf->bps[0] = bp;
2283 } else { 2283 } else {
2284 dabuf->nbuf = nbuf; 2284 dabuf->nbuf = nbuf;
2285 for (i = 0, dabuf->bbcount = 0; i < nbuf; i++) { 2285 for (i = 0, dabuf->bbcount = 0; i < nbuf; i++) {
2286 dabuf->bps[i] = bp = bps[i]; 2286 dabuf->bps[i] = bp = bps[i];
2287 dabuf->bbcount += BTOBB(XFS_BUF_COUNT(bp)); 2287 dabuf->bbcount += bp->b_length;
2288 } 2288 }
2289 dabuf->data = kmem_alloc(BBTOB(dabuf->bbcount), KM_SLEEP); 2289 dabuf->data = kmem_alloc(BBTOB(dabuf->bbcount), KM_SLEEP);
2290 for (i = off = 0; i < nbuf; i++, off += XFS_BUF_COUNT(bp)) { 2290 for (i = off = 0; i < nbuf; i++, off += BBTOB(bp->b_length)) {
2291 bp = bps[i]; 2291 bp = bps[i];
2292 memcpy((char *)dabuf->data + off, bp->b_addr, 2292 memcpy((char *)dabuf->data + off, bp->b_addr,
2293 XFS_BUF_COUNT(bp)); 2293 BBTOB(bp->b_length));
2294 } 2294 }
2295 } 2295 }
2296 return dabuf; 2296 return dabuf;
@@ -2310,10 +2310,10 @@ xfs_da_buf_clean(xfs_dabuf_t *dabuf)
2310 ASSERT(dabuf->nbuf > 1); 2310 ASSERT(dabuf->nbuf > 1);
2311 dabuf->dirty = 0; 2311 dabuf->dirty = 0;
2312 for (i = off = 0; i < dabuf->nbuf; 2312 for (i = off = 0; i < dabuf->nbuf;
2313 i++, off += XFS_BUF_COUNT(bp)) { 2313 i++, off += BBTOB(bp->b_length)) {
2314 bp = dabuf->bps[i]; 2314 bp = dabuf->bps[i];
2315 memcpy(bp->b_addr, dabuf->data + off, 2315 memcpy(bp->b_addr, dabuf->data + off,
2316 XFS_BUF_COUNT(bp)); 2316 BBTOB(bp->b_length));
2317 } 2317 }
2318 } 2318 }
2319} 2319}
@@ -2356,10 +2356,10 @@ xfs_da_log_buf(xfs_trans_t *tp, xfs_dabuf_t *dabuf, uint first, uint last)
2356 } 2356 }
2357 dabuf->dirty = 1; 2357 dabuf->dirty = 1;
2358 ASSERT(first <= last); 2358 ASSERT(first <= last);
2359 for (i = off = 0; i < dabuf->nbuf; i++, off += XFS_BUF_COUNT(bp)) { 2359 for (i = off = 0; i < dabuf->nbuf; i++, off += BBTOB(bp->b_length)) {
2360 bp = dabuf->bps[i]; 2360 bp = dabuf->bps[i];
2361 f = off; 2361 f = off;
2362 l = f + XFS_BUF_COUNT(bp) - 1; 2362 l = f + BBTOB(bp->b_length) - 1;
2363 if (f < first) 2363 if (f < first)
2364 f = first; 2364 f = first;
2365 if (l > last) 2365 if (l > last)
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index f9d8355ffae2..5e2aa526e058 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -1487,7 +1487,7 @@ xlog_sync(xlog_t *log,
1487 } else { 1487 } else {
1488 iclog->ic_bwritecnt = 1; 1488 iclog->ic_bwritecnt = 1;
1489 } 1489 }
1490 XFS_BUF_SET_COUNT(bp, count); 1490 bp->b_io_length = BTOBB(count);
1491 bp->b_fspriv = iclog; 1491 bp->b_fspriv = iclog;
1492 XFS_BUF_ZEROFLAGS(bp); 1492 XFS_BUF_ZEROFLAGS(bp);
1493 XFS_BUF_ASYNC(bp); 1493 XFS_BUF_ASYNC(bp);
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 24f59a25ecdd..8c826b00aac1 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -178,7 +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_SET_COUNT(bp, BBTOB(nbblks)); 181 bp->b_io_length = nbblks;
182 bp->b_error = 0; 182 bp->b_error = 0;
183 183
184 xfsbdstrat(log->l_mp, bp); 184 xfsbdstrat(log->l_mp, bp);
@@ -266,7 +266,7 @@ xlog_bwrite(
266 XFS_BUF_ZEROFLAGS(bp); 266 XFS_BUF_ZEROFLAGS(bp);
267 xfs_buf_hold(bp); 267 xfs_buf_hold(bp);
268 xfs_buf_lock(bp); 268 xfs_buf_lock(bp);
269 XFS_BUF_SET_COUNT(bp, BBTOB(nbblks)); 269 bp->b_io_length = nbblks;
270 bp->b_error = 0; 270 bp->b_error = 0;
271 271
272 error = xfs_bwrite(bp); 272 error = xfs_bwrite(bp);
@@ -1778,7 +1778,7 @@ xlog_recover_do_inode_buffer(
1778 1778
1779 trace_xfs_log_recover_buf_inode_buf(mp->m_log, buf_f); 1779 trace_xfs_log_recover_buf_inode_buf(mp->m_log, buf_f);
1780 1780
1781 inodes_per_buf = XFS_BUF_COUNT(bp) >> mp->m_sb.sb_inodelog; 1781 inodes_per_buf = BBTOB(bp->b_io_length) >> mp->m_sb.sb_inodelog;
1782 for (i = 0; i < inodes_per_buf; i++) { 1782 for (i = 0; i < inodes_per_buf; i++) {
1783 next_unlinked_offset = (i * mp->m_sb.sb_inodesize) + 1783 next_unlinked_offset = (i * mp->m_sb.sb_inodesize) +
1784 offsetof(xfs_dinode_t, di_next_unlinked); 1784 offsetof(xfs_dinode_t, di_next_unlinked);
@@ -1820,7 +1820,8 @@ xlog_recover_do_inode_buffer(
1820 1820
1821 ASSERT(item->ri_buf[item_index].i_addr != NULL); 1821 ASSERT(item->ri_buf[item_index].i_addr != NULL);
1822 ASSERT((item->ri_buf[item_index].i_len % XFS_BLF_CHUNK) == 0); 1822 ASSERT((item->ri_buf[item_index].i_len % XFS_BLF_CHUNK) == 0);
1823 ASSERT((reg_buf_offset + reg_buf_bytes) <= XFS_BUF_COUNT(bp)); 1823 ASSERT((reg_buf_offset + reg_buf_bytes) <=
1824 BBTOB(bp->b_io_length));
1824 1825
1825 /* 1826 /*
1826 * The current logged region contains a copy of the 1827 * The current logged region contains a copy of the
@@ -1879,8 +1880,8 @@ xlog_recover_do_reg_buffer(
1879 ASSERT(nbits > 0); 1880 ASSERT(nbits > 0);
1880 ASSERT(item->ri_buf[i].i_addr != NULL); 1881 ASSERT(item->ri_buf[i].i_addr != NULL);
1881 ASSERT(item->ri_buf[i].i_len % XFS_BLF_CHUNK == 0); 1882 ASSERT(item->ri_buf[i].i_len % XFS_BLF_CHUNK == 0);
1882 ASSERT(XFS_BUF_COUNT(bp) >= 1883 ASSERT(BBTOB(bp->b_io_length) >=
1883 ((uint)bit << XFS_BLF_SHIFT)+(nbits<<XFS_BLF_SHIFT)); 1884 ((uint)bit << XFS_BLF_SHIFT) + (nbits << XFS_BLF_SHIFT));
1884 1885
1885 /* 1886 /*
1886 * Do a sanity check if this is a dquot buffer. Just checking 1887 * Do a sanity check if this is a dquot buffer. Just checking
@@ -2173,7 +2174,7 @@ xlog_recover_buffer_pass2(
2173 */ 2174 */
2174 if (XFS_DINODE_MAGIC == 2175 if (XFS_DINODE_MAGIC ==
2175 be16_to_cpu(*((__be16 *)xfs_buf_offset(bp, 0))) && 2176 be16_to_cpu(*((__be16 *)xfs_buf_offset(bp, 0))) &&
2176 (XFS_BUF_COUNT(bp) != MAX(log->l_mp->m_sb.sb_blocksize, 2177 (BBTOB(bp->b_io_length) != MAX(log->l_mp->m_sb.sb_blocksize,
2177 (__uint32_t)XFS_INODE_CLUSTER_SIZE(log->l_mp)))) { 2178 (__uint32_t)XFS_INODE_CLUSTER_SIZE(log->l_mp)))) {
2178 xfs_buf_stale(bp); 2179 xfs_buf_stale(bp);
2179 error = xfs_bwrite(bp); 2180 error = xfs_bwrite(bp);
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c
index 9132d162c4b8..2ec196b6c079 100644
--- a/fs/xfs/xfs_trans_buf.c
+++ b/fs/xfs/xfs_trans_buf.c
@@ -56,7 +56,7 @@ xfs_trans_buf_item_match(
56 if (blip->bli_item.li_type == XFS_LI_BUF && 56 if (blip->bli_item.li_type == XFS_LI_BUF &&
57 blip->bli_buf->b_target == 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 BBTOB(blip->bli_buf->b_length) == len)
60 return blip->bli_buf; 60 return blip->bli_buf;
61 } 61 }
62 62
@@ -585,7 +585,7 @@ xfs_trans_log_buf(xfs_trans_t *tp,
585 585
586 ASSERT(bp->b_transp == tp); 586 ASSERT(bp->b_transp == tp);
587 ASSERT(bip != NULL); 587 ASSERT(bip != NULL);
588 ASSERT((first <= last) && (last < XFS_BUF_COUNT(bp))); 588 ASSERT(first <= last && last < BBTOB(bp->b_length));
589 ASSERT(bp->b_iodone == NULL || 589 ASSERT(bp->b_iodone == NULL ||
590 bp->b_iodone == xfs_buf_iodone_callbacks); 590 bp->b_iodone == xfs_buf_iodone_callbacks);
591 591