diff options
Diffstat (limited to 'fs/btrfs/extent_map.c')
-rw-r--r-- | fs/btrfs/extent_map.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c index 3021564ac62c..ff2b1dd25bf9 100644 --- a/fs/btrfs/extent_map.c +++ b/fs/btrfs/extent_map.c | |||
@@ -1816,3 +1816,22 @@ int try_release_extent_mapping(struct extent_map_tree *tree, struct page *page) | |||
1816 | } | 1816 | } |
1817 | EXPORT_SYMBOL(try_release_extent_mapping); | 1817 | EXPORT_SYMBOL(try_release_extent_mapping); |
1818 | 1818 | ||
1819 | sector_t extent_bmap(struct address_space *mapping, sector_t iblock, | ||
1820 | get_extent_t *get_extent) | ||
1821 | { | ||
1822 | struct inode *inode = mapping->host; | ||
1823 | u64 start = iblock << inode->i_blkbits; | ||
1824 | u64 end = start + (1 << inode->i_blkbits) - 1; | ||
1825 | struct extent_map *em; | ||
1826 | |||
1827 | em = get_extent(inode, NULL, 0, start, end, 0); | ||
1828 | if (!em || IS_ERR(em)) | ||
1829 | return 0; | ||
1830 | |||
1831 | // XXX(hch): block 0 is valid in some cases, e.g. XFS RT device | ||
1832 | if (em->block_start == EXTENT_MAP_INLINE || | ||
1833 | em->block_start == 0) | ||
1834 | return 0; | ||
1835 | |||
1836 | return (em->block_start + start - em->start) >> inode->i_blkbits; | ||
1837 | } | ||