Skip to content

Commit 53645a9

Browse files
fdmananaChris Mason
authored andcommitted
Btrfs: remove duplicated ino cache's inode lookup
We're doing a unnecessary extra lookup of the ino cache's inode when we already have it (and holding a reference) during the process of saving the ino cache contents to disk. Therefore remove this extra lookup. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
1 parent d4b4087 commit 53645a9

3 files changed

Lines changed: 5 additions & 9 deletions

File tree

‎fs/btrfs/free-space-cache.c‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2967,19 +2967,15 @@ int load_free_ino_cache(struct btrfs_fs_info *fs_info, struct btrfs_root *root)
29672967

29682968
int btrfs_write_out_ino_cache(struct btrfs_root *root,
29692969
struct btrfs_trans_handle *trans,
2970-
struct btrfs_path *path)
2970+
struct btrfs_path *path,
2971+
struct inode *inode)
29712972
{
29722973
struct btrfs_free_space_ctl *ctl = root->free_ino_ctl;
2973-
struct inode *inode;
29742974
int ret;
29752975

29762976
if (!btrfs_test_opt(root, INODE_MAP_CACHE))
29772977
return 0;
29782978

2979-
inode = lookup_free_ino_inode(root, path);
2980-
if (IS_ERR(inode))
2981-
return 0;
2982-
29832979
ret = __btrfs_write_out_cache(root, inode, ctl, NULL, trans, path, 0);
29842980
if (ret) {
29852981
btrfs_delalloc_release_metadata(inode, inode->i_size);
@@ -2990,7 +2986,6 @@ int btrfs_write_out_ino_cache(struct btrfs_root *root,
29902986
#endif
29912987
}
29922988

2993-
iput(inode);
29942989
return ret;
29952990
}
29962991

‎fs/btrfs/free-space-cache.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ int load_free_ino_cache(struct btrfs_fs_info *fs_info,
7676
struct btrfs_root *root);
7777
int btrfs_write_out_ino_cache(struct btrfs_root *root,
7878
struct btrfs_trans_handle *trans,
79-
struct btrfs_path *path);
79+
struct btrfs_path *path,
80+
struct inode *inode);
8081

8182
void btrfs_init_free_space_ctl(struct btrfs_block_group_cache *block_group);
8283
int __btrfs_add_free_space(struct btrfs_free_space_ctl *ctl,

‎fs/btrfs/inode-map.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ int btrfs_save_ino_cache(struct btrfs_root *root,
503503
}
504504
btrfs_free_reserved_data_space(inode, prealloc);
505505

506-
ret = btrfs_write_out_ino_cache(root, trans, path);
506+
ret = btrfs_write_out_ino_cache(root, trans, path, inode);
507507
out_put:
508508
iput(inode);
509509
out_release:

0 commit comments

Comments
 (0)