Commit facee0a0 authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: make extent_fiemap take btrfs_inode

Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 948dfeb8
...@@ -4696,7 +4696,7 @@ static int emit_last_fiemap_cache(struct fiemap_extent_info *fieinfo, ...@@ -4696,7 +4696,7 @@ static int emit_last_fiemap_cache(struct fiemap_extent_info *fieinfo,
return ret; return ret;
} }
int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, int extent_fiemap(struct btrfs_inode *inode, struct fiemap_extent_info *fieinfo,
u64 start, u64 len) u64 start, u64 len)
{ {
int ret = 0; int ret = 0;
...@@ -4707,12 +4707,12 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, ...@@ -4707,12 +4707,12 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
u64 last; u64 last;
u64 last_for_get_extent = 0; u64 last_for_get_extent = 0;
u64 disko = 0; u64 disko = 0;
u64 isize = i_size_read(inode); u64 isize = i_size_read(&inode->vfs_inode);
struct btrfs_key found_key; struct btrfs_key found_key;
struct extent_map *em = NULL; struct extent_map *em = NULL;
struct extent_state *cached_state = NULL; struct extent_state *cached_state = NULL;
struct btrfs_path *path; struct btrfs_path *path;
struct btrfs_root *root = BTRFS_I(inode)->root; struct btrfs_root *root = inode->root;
struct fiemap_cache cache = { 0 }; struct fiemap_cache cache = { 0 };
struct ulist *roots; struct ulist *roots;
struct ulist *tmp_ulist; struct ulist *tmp_ulist;
...@@ -4736,15 +4736,15 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, ...@@ -4736,15 +4736,15 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
goto out_free_ulist; goto out_free_ulist;
} }
start = round_down(start, btrfs_inode_sectorsize(BTRFS_I(inode))); start = round_down(start, btrfs_inode_sectorsize(inode));
len = round_up(max, btrfs_inode_sectorsize(BTRFS_I(inode))) - start; len = round_up(max, btrfs_inode_sectorsize(inode)) - start;
/* /*
* lookup the last file extent. We're not using i_size here * lookup the last file extent. We're not using i_size here
* because there might be preallocation past i_size * because there might be preallocation past i_size
*/ */
ret = btrfs_lookup_file_extent(NULL, root, path, ret = btrfs_lookup_file_extent(NULL, root, path, btrfs_ino(inode), -1,
btrfs_ino(BTRFS_I(inode)), -1, 0); 0);
if (ret < 0) { if (ret < 0) {
goto out_free_ulist; goto out_free_ulist;
} else { } else {
...@@ -4758,7 +4758,7 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, ...@@ -4758,7 +4758,7 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
found_type = found_key.type; found_type = found_key.type;
/* No extents, but there might be delalloc bits */ /* No extents, but there might be delalloc bits */
if (found_key.objectid != btrfs_ino(BTRFS_I(inode)) || if (found_key.objectid != btrfs_ino(inode) ||
found_type != BTRFS_EXTENT_DATA_KEY) { found_type != BTRFS_EXTENT_DATA_KEY) {
/* have to trust i_size as the end */ /* have to trust i_size as the end */
last = (u64)-1; last = (u64)-1;
...@@ -4784,10 +4784,10 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, ...@@ -4784,10 +4784,10 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
last_for_get_extent = isize; last_for_get_extent = isize;
} }
lock_extent_bits(&BTRFS_I(inode)->io_tree, start, start + len - 1, lock_extent_bits(&inode->io_tree, start, start + len - 1,
&cached_state); &cached_state);
em = get_extent_skip_holes(BTRFS_I(inode), start, last_for_get_extent); em = get_extent_skip_holes(inode, start, last_for_get_extent);
if (!em) if (!em)
goto out; goto out;
if (IS_ERR(em)) { if (IS_ERR(em)) {
...@@ -4853,8 +4853,7 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, ...@@ -4853,8 +4853,7 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
* then we're just getting a count and we can skip the * then we're just getting a count and we can skip the
* lookup stuff. * lookup stuff.
*/ */
ret = btrfs_check_shared(root, ret = btrfs_check_shared(root, btrfs_ino(inode),
btrfs_ino(BTRFS_I(inode)),
bytenr, roots, tmp_ulist); bytenr, roots, tmp_ulist);
if (ret < 0) if (ret < 0)
goto out_free; goto out_free;
...@@ -4876,8 +4875,7 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, ...@@ -4876,8 +4875,7 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
} }
/* now scan forward to see if this is really the last extent. */ /* now scan forward to see if this is really the last extent. */
em = get_extent_skip_holes(BTRFS_I(inode), off, em = get_extent_skip_holes(inode, off, last_for_get_extent);
last_for_get_extent);
if (IS_ERR(em)) { if (IS_ERR(em)) {
ret = PTR_ERR(em); ret = PTR_ERR(em);
goto out; goto out;
...@@ -4899,7 +4897,7 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, ...@@ -4899,7 +4897,7 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
ret = emit_last_fiemap_cache(fieinfo, &cache); ret = emit_last_fiemap_cache(fieinfo, &cache);
free_extent_map(em); free_extent_map(em);
out: out:
unlock_extent_cached(&BTRFS_I(inode)->io_tree, start, start + len - 1, unlock_extent_cached(&inode->io_tree, start, start + len - 1,
&cached_state); &cached_state);
out_free_ulist: out_free_ulist:
......
...@@ -203,7 +203,7 @@ int extent_writepages(struct address_space *mapping, ...@@ -203,7 +203,7 @@ int extent_writepages(struct address_space *mapping,
int btree_write_cache_pages(struct address_space *mapping, int btree_write_cache_pages(struct address_space *mapping,
struct writeback_control *wbc); struct writeback_control *wbc);
void extent_readahead(struct readahead_control *rac); void extent_readahead(struct readahead_control *rac);
int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, int extent_fiemap(struct btrfs_inode *inode, struct fiemap_extent_info *fieinfo,
u64 start, u64 len); u64 start, u64 len);
void set_page_extent_mapped(struct page *page); void set_page_extent_mapped(struct page *page);
......
...@@ -8035,7 +8035,7 @@ static int btrfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, ...@@ -8035,7 +8035,7 @@ static int btrfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
if (ret) if (ret)
return ret; return ret;
return extent_fiemap(inode, fieinfo, start, len); return extent_fiemap(BTRFS_I(inode), fieinfo, start, len);
} }
int btrfs_readpage(struct file *file, struct page *page) int btrfs_readpage(struct file *file, struct page *page)
......
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