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>
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 382c49a..ab3c449 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -198,12 +198,12 @@
bp->b_target = target;
/*
- * Set length and count_desired to the same value initially.
- * I/O routines should use count_desired, which will be the same in
+ * Set length and io_length to the same value initially.
+ * I/O routines should use io_length, which will be the same in
* most cases but may be reset (e.g. XFS recovery).
*/
bp->b_length = numblks;
- bp->b_count_desired = numblks << BBSHIFT;
+ bp->b_io_length = numblks;
bp->b_flags = flags;
/*
@@ -302,7 +302,7 @@
xfs_buf_t *bp,
uint flags)
{
- size_t size = bp->b_count_desired;
+ size_t size;
size_t nbytes, offset;
gfp_t gfp_mask = xb_to_gfp(flags);
unsigned short page_count, i;
@@ -345,6 +345,7 @@
return error;
offset = bp->b_offset;
+ size = BBTOB(bp->b_length);
bp->b_flags |= _XBF_PAGES;
for (i = 0; i < bp->b_page_count; i++) {
@@ -575,7 +576,7 @@
* that we can do IO on it.
*/
bp->b_bn = blkno;
- bp->b_count_desired = BBTOB(bp->b_length);
+ bp->b_io_length = bp->b_length;
found:
if (!(bp->b_flags & XBF_MAPPED)) {
@@ -718,7 +719,7 @@
bp->b_page_count = 0;
bp->b_addr = NULL;
bp->b_length = numblks;
- bp->b_count_desired = numblks << BBSHIFT;
+ bp->b_io_length = numblks;
bp->b_bn = XFS_BUF_DADDR_NULL;
bp->b_flags &= ~XBF_MAPPED;
}
@@ -770,7 +771,7 @@
pageaddr += PAGE_SIZE;
}
- bp->b_count_desired = len;
+ bp->b_io_length = BTOBB(len);
bp->b_length = BTOBB(buflen);
bp->b_flags |= XBF_MAPPED;
@@ -1012,9 +1013,8 @@
const char *func)
{
xfs_alert(bp->b_target->bt_mount,
-"metadata I/O error: block 0x%llx (\"%s\") error %d buf count %zd",
- (__uint64_t)XFS_BUF_ADDR(bp), func,
- bp->b_error, XFS_BUF_COUNT(bp));
+"metadata I/O error: block 0x%llx (\"%s\") error %d numblks %d",
+ (__uint64_t)XFS_BUF_ADDR(bp), func, bp->b_error, bp->b_length);
}
int
@@ -1186,7 +1186,7 @@
int rw, map_i, total_nr_pages, nr_pages;
struct bio *bio;
int offset = bp->b_offset;
- int size = bp->b_count_desired;
+ int size = BBTOB(bp->b_io_length);
sector_t sector = bp->b_bn;
total_nr_pages = bp->b_page_count;
@@ -1234,7 +1234,7 @@
break;
offset = 0;
- sector += nbytes >> BBSHIFT;
+ sector += BTOBB(nbytes);
size -= nbytes;
total_nr_pages--;
}
@@ -1328,7 +1328,7 @@
page = bp->b_pages[xfs_buf_btoct(boff + bp->b_offset)];
cpoff = xfs_buf_poff(boff + bp->b_offset);
csize = min_t(size_t,
- PAGE_SIZE-cpoff, bp->b_count_desired-boff);
+ PAGE_SIZE - cpoff, BBTOB(bp->b_io_length) - boff);
ASSERT(((csize + cpoff) <= PAGE_SIZE));