summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2007-09-10 20:02:30 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-09-10 20:02:30 -0400
commitd396c6f554d182b7bce4e2bb2acb47f80430c05f (patch)
tree2bc7b567310474ed4562d4e1246efd69a868f8cd /fs/btrfs/inode.c
parent90f1c19a9fd2a943adc69d2b9b8c83bcc4bba6f9 (diff)
Btrfs: [PATCH] extent_map: provide generic bmap
generic_bmap is completely trivial, while the extent to bh mapping in btrfs is rather complex. So provide a extent_bmap instead that takes a get_extent callback and can be used by filesystem using the extent_map code. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c23
1 files changed, 2 insertions, 21 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 1ace6d11e09..39c1fe178f4 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1567,28 +1567,9 @@ out:
return em;
}
-static int btrfs_get_block_bmap(struct inode *inode, sector_t iblock,
- struct buffer_head *result, int create)
+static sector_t btrfs_bmap(struct address_space *mapping, sector_t iblock)
{
- struct btrfs_root *root = BTRFS_I(inode)->root;
- u64 start = iblock << inode->i_blkbits;
- u64 end = start + root->blocksize -1;
- struct extent_map *em;
-
- em = btrfs_get_extent(inode, NULL, 0, start, end, 0);
- if (em && !IS_ERR(em) && em->block_start != EXTENT_MAP_INLINE &&
- em->block_start != 0) {
- u64 offset;
- offset = start - em->start;
- start = (em->block_start + offset) >> inode->i_blkbits;
- btrfs_map_bh_to_logical(root, result, start);
- }
- return 0;
-}
-
-static sector_t btrfs_bmap(struct address_space *as, sector_t block)
-{
- return generic_block_bmap(as, block, btrfs_get_block_bmap);
+ return extent_bmap(mapping, iblock, btrfs_get_extent);
}
static int btrfs_prepare_write(struct file *file, struct page *page,