Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 128455
b: refs/heads/master
c: d396c6f
h: refs/heads/master
i:
  128453: f3da753
  128451: b144e8e
  128447: 7c56bb8
v: v3
  • Loading branch information
Christoph Hellwig authored and David Woodhouse committed Sep 11, 2007
1 parent d835140 commit 488bf7f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 90f1c19a9fd2a943adc69d2b9b8c83bcc4bba6f9
refs/heads/master: d396c6f554d182b7bce4e2bb2acb47f80430c05f
19 changes: 19 additions & 0 deletions trunk/fs/btrfs/extent_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -1816,3 +1816,22 @@ int try_release_extent_mapping(struct extent_map_tree *tree, struct page *page)
}
EXPORT_SYMBOL(try_release_extent_mapping);

sector_t extent_bmap(struct address_space *mapping, sector_t iblock,
get_extent_t *get_extent)
{
struct inode *inode = mapping->host;
u64 start = iblock << inode->i_blkbits;
u64 end = start + (1 << inode->i_blkbits) - 1;
struct extent_map *em;

em = get_extent(inode, NULL, 0, start, end, 0);
if (!em || IS_ERR(em))
return 0;

// XXX(hch): block 0 is valid in some cases, e.g. XFS RT device
if (em->block_start == EXTENT_MAP_INLINE ||
em->block_start == 0)
return 0;

return (em->block_start + start - em->start) >> inode->i_blkbits;
}
2 changes: 2 additions & 0 deletions trunk/fs/btrfs/extent_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ int extent_prepare_write(struct extent_map_tree *tree,
int extent_commit_write(struct extent_map_tree *tree,
struct inode *inode, struct page *page,
unsigned from, unsigned to);
sector_t extent_bmap(struct address_space *mapping, sector_t iblock,
get_extent_t *get_extent);
int set_range_dirty(struct extent_map_tree *tree, u64 start, u64 end);
int set_state_private(struct extent_map_tree *tree, u64 start, u64 private);
int get_state_private(struct extent_map_tree *tree, u64 start, u64 *private);
Expand Down
23 changes: 2 additions & 21 deletions trunk/fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1567,28 +1567,9 @@ struct extent_map *btrfs_get_extent(struct inode *inode, struct page *page,
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,
Expand Down

0 comments on commit 488bf7f

Please sign in to comment.