summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2010-04-28 12:28:59 +0000
committerAlex Elder <aelder@sgi.com>2010-05-19 09:58:19 -0500
commit2b8f12b7e438fa6ba4a0f8f861871be0beb3a3e6 (patch)
tree8528d14896aef2e8718fd9edc4fc716d7815ae3f /fs
parent558e6891693f4c383c51c7343a88dea174eadacf (diff)
downloadlwn-2b8f12b7e438fa6ba4a0f8f861871be0beb3a3e6.tar.gz
lwn-2b8f12b7e438fa6ba4a0f8f861871be0beb3a3e6.zip
xfs: clean up mapping size calculation in __xfs_get_blocks
Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Alex Elder <aelder@sgi.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c
index 6feecd279470..1d51bdde5748 100644
--- a/fs/xfs/linux-2.6/xfs_aops.c
+++ b/fs/xfs/linux-2.6/xfs_aops.c
@@ -1536,16 +1536,23 @@ __xfs_get_blocks(
}
}
+ /*
+ * If this is O_DIRECT or the mpage code calling tell them how large
+ * the mapping is, so that we can avoid repeated get_blocks calls.
+ */
if (direct || size > (1 << inode->i_blkbits)) {
- struct xfs_mount *mp = XFS_I(inode)->i_mount;
- xfs_off_t iomap_offset = XFS_FSB_TO_B(mp, imap.br_startoff);
- xfs_off_t iomap_delta = offset - iomap_offset;
- xfs_off_t iomap_bsize = XFS_FSB_TO_B(mp, imap.br_blockcount);
-
- ASSERT(iomap_bsize - iomap_delta > 0);
- offset = min_t(xfs_off_t,
- iomap_bsize - iomap_delta, size);
- bh_result->b_size = (ssize_t)min_t(xfs_off_t, LONG_MAX, offset);
+ xfs_off_t mapping_size;
+
+ mapping_size = imap.br_startoff + imap.br_blockcount - iblock;
+ mapping_size <<= inode->i_blkbits;
+
+ ASSERT(mapping_size > 0);
+ if (mapping_size > size)
+ mapping_size = size;
+ if (mapping_size > LONG_MAX)
+ mapping_size = LONG_MAX;
+
+ bh_result->b_size = mapping_size;
}
return 0;