Skip to content

Commit 0e996e7

Browse files
josefbacikkdave
authored andcommitted
btrfs: move ino_cache_inode dropping out of btrfs_free_fs_root
We are going to make root life be controlled soley by refcounting, and inodes will be one of the things that hold a ref on the root. This means we need to handle dropping the ino_cache_inode outside of the root freeing logic, so move it into btrfs_drop_and_free_fs_root() so it is cleaned up properly on unmount. Signed-off-by: Josef Bacik <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 3fd6372 commit 0e996e7

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

fs/btrfs/disk-io.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3912,12 +3912,15 @@ void btrfs_drop_and_free_fs_root(struct btrfs_fs_info *fs_info,
39123912
__btrfs_remove_free_space_cache(root->free_ino_pinned);
39133913
if (root->free_ino_ctl)
39143914
__btrfs_remove_free_space_cache(root->free_ino_ctl);
3915+
if (root->ino_cache_inode) {
3916+
iput(root->ino_cache_inode);
3917+
root->ino_cache_inode = NULL;
3918+
}
39153919
btrfs_free_fs_root(root);
39163920
}
39173921

39183922
void btrfs_free_fs_root(struct btrfs_root *root)
39193923
{
3920-
iput(root->ino_cache_inode);
39213924
WARN_ON(!RB_EMPTY_ROOT(&root->inode_tree));
39223925
if (root->anon_dev)
39233926
free_anon_bdev(root->anon_dev);

fs/btrfs/transaction.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2424,6 +2424,10 @@ int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root)
24242424
btrfs_debug(fs_info, "cleaner removing %llu", root->root_key.objectid);
24252425

24262426
btrfs_kill_all_delayed_nodes(root);
2427+
if (root->ino_cache_inode) {
2428+
iput(root->ino_cache_inode);
2429+
root->ino_cache_inode = NULL;
2430+
}
24272431

24282432
if (btrfs_header_backref_rev(root->node) <
24292433
BTRFS_MIXED_BACKREF_REV)

0 commit comments

Comments
 (0)