btrfs: directly pass the inode to btrfs_is_data_extent_shared()
Currently we pass a root and an inode number as arguments for btrfs_is_data_extent_shared() and the inode number is always from an inode that belongs to that root (it wouldn't make sense otherwise). In every context that we call btrfs_is_data_extent_shared() (fiemap only), we have an inode available, so directly pass the inode to the function instead of a root and inode number. This reduces the number of parameters and it makes the function's signature conform to most other functions we have. Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
a0a5472ad8
commit
ceb707da9a
@ -1658,8 +1658,7 @@ static void store_backref_shared_cache(struct btrfs_backref_shared_cache *cache,
|
|||||||
/*
|
/*
|
||||||
* Check if a data extent is shared or not.
|
* Check if a data extent is shared or not.
|
||||||
*
|
*
|
||||||
* @root: The root the inode belongs to.
|
* @inode: The inode whose extent we are checking.
|
||||||
* @inum: Number of the inode whose extent we are checking.
|
|
||||||
* @bytenr: Logical bytenr of the extent we are checking.
|
* @bytenr: Logical bytenr of the extent we are checking.
|
||||||
* @extent_gen: Generation of the extent (file extent item) or 0 if it is
|
* @extent_gen: Generation of the extent (file extent item) or 0 if it is
|
||||||
* not known.
|
* not known.
|
||||||
@ -1678,11 +1677,12 @@ static void store_backref_shared_cache(struct btrfs_backref_shared_cache *cache,
|
|||||||
*
|
*
|
||||||
* Return: 0 if extent is not shared, 1 if it is shared, < 0 on error.
|
* Return: 0 if extent is not shared, 1 if it is shared, < 0 on error.
|
||||||
*/
|
*/
|
||||||
int btrfs_is_data_extent_shared(struct btrfs_root *root, u64 inum, u64 bytenr,
|
int btrfs_is_data_extent_shared(struct btrfs_inode *inode, u64 bytenr,
|
||||||
u64 extent_gen,
|
u64 extent_gen,
|
||||||
struct ulist *roots, struct ulist *tmp,
|
struct ulist *roots, struct ulist *tmp,
|
||||||
struct btrfs_backref_shared_cache *cache)
|
struct btrfs_backref_shared_cache *cache)
|
||||||
{
|
{
|
||||||
|
struct btrfs_root *root = inode->root;
|
||||||
struct btrfs_fs_info *fs_info = root->fs_info;
|
struct btrfs_fs_info *fs_info = root->fs_info;
|
||||||
struct btrfs_trans_handle *trans;
|
struct btrfs_trans_handle *trans;
|
||||||
struct ulist_iterator uiter;
|
struct ulist_iterator uiter;
|
||||||
@ -1691,7 +1691,7 @@ int btrfs_is_data_extent_shared(struct btrfs_root *root, u64 inum, u64 bytenr,
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct share_check shared = {
|
struct share_check shared = {
|
||||||
.root_objectid = root->root_key.objectid,
|
.root_objectid = root->root_key.objectid,
|
||||||
.inum = inum,
|
.inum = btrfs_ino(inode),
|
||||||
.share_count = 0,
|
.share_count = 0,
|
||||||
.have_delayed_delete_refs = false,
|
.have_delayed_delete_refs = false,
|
||||||
};
|
};
|
||||||
|
@ -77,7 +77,7 @@ int btrfs_find_one_extref(struct btrfs_root *root, u64 inode_objectid,
|
|||||||
u64 start_off, struct btrfs_path *path,
|
u64 start_off, struct btrfs_path *path,
|
||||||
struct btrfs_inode_extref **ret_extref,
|
struct btrfs_inode_extref **ret_extref,
|
||||||
u64 *found_off);
|
u64 *found_off);
|
||||||
int btrfs_is_data_extent_shared(struct btrfs_root *root, u64 inum, u64 bytenr,
|
int btrfs_is_data_extent_shared(struct btrfs_inode *inode, u64 bytenr,
|
||||||
u64 extent_gen,
|
u64 extent_gen,
|
||||||
struct ulist *roots, struct ulist *tmp,
|
struct ulist *roots, struct ulist *tmp,
|
||||||
struct btrfs_backref_shared_cache *cache);
|
struct btrfs_backref_shared_cache *cache);
|
||||||
|
@ -3712,7 +3712,6 @@ static int fiemap_process_hole(struct btrfs_inode *inode,
|
|||||||
u64 start, u64 end)
|
u64 start, u64 end)
|
||||||
{
|
{
|
||||||
const u64 i_size = i_size_read(&inode->vfs_inode);
|
const u64 i_size = i_size_read(&inode->vfs_inode);
|
||||||
const u64 ino = btrfs_ino(inode);
|
|
||||||
u64 cur_offset = start;
|
u64 cur_offset = start;
|
||||||
u64 last_delalloc_end = 0;
|
u64 last_delalloc_end = 0;
|
||||||
u32 prealloc_flags = FIEMAP_EXTENT_UNWRITTEN;
|
u32 prealloc_flags = FIEMAP_EXTENT_UNWRITTEN;
|
||||||
@ -3752,8 +3751,8 @@ static int fiemap_process_hole(struct btrfs_inode *inode,
|
|||||||
|
|
||||||
if (prealloc_len > 0) {
|
if (prealloc_len > 0) {
|
||||||
if (!checked_extent_shared && fieinfo->fi_extents_max) {
|
if (!checked_extent_shared && fieinfo->fi_extents_max) {
|
||||||
ret = btrfs_is_data_extent_shared(inode->root,
|
ret = btrfs_is_data_extent_shared(inode,
|
||||||
ino, disk_bytenr,
|
disk_bytenr,
|
||||||
extent_gen, roots,
|
extent_gen, roots,
|
||||||
tmp_ulist,
|
tmp_ulist,
|
||||||
backref_cache);
|
backref_cache);
|
||||||
@ -3802,8 +3801,8 @@ static int fiemap_process_hole(struct btrfs_inode *inode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!checked_extent_shared && fieinfo->fi_extents_max) {
|
if (!checked_extent_shared && fieinfo->fi_extents_max) {
|
||||||
ret = btrfs_is_data_extent_shared(inode->root,
|
ret = btrfs_is_data_extent_shared(inode,
|
||||||
ino, disk_bytenr,
|
disk_bytenr,
|
||||||
extent_gen, roots,
|
extent_gen, roots,
|
||||||
tmp_ulist,
|
tmp_ulist,
|
||||||
backref_cache);
|
backref_cache);
|
||||||
@ -3904,7 +3903,6 @@ int extent_fiemap(struct btrfs_inode *inode, struct fiemap_extent_info *fieinfo,
|
|||||||
const u64 ino = btrfs_ino(inode);
|
const u64 ino = btrfs_ino(inode);
|
||||||
struct extent_state *cached_state = NULL;
|
struct extent_state *cached_state = NULL;
|
||||||
struct btrfs_path *path;
|
struct btrfs_path *path;
|
||||||
struct btrfs_root *root = inode->root;
|
|
||||||
struct fiemap_cache cache = { 0 };
|
struct fiemap_cache cache = { 0 };
|
||||||
struct btrfs_backref_shared_cache *backref_cache;
|
struct btrfs_backref_shared_cache *backref_cache;
|
||||||
struct ulist *roots;
|
struct ulist *roots;
|
||||||
@ -3925,8 +3923,8 @@ int extent_fiemap(struct btrfs_inode *inode, struct fiemap_extent_info *fieinfo,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
lockstart = round_down(start, root->fs_info->sectorsize);
|
lockstart = round_down(start, inode->root->fs_info->sectorsize);
|
||||||
lockend = round_up(start + len, root->fs_info->sectorsize);
|
lockend = round_up(start + len, inode->root->fs_info->sectorsize);
|
||||||
prev_extent_end = lockstart;
|
prev_extent_end = lockstart;
|
||||||
|
|
||||||
lock_extent(&inode->io_tree, lockstart, lockend, &cached_state);
|
lock_extent(&inode->io_tree, lockstart, lockend, &cached_state);
|
||||||
@ -4034,7 +4032,7 @@ int extent_fiemap(struct btrfs_inode *inode, struct fiemap_extent_info *fieinfo,
|
|||||||
} else {
|
} else {
|
||||||
/* We have a regular extent. */
|
/* We have a regular extent. */
|
||||||
if (fieinfo->fi_extents_max) {
|
if (fieinfo->fi_extents_max) {
|
||||||
ret = btrfs_is_data_extent_shared(root, ino,
|
ret = btrfs_is_data_extent_shared(inode,
|
||||||
disk_bytenr,
|
disk_bytenr,
|
||||||
extent_gen,
|
extent_gen,
|
||||||
roots,
|
roots,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user