Commit 87cbc49c authored by Nathan Scott's avatar Nathan Scott

[XFS] Add xfs_map_buffer helper, use it in a couple of places.

SGI-PV: 950211
SGI-Modid: xfs-linux-melb:xfs-kern:25312a
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarNathan Scott <nathans@sgi.com>
parent f51623b2
...@@ -486,6 +486,26 @@ xfs_add_to_ioend( ...@@ -486,6 +486,26 @@ xfs_add_to_ioend(
ioend->io_size += bh->b_size; ioend->io_size += bh->b_size;
} }
STATIC void
xfs_map_buffer(
struct buffer_head *bh,
xfs_iomap_t *mp,
xfs_off_t offset,
uint block_bits)
{
sector_t bn;
ASSERT(mp->iomap_bn != IOMAP_DADDR_NULL);
bn = (mp->iomap_bn >> (block_bits - BBSHIFT)) +
((offset - mp->iomap_offset) >> block_bits);
ASSERT(bn || (mp->iomap_flags & IOMAP_REALTIME));
bh->b_blocknr = bn;
set_buffer_mapped(bh);
}
STATIC void STATIC void
xfs_map_at_offset( xfs_map_at_offset(
struct buffer_head *bh, struct buffer_head *bh,
...@@ -493,22 +513,11 @@ xfs_map_at_offset( ...@@ -493,22 +513,11 @@ xfs_map_at_offset(
int block_bits, int block_bits,
xfs_iomap_t *iomapp) xfs_iomap_t *iomapp)
{ {
xfs_daddr_t bn;
int sector_shift;
ASSERT(!(iomapp->iomap_flags & IOMAP_HOLE)); ASSERT(!(iomapp->iomap_flags & IOMAP_HOLE));
ASSERT(!(iomapp->iomap_flags & IOMAP_DELAY)); ASSERT(!(iomapp->iomap_flags & IOMAP_DELAY));
ASSERT(iomapp->iomap_bn != IOMAP_DADDR_NULL);
sector_shift = block_bits - BBSHIFT;
bn = (iomapp->iomap_bn >> sector_shift) +
((offset - iomapp->iomap_offset) >> block_bits);
ASSERT(bn || (iomapp->iomap_flags & IOMAP_REALTIME));
ASSERT((bn << sector_shift) >= iomapp->iomap_bn);
lock_buffer(bh); lock_buffer(bh);
bh->b_blocknr = bn; xfs_map_buffer(bh, iomapp, offset, block_bits);
bh->b_bdev = iomapp->iomap_target->bt_bdev; bh->b_bdev = iomapp->iomap_target->bt_bdev;
set_buffer_mapped(bh); set_buffer_mapped(bh);
clear_buffer_delay(bh); clear_buffer_delay(bh);
...@@ -1246,21 +1255,13 @@ __linvfs_get_block( ...@@ -1246,21 +1255,13 @@ __linvfs_get_block(
return 0; return 0;
if (iomap.iomap_bn != IOMAP_DADDR_NULL) { if (iomap.iomap_bn != IOMAP_DADDR_NULL) {
xfs_daddr_t bn; /*
xfs_off_t delta; * For unwritten extents do not report a disk address on
/* For unwritten extents do not report a disk address on
* the read case (treat as if we're reading into a hole). * the read case (treat as if we're reading into a hole).
*/ */
if (create || !(iomap.iomap_flags & IOMAP_UNWRITTEN)) { if (create || !(iomap.iomap_flags & IOMAP_UNWRITTEN)) {
delta = offset - iomap.iomap_offset; xfs_map_buffer(bh_result, &iomap, offset,
delta >>= inode->i_blkbits; inode->i_blkbits);
bn = iomap.iomap_bn >> (inode->i_blkbits - BBSHIFT);
bn += delta;
BUG_ON(!bn && !(iomap.iomap_flags & IOMAP_REALTIME));
bh_result->b_blocknr = bn;
set_buffer_mapped(bh_result);
} }
if (create && (iomap.iomap_flags & IOMAP_UNWRITTEN)) { if (create && (iomap.iomap_flags & IOMAP_UNWRITTEN)) {
if (direct) if (direct)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment