aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/linux-2.6/xfs_aops.c
diff options
context:
space:
mode:
authorNathan Scott <nathans@sgi.com>2006-03-13 21:26:43 -0500
committerNathan Scott <nathans@sgi.com>2006-03-13 21:26:43 -0500
commit87cbc49cd4b773a972bce56c5dd09c4717f3285b (patch)
tree2070b4b4fdc72a74d8a7a76b29f4a63e96a49d04 /fs/xfs/linux-2.6/xfs_aops.c
parentf51623b21fe3068d12f0c5d39e02fd2549635a99 (diff)
[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: Christoph Hellwig <hch@lst.de> Signed-off-by: Nathan Scott <nathans@sgi.com>
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_aops.c')
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.c49
1 files changed, 25 insertions, 24 deletions
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c
index 58fc7ade90b5..4b6bfdb8251c 100644
--- a/fs/xfs/linux-2.6/xfs_aops.c
+++ b/fs/xfs/linux-2.6/xfs_aops.c
@@ -487,28 +487,37 @@ xfs_add_to_ioend(
487} 487}
488 488
489STATIC void 489STATIC void
490xfs_map_buffer(
491 struct buffer_head *bh,
492 xfs_iomap_t *mp,
493 xfs_off_t offset,
494 uint block_bits)
495{
496 sector_t bn;
497
498 ASSERT(mp->iomap_bn != IOMAP_DADDR_NULL);
499
500 bn = (mp->iomap_bn >> (block_bits - BBSHIFT)) +
501 ((offset - mp->iomap_offset) >> block_bits);
502
503 ASSERT(bn || (mp->iomap_flags & IOMAP_REALTIME));
504
505 bh->b_blocknr = bn;
506 set_buffer_mapped(bh);
507}
508
509STATIC void
490xfs_map_at_offset( 510xfs_map_at_offset(
491 struct buffer_head *bh, 511 struct buffer_head *bh,
492 loff_t offset, 512 loff_t offset,
493 int block_bits, 513 int block_bits,
494 xfs_iomap_t *iomapp) 514 xfs_iomap_t *iomapp)
495{ 515{
496 xfs_daddr_t bn;
497 int sector_shift;
498
499 ASSERT(!(iomapp->iomap_flags & IOMAP_HOLE)); 516 ASSERT(!(iomapp->iomap_flags & IOMAP_HOLE));
500 ASSERT(!(iomapp->iomap_flags & IOMAP_DELAY)); 517 ASSERT(!(iomapp->iomap_flags & IOMAP_DELAY));
501 ASSERT(iomapp->iomap_bn != IOMAP_DADDR_NULL);
502
503 sector_shift = block_bits - BBSHIFT;
504 bn = (iomapp->iomap_bn >> sector_shift) +
505 ((offset - iomapp->iomap_offset) >> block_bits);
506
507 ASSERT(bn || (iomapp->iomap_flags & IOMAP_REALTIME));
508 ASSERT((bn << sector_shift) >= iomapp->iomap_bn);
509 518
510 lock_buffer(bh); 519 lock_buffer(bh);
511 bh->b_blocknr = bn; 520 xfs_map_buffer(bh, iomapp, offset, block_bits);
512 bh->b_bdev = iomapp->iomap_target->bt_bdev; 521 bh->b_bdev = iomapp->iomap_target->bt_bdev;
513 set_buffer_mapped(bh); 522 set_buffer_mapped(bh);
514 clear_buffer_delay(bh); 523 clear_buffer_delay(bh);
@@ -1246,21 +1255,13 @@ __linvfs_get_block(
1246 return 0; 1255 return 0;
1247 1256
1248 if (iomap.iomap_bn != IOMAP_DADDR_NULL) { 1257 if (iomap.iomap_bn != IOMAP_DADDR_NULL) {
1249 xfs_daddr_t bn; 1258 /*
1250 xfs_off_t delta; 1259 * For unwritten extents do not report a disk address on
1251
1252 /* For unwritten extents do not report a disk address on
1253 * the read case (treat as if we're reading into a hole). 1260 * the read case (treat as if we're reading into a hole).
1254 */ 1261 */
1255 if (create || !(iomap.iomap_flags & IOMAP_UNWRITTEN)) { 1262 if (create || !(iomap.iomap_flags & IOMAP_UNWRITTEN)) {
1256 delta = offset - iomap.iomap_offset; 1263 xfs_map_buffer(bh_result, &iomap, offset,
1257 delta >>= inode->i_blkbits; 1264 inode->i_blkbits);
1258
1259 bn = iomap.iomap_bn >> (inode->i_blkbits - BBSHIFT);
1260 bn += delta;
1261 BUG_ON(!bn && !(iomap.iomap_flags & IOMAP_REALTIME));
1262 bh_result->b_blocknr = bn;
1263 set_buffer_mapped(bh_result);
1264 } 1265 }
1265 if (create && (iomap.iomap_flags & IOMAP_UNWRITTEN)) { 1266 if (create && (iomap.iomap_flags & IOMAP_UNWRITTEN)) {
1266 if (direct) 1267 if (direct)