aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_buf.c
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 /fs/xfs/xfs_buf.c
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>
Diffstat (limited to 'fs/xfs/xfs_buf.c')
-rw-r--r--fs/xfs/xfs_buf.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 382c49a42ac..ab3c4491777 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